From 2e5f47375207983e0a0e03435fd35f11df864862 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Thu, 30 May 2013 11:21:01 +0200 Subject: [PATCH 001/206] 8015585: Missing regression test for 8011771 Missing regression test Reviewed-by: kvn --- .../test/compiler/8011771/Test8011771.java | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 hotspot/test/compiler/8011771/Test8011771.java diff --git a/hotspot/test/compiler/8011771/Test8011771.java b/hotspot/test/compiler/8011771/Test8011771.java new file mode 100644 index 00000000000..7827150cb24 --- /dev/null +++ b/hotspot/test/compiler/8011771/Test8011771.java @@ -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. + */ + +/* + * @test + * @bug 8011771 + * @summary Array bound check elimination's in block motion doesn't always reset its data structures from one step to the other. + * @run main/othervm -XX:-BackgroundCompilation Test8011771 + * + */ + +public class Test8011771 { + + static void m(int[] a, int[] b, int j) { + // Array bound check elimination inserts a predicate before + // the loop. We'll have the predicate fail, so the method is + // recompiled without optimistic optimizations + for (int i = 0; i < 10; i++) { + a[i] = i; + } + + // The test itself + a[j] = 0; + a[j+5] = 0; + b[j+4] = 0; // this range check shouldn't be eliminated + } + + static public void main(String[] args) { + int[] arr1 = new int[10], arr2 = new int[10]; + // force compilation: + for (int i = 0; i < 5000; i++) { + m(arr1, arr2, 0); + } + + try { + m(new int[1], null, 0); // force predicate failure + } catch(ArrayIndexOutOfBoundsException e) {} + + // force compilation again (no optimistic opts): + for (int i = 0; i < 5000; i++) { + m(arr1, arr2, 0); + } + + // Check that the range check on the second array wasn't optimized out + boolean success = false; + try { + m(arr1, new int[1], 0); + } catch(ArrayIndexOutOfBoundsException e) { + success = true; + } + if (success) { + System.out.println("TEST PASSED"); + } else { + throw new RuntimeException("TEST FAILED: erroneous bound check elimination"); + } + } +} From 337a9c1432aed56e04c020f541c183aa3b54e55d Mon Sep 17 00:00:00 2001 From: Christian Thalinger Date: Thu, 30 May 2013 08:37:08 -0700 Subject: [PATCH 002/206] 8015266: fix some -Wsign-compare warnings in adlc Reviewed-by: kvn --- hotspot/src/share/vm/adlc/archDesc.cpp | 4 +- hotspot/src/share/vm/adlc/dict2.cpp | 18 +++--- hotspot/src/share/vm/adlc/formssel.cpp | 83 ++++++++++++++------------ hotspot/src/share/vm/adlc/formssel.hpp | 16 ++--- hotspot/src/share/vm/adlc/output_c.cpp | 35 ++++++----- 5 files changed, 85 insertions(+), 71 deletions(-) diff --git a/hotspot/src/share/vm/adlc/archDesc.cpp b/hotspot/src/share/vm/adlc/archDesc.cpp index 7e272e4d028..412a728228a 100644 --- a/hotspot/src/share/vm/adlc/archDesc.cpp +++ b/hotspot/src/share/vm/adlc/archDesc.cpp @@ -29,8 +29,8 @@ static FILE *errfile = stderr; //--------------------------- utility functions ----------------------------- -inline char toUpper(char lower) { - return (('a' <= lower && lower <= 'z') ? (lower + ('A'-'a')) : lower); +inline char toUpper(char lower) { + return (('a' <= lower && lower <= 'z') ? ((char) (lower + ('A'-'a'))) : lower); } char *toUpper(const char *str) { char *upper = new char[strlen(str)+1]; diff --git a/hotspot/src/share/vm/adlc/dict2.cpp b/hotspot/src/share/vm/adlc/dict2.cpp index c7797c74223..24d7fcba023 100644 --- a/hotspot/src/share/vm/adlc/dict2.cpp +++ b/hotspot/src/share/vm/adlc/dict2.cpp @@ -64,18 +64,18 @@ void Dict::init() { int i; // Precompute table of null character hashes - if( !initflag ) { // Not initializated yet? - xsum[0] = (1<Amalloc_4(sizeof(bucket)*_size); - memset(_bin,0,sizeof(bucket)*_size); + _bin = (bucket*)_arena->Amalloc_4(sizeof(bucket) * _size); + memset(_bin, 0, sizeof(bucket) * _size); } //------------------------------~Dict------------------------------------------ @@ -287,11 +287,11 @@ int hashstr(const void *t) { register int sum = 0; register const char *s = (const char *)t; - while( ((c = s[k]) != '\0') && (k < MAXID-1) ) { // Get characters till nul - c = (c<<1)+1; // Characters are always odd! - sum += c + (c<> 1); // Hash key, un-modulo'd table size } diff --git a/hotspot/src/share/vm/adlc/formssel.cpp b/hotspot/src/share/vm/adlc/formssel.cpp index 42f1e3fad6f..27651dc68d7 100644 --- a/hotspot/src/share/vm/adlc/formssel.cpp +++ b/hotspot/src/share/vm/adlc/formssel.cpp @@ -796,11 +796,11 @@ uint InstructForm::num_opnds() { return num_opnds; } -const char *InstructForm::opnd_ident(int idx) { +const char* InstructForm::opnd_ident(int idx) { return _components.at(idx)->_name; } -const char *InstructForm::unique_opnd_ident(int idx) { +const char* InstructForm::unique_opnd_ident(uint idx) { uint i; for (i = 1; i < num_opnds(); ++i) { if (unique_opnds_idx(i) == idx) { @@ -1315,36 +1315,36 @@ void InstructForm::rep_var_format(FILE *fp, const char *rep_var) { // Seach through operands to determine parameters unique positions. void InstructForm::set_unique_opnds() { uint* uniq_idx = NULL; - int nopnds = num_opnds(); + uint nopnds = num_opnds(); uint num_uniq = nopnds; - int i; + uint i; _uniq_idx_length = 0; - if ( nopnds > 0 ) { + if (nopnds > 0) { // Allocate index array. Worst case we're mapping from each // component back to an index and any DEF always goes at 0 so the // length of the array has to be the number of components + 1. _uniq_idx_length = _components.count() + 1; - uniq_idx = (uint*) malloc(sizeof(uint)*(_uniq_idx_length)); - for( i = 0; i < _uniq_idx_length; i++ ) { + uniq_idx = (uint*) malloc(sizeof(uint) * _uniq_idx_length); + for (i = 0; i < _uniq_idx_length; i++) { uniq_idx[i] = i; } } // Do it only if there is a match rule and no expand rule. With an // expand rule it is done by creating new mach node in Expand() // method. - if ( nopnds > 0 && _matrule != NULL && _exprule == NULL ) { + if (nopnds > 0 && _matrule != NULL && _exprule == NULL) { const char *name; uint count; bool has_dupl_use = false; _parameters.reset(); - while( (name = _parameters.iter()) != NULL ) { + while ((name = _parameters.iter()) != NULL) { count = 0; - int position = 0; - int uniq_position = 0; + uint position = 0; + uint uniq_position = 0; _components.reset(); Component *comp = NULL; - if( sets_result() ) { + if (sets_result()) { comp = _components.iter(); position++; } @@ -1352,11 +1352,11 @@ void InstructForm::set_unique_opnds() { for (; (comp = _components.iter()) != NULL; ++position) { // When the first component is not a DEF, // leave space for the result operand! - if ( position==0 && (! comp->isa(Component::DEF)) ) { + if (position==0 && (!comp->isa(Component::DEF))) { ++position; } - if( strcmp(name, comp->_name)==0 ) { - if( ++count > 1 ) { + if (strcmp(name, comp->_name) == 0) { + if (++count > 1) { assert(position < _uniq_idx_length, "out of bounds"); uniq_idx[position] = uniq_position; has_dupl_use = true; @@ -1364,22 +1364,25 @@ void InstructForm::set_unique_opnds() { uniq_position = position; } } - if( comp->isa(Component::DEF) - && comp->isa(Component::USE) ) { + if (comp->isa(Component::DEF) && comp->isa(Component::USE)) { ++position; - if( position != 1 ) + if (position != 1) --position; // only use two slots for the 1st USE_DEF } } } - if( has_dupl_use ) { - for( i = 1; i < nopnds; i++ ) - if( i != uniq_idx[i] ) + if (has_dupl_use) { + for (i = 1; i < nopnds; i++) { + if (i != uniq_idx[i]) { break; - int j = i; - for( ; i < nopnds; i++ ) - if( i == uniq_idx[i] ) + } + } + uint j = i; + for (; i < nopnds; i++) { + if (i == uniq_idx[i]) { uniq_idx[i] = j++; + } + } num_uniq = j; } } @@ -2216,21 +2219,27 @@ RegClass* OperandForm::get_RegClass() const { bool OperandForm::is_bound_register() const { - RegClass *reg_class = get_RegClass(); - if (reg_class == NULL) return false; + RegClass* reg_class = get_RegClass(); + if (reg_class == NULL) { + return false; + } - const char * name = ideal_type(globalAD->globalNames()); - if (name == NULL) return false; + const char* name = ideal_type(globalAD->globalNames()); + if (name == NULL) { + return false; + } - int size = 0; - if (strcmp(name,"RegFlags")==0) size = 1; - if (strcmp(name,"RegI")==0) size = 1; - if (strcmp(name,"RegF")==0) size = 1; - if (strcmp(name,"RegD")==0) size = 2; - if (strcmp(name,"RegL")==0) size = 2; - if (strcmp(name,"RegN")==0) size = 1; - if (strcmp(name,"RegP")==0) size = globalAD->get_preproc_def("_LP64") ? 2 : 1; - if (size == 0) return false; + uint size = 0; + if (strcmp(name, "RegFlags") == 0) size = 1; + if (strcmp(name, "RegI") == 0) size = 1; + if (strcmp(name, "RegF") == 0) size = 1; + if (strcmp(name, "RegD") == 0) size = 2; + if (strcmp(name, "RegL") == 0) size = 2; + if (strcmp(name, "RegN") == 0) size = 1; + if (strcmp(name, "RegP") == 0) size = globalAD->get_preproc_def("_LP64") ? 2 : 1; + if (size == 0) { + return false; + } return size == reg_class->size(); } diff --git a/hotspot/src/share/vm/adlc/formssel.hpp b/hotspot/src/share/vm/adlc/formssel.hpp index 6f2975fc3a3..622d8902f45 100644 --- a/hotspot/src/share/vm/adlc/formssel.hpp +++ b/hotspot/src/share/vm/adlc/formssel.hpp @@ -106,7 +106,7 @@ public: const char *_ins_pipe; // Instruction Scheduling description class uint *_uniq_idx; // Indexes of unique operands - int _uniq_idx_length; // Length of _uniq_idx array + uint _uniq_idx_length; // Length of _uniq_idx array uint _num_uniq; // Number of unique operands ComponentList _components; // List of Components matches MachNode's // operand structure @@ -272,14 +272,14 @@ public: void set_unique_opnds(); uint num_unique_opnds() { return _num_uniq; } uint unique_opnds_idx(int idx) { - if( _uniq_idx != NULL && idx > 0 ) { - assert(idx < _uniq_idx_length, "out of bounds"); - return _uniq_idx[idx]; - } else { - return idx; - } + if (_uniq_idx != NULL && idx > 0) { + assert((uint)idx < _uniq_idx_length, "out of bounds"); + return _uniq_idx[idx]; + } else { + return idx; + } } - const char *unique_opnd_ident(int idx); // Name of operand at unique idx. + const char *unique_opnd_ident(uint idx); // Name of operand at unique idx. // Operands which are only KILLs aren't part of the input array and // require special handling in some cases. Their position in this diff --git a/hotspot/src/share/vm/adlc/output_c.cpp b/hotspot/src/share/vm/adlc/output_c.cpp index f86dd21fc3b..a9bd95177eb 100644 --- a/hotspot/src/share/vm/adlc/output_c.cpp +++ b/hotspot/src/share/vm/adlc/output_c.cpp @@ -463,8 +463,9 @@ static int pipeline_res_mask_initializer( uint resources_used_exclusively = 0; for (pipeclass->_resUsage.reset(); - (piperesource = (const PipeClassResourceForm *)pipeclass->_resUsage.iter()) != NULL; ) + (piperesource = (const PipeClassResourceForm*)pipeclass->_resUsage.iter()) != NULL; ) { element_count++; + } // Pre-compute the string length int templen; @@ -482,8 +483,8 @@ static int pipeline_res_mask_initializer( for (i = rescount; i > 0; i /= 10) maskdigit++; - static const char * pipeline_use_cycle_mask = "Pipeline_Use_Cycle_Mask"; - static const char * pipeline_use_element = "Pipeline_Use_Element"; + static const char* pipeline_use_cycle_mask = "Pipeline_Use_Cycle_Mask"; + static const char* pipeline_use_element = "Pipeline_Use_Element"; templen = 1 + (int)(strlen(pipeline_use_cycle_mask) + (int)strlen(pipeline_use_element) + @@ -496,11 +497,12 @@ static int pipeline_res_mask_initializer( templen = 0; for (pipeclass->_resUsage.reset(); - (piperesource = (const PipeClassResourceForm *)pipeclass->_resUsage.iter()) != NULL; ) { + (piperesource = (const PipeClassResourceForm*)pipeclass->_resUsage.iter()) != NULL; ) { int used_mask = pipeline->_resdict[piperesource->_resource]->is_resource()->mask(); - if (!used_mask) + if (!used_mask) { fprintf(stderr, "*** used_mask is 0 ***\n"); + } resources_used |= used_mask; @@ -509,8 +511,9 @@ static int pipeline_res_mask_initializer( for (lb = 0; (used_mask & (1 << lb)) == 0; lb++); for (ub = 31; (used_mask & (1 << ub)) == 0; ub--); - if (lb == ub) + if (lb == ub) { resources_used_exclusively |= used_mask; + } int formatlen = sprintf(&resource_mask[templen], " %s(0x%0*x, %*d, %*d, %s %s(", @@ -526,7 +529,7 @@ static int pipeline_res_mask_initializer( int cycles = piperesource->_cycles; uint stage = pipeline->_stages.index(piperesource->_stage); - if (NameList::Not_in_list == stage) { + if ((uint)NameList::Not_in_list == stage) { fprintf(stderr, "pipeline_res_mask_initializer: " "semantic error: " @@ -534,8 +537,8 @@ static int pipeline_res_mask_initializer( piperesource->_stage); exit(1); } - uint upper_limit = stage+cycles-1; - uint lower_limit = stage-1; + uint upper_limit = stage + cycles - 1; + uint lower_limit = stage - 1; uint upper_idx = upper_limit >> 5; uint lower_idx = lower_limit >> 5; uint upper_position = upper_limit & 0x1f; @@ -543,7 +546,7 @@ static int pipeline_res_mask_initializer( uint mask = (((uint)1) << upper_position) - 1; - while ( upper_idx > lower_idx ) { + while (upper_idx > lower_idx) { res_mask[upper_idx--] |= mask; mask = (uint)-1; } @@ -565,8 +568,9 @@ static int pipeline_res_mask_initializer( } resource_mask[templen] = 0; - if (last_comma) + if (last_comma) { last_comma[0] = ' '; + } // See if the same string is in the table int ndx = pipeline_res_mask.index(resource_mask); @@ -580,7 +584,7 @@ static int pipeline_res_mask_initializer( fprintf(fp_cpp, "static const Pipeline_Use_Element pipeline_res_mask_%03d[%d] = {\n%s};\n\n", ndx+1, element_count, resource_mask); - char * args = new char [9 + 2*masklen + maskdigit]; + char* args = new char [9 + 2*masklen + maskdigit]; sprintf(args, "0x%0*x, 0x%0*x, %*d", masklen, resources_used, @@ -589,8 +593,9 @@ static int pipeline_res_mask_initializer( pipeline_res_args.addName(args); } - else + else { delete [] resource_mask; + } delete [] res_mask; //delete [] res_masks; @@ -1787,7 +1792,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { // Skip first unique operands. for( i = 1; i < cur_num_opnds; i++ ) { comp = node->_components.iter(); - if( (int)i != node->unique_opnds_idx(i) ) { + if (i != node->unique_opnds_idx(i)) { break; } new_num_opnds++; @@ -1795,7 +1800,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { // Replace not unique operands with next unique operands. for( ; i < cur_num_opnds; i++ ) { comp = node->_components.iter(); - int j = node->unique_opnds_idx(i); + uint j = node->unique_opnds_idx(i); // unique_opnds_idx(i) is unique if unique_opnds_idx(j) is not unique. if( j != node->unique_opnds_idx(j) ) { fprintf(fp," set_opnd_array(%d, opnd_array(%d)->clone(C)); // %s\n", From 6a17746b6cbb6d30cb42cf1e115e99d7789f3b5b Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Fri, 31 May 2013 14:40:26 +0200 Subject: [PATCH 003/206] 8009981: nashorn tests fail with -XX:+VerifyStack Nmethod::preserve_callee_argument_oops() must take appendix into account. Reviewed-by: kvn, twisti --- hotspot/src/share/vm/code/nmethod.cpp | 7 +++---- hotspot/src/share/vm/runtime/deoptimization.cpp | 15 ++++++++++----- hotspot/src/share/vm/runtime/frame.cpp | 16 +++++++++++----- hotspot/src/share/vm/runtime/frame.hpp | 2 +- hotspot/src/share/vm/runtime/sharedRuntime.cpp | 7 ++++++- hotspot/src/share/vm/runtime/sharedRuntime.hpp | 2 +- 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index 597a7ac548e..53f8cd07be8 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -1976,11 +1976,10 @@ void nmethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map if (!method()->is_native()) { SimpleScopeDesc ssd(this, fr.pc()); Bytecode_invoke call(ssd.method(), ssd.bci()); - // compiled invokedynamic call sites have an implicit receiver at - // resolution time, so make sure it gets GC'ed. - bool has_receiver = !call.is_invokestatic(); + bool has_receiver = call.has_receiver(); + bool has_appendix = call.has_appendix(); Symbol* signature = call.signature(); - fr.oops_compiled_arguments_do(signature, has_receiver, reg_map, f); + fr.oops_compiled_arguments_do(signature, has_receiver, has_appendix, reg_map, f); } #endif // !SHARK } diff --git a/hotspot/src/share/vm/runtime/deoptimization.cpp b/hotspot/src/share/vm/runtime/deoptimization.cpp index 4a8d52b1284..7f71c2d8b76 100644 --- a/hotspot/src/share/vm/runtime/deoptimization.cpp +++ b/hotspot/src/share/vm/runtime/deoptimization.cpp @@ -635,18 +635,22 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m // at an uncommon trap for an invoke (where the compiler // generates debug info before the invoke has executed) Bytecodes::Code cur_code = str.next(); - if (cur_code == Bytecodes::_invokevirtual || - cur_code == Bytecodes::_invokespecial || - cur_code == Bytecodes::_invokestatic || - cur_code == Bytecodes::_invokeinterface) { + if (cur_code == Bytecodes::_invokevirtual || + cur_code == Bytecodes::_invokespecial || + cur_code == Bytecodes::_invokestatic || + cur_code == Bytecodes::_invokeinterface || + cur_code == Bytecodes::_invokedynamic) { Bytecode_invoke invoke(mh, iframe->interpreter_frame_bci()); Symbol* signature = invoke.signature(); ArgumentSizeComputer asc(signature); cur_invoke_parameter_size = asc.size(); - if (cur_code != Bytecodes::_invokestatic) { + if (invoke.has_receiver()) { // Add in receiver ++cur_invoke_parameter_size; } + if (i != 0 && !invoke.is_invokedynamic() && MethodHandles::has_member_arg(invoke.klass(), invoke.name())) { + callee_size_of_parameters++; + } } if (str.bci() < max_bci) { Bytecodes::Code bc = str.next(); @@ -661,6 +665,7 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m case Bytecodes::_invokespecial: case Bytecodes::_invokestatic: case Bytecodes::_invokeinterface: + case Bytecodes::_invokedynamic: case Bytecodes::_athrow: break; default: { diff --git a/hotspot/src/share/vm/runtime/frame.cpp b/hotspot/src/share/vm/runtime/frame.cpp index e1913829702..e5caf604d98 100644 --- a/hotspot/src/share/vm/runtime/frame.cpp +++ b/hotspot/src/share/vm/runtime/frame.cpp @@ -1008,6 +1008,7 @@ class CompiledArgumentOopFinder: public SignatureInfo { OopClosure* _f; int _offset; // the current offset, incremented with each argument bool _has_receiver; // true if the callee has a receiver + bool _has_appendix; // true if the call has an appendix frame _fr; RegisterMap* _reg_map; int _arg_size; @@ -1027,19 +1028,20 @@ class CompiledArgumentOopFinder: public SignatureInfo { } public: - CompiledArgumentOopFinder(Symbol* signature, bool has_receiver, OopClosure* f, frame fr, const RegisterMap* reg_map) + CompiledArgumentOopFinder(Symbol* signature, bool has_receiver, bool has_appendix, OopClosure* f, frame fr, const RegisterMap* reg_map) : SignatureInfo(signature) { // initialize CompiledArgumentOopFinder _f = f; _offset = 0; _has_receiver = has_receiver; + _has_appendix = has_appendix; _fr = fr; _reg_map = (RegisterMap*)reg_map; - _arg_size = ArgumentSizeComputer(signature).size() + (has_receiver ? 1 : 0); + _arg_size = ArgumentSizeComputer(signature).size() + (has_receiver ? 1 : 0) + (has_appendix ? 1 : 0); int arg_size; - _regs = SharedRuntime::find_callee_arguments(signature, has_receiver, &arg_size); + _regs = SharedRuntime::find_callee_arguments(signature, has_receiver, has_appendix, &arg_size); assert(arg_size == _arg_size, "wrong arg size"); } @@ -1049,12 +1051,16 @@ class CompiledArgumentOopFinder: public SignatureInfo { _offset++; } iterate_parameters(); + if (_has_appendix) { + handle_oop_offset(); + _offset++; + } } }; -void frame::oops_compiled_arguments_do(Symbol* signature, bool has_receiver, const RegisterMap* reg_map, OopClosure* f) { +void frame::oops_compiled_arguments_do(Symbol* signature, bool has_receiver, bool has_appendix, const RegisterMap* reg_map, OopClosure* f) { ResourceMark rm; - CompiledArgumentOopFinder finder(signature, has_receiver, f, *this, reg_map); + CompiledArgumentOopFinder finder(signature, has_receiver, has_appendix, f, *this, reg_map); finder.oops_do(); } diff --git a/hotspot/src/share/vm/runtime/frame.hpp b/hotspot/src/share/vm/runtime/frame.hpp index 2e27430f7fb..1baa38fb6c3 100644 --- a/hotspot/src/share/vm/runtime/frame.hpp +++ b/hotspot/src/share/vm/runtime/frame.hpp @@ -411,7 +411,7 @@ class frame VALUE_OBJ_CLASS_SPEC { oop* oopmapreg_to_location(VMReg reg, const RegisterMap* regmap) const; // Oops-do's - void oops_compiled_arguments_do(Symbol* signature, bool has_receiver, const RegisterMap* reg_map, OopClosure* f); + void oops_compiled_arguments_do(Symbol* signature, bool has_receiver, bool has_appendix, const RegisterMap* reg_map, OopClosure* f); void oops_interpreted_do(OopClosure* f, CLDToOopClosure* cld_f, const RegisterMap* map, bool query_oop_map_cache = true); private: diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index 114f27d20a8..fe55e8b0e6b 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -2726,7 +2726,7 @@ VMReg SharedRuntime::name_for_receiver() { return regs.first(); } -VMRegPair *SharedRuntime::find_callee_arguments(Symbol* sig, bool has_receiver, int* arg_size) { +VMRegPair *SharedRuntime::find_callee_arguments(Symbol* sig, bool has_receiver, bool has_appendix, int* arg_size) { // This method is returning a data structure allocating as a // ResourceObject, so do not put any ResourceMarks in here. char *s = sig->as_C_string(); @@ -2770,6 +2770,11 @@ VMRegPair *SharedRuntime::find_callee_arguments(Symbol* sig, bool has_receiver, default : ShouldNotReachHere(); } } + + if (has_appendix) { + sig_bt[cnt++] = T_OBJECT; + } + assert( cnt < 256, "grow table size" ); int comp_args_on_stack; diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.hpp b/hotspot/src/share/vm/runtime/sharedRuntime.hpp index e6867645ae6..a7f0d92a1fb 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp @@ -410,7 +410,7 @@ class SharedRuntime: AllStatic { // Convert a sig into a calling convention register layout // and find interesting things about it. - static VMRegPair* find_callee_arguments(Symbol* sig, bool has_receiver, int *arg_size); + static VMRegPair* find_callee_arguments(Symbol* sig, bool has_receiver, bool has_appendix, int *arg_size); static VMReg name_for_receiver(); // "Top of Stack" slots that may be unused by the calling convention but must From ff008d061551555640074f1acbfcadf3ef23cf1e Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Fri, 31 May 2013 13:54:47 -0700 Subject: [PATCH 004/206] 8015441: runThese crashed with assert(opcode == Op_ConP || opcode == Op_ThreadLocal || opcode == Op_CastX2P ..) failed: sanity Relax the assert to accept any raw ptr types. Reviewed-by: roland --- hotspot/src/share/vm/opto/escape.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/opto/escape.cpp b/hotspot/src/share/vm/opto/escape.cpp index f29f82b3539..96f0011b3b2 100644 --- a/hotspot/src/share/vm/opto/escape.cpp +++ b/hotspot/src/share/vm/opto/escape.cpp @@ -2202,7 +2202,7 @@ Node* ConnectionGraph::get_addp_base(Node *addp) { int opcode = uncast_base->Opcode(); assert(opcode == Op_ConP || opcode == Op_ThreadLocal || opcode == Op_CastX2P || uncast_base->is_DecodeNarrowPtr() || - (uncast_base->is_Mem() && uncast_base->bottom_type() == TypeRawPtr::NOTNULL) || + (uncast_base->is_Mem() && (uncast_base->bottom_type()->isa_rawptr() != NULL)) || (uncast_base->is_Proj() && uncast_base->in(0)->is_Allocate()), "sanity"); } return base; From 34f8be0bc97c236d84fdd528c7ba63a3bd168e4b Mon Sep 17 00:00:00 2001 From: Albert Noll Date: Fri, 31 May 2013 06:41:50 +0200 Subject: [PATCH 005/206] 8013496: Code cache management command line options work only in special order. Another order of arguments does not deliver the second parameter to the jvm Moved check that ReservedCodeCacheSize >= InitialCodeCacheSize to Arguments::check_vm_args_consistency(). As a result, the ordering in which the two parameters are given to the VM is not relevant. Added a regression test. Reviewed-by: kvn, twisti --- hotspot/src/share/vm/runtime/arguments.cpp | 14 +++-- hotspot/test/compiler/8013496/Test8013496.sh | 55 ++++++++++++++++++++ 2 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 hotspot/test/compiler/8013496/Test8013496.sh diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 83f4660a0c7..7cfd7a42eb7 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -2217,6 +2217,13 @@ bool Arguments::check_vm_args_consistency() { status = false; } + if (ReservedCodeCacheSize < InitialCodeCacheSize) { + jio_fprintf(defaultStream::error_stream(), + "Invalid ReservedCodeCacheSize: %dK. Should be greater than InitialCodeCacheSize=%dK\n", + ReservedCodeCacheSize/K, InitialCodeCacheSize/K); + status = false; + } + return status; } @@ -2619,13 +2626,10 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, } else if (match_option(option, "-Xmaxjitcodesize", &tail) || match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) { julong long_ReservedCodeCacheSize = 0; - ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, - (size_t)InitialCodeCacheSize); + ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 1); if (errcode != arg_in_range) { jio_fprintf(defaultStream::error_stream(), - "Invalid maximum code cache size: %s. Should be greater than InitialCodeCacheSize=%dK\n", - option->optionString, InitialCodeCacheSize/K); - describe_range_error(errcode); + "Invalid maximum code cache size: %s.\n", option->optionString); return JNI_EINVAL; } FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize); diff --git a/hotspot/test/compiler/8013496/Test8013496.sh b/hotspot/test/compiler/8013496/Test8013496.sh new file mode 100644 index 00000000000..ae1d1fe34ff --- /dev/null +++ b/hotspot/test/compiler/8013496/Test8013496.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# +# 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 8013496 +# @summary Test checks that the order in which ReversedCodeCacheSize and +# InitialCodeCacheSize are passed to the VM is irrelevant. +# @run shell Test8013496.sh +# +# +## some tests require path to find test source dir +if [ "${TESTSRC}" = "" ] +then + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" +fi +echo "TESTSRC=${TESTSRC}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh +set -x + +${TESTJAVA}/bin/java ${TESTVMOPTS} -XX:ReservedCodeCacheSize=2m -XX:InitialCodeCacheSize=500K -version > 1.out 2>&1 +${TESTJAVA}/bin/java ${TESTVMOPTS} -XX:InitialCodeCacheSize=500K -XX:ReservedCodeCacheSize=2m -version > 2.out 2>&1 + +diff 1.out 2.out + +result=$? +if [ $result -eq 0 ] ; then + echo "Test Passed" + exit 0 +else + echo "Test Failed" + exit 1 +fi From 6ae26f2e9424d37ab38a051ab2a75cba46f0e9d0 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Wed, 24 Apr 2013 11:49:38 +0200 Subject: [PATCH 006/206] 8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292 ConstMethod::max_stack() doesn't account for JSR 292 appendix. Reviewed-by: kvn --- .../src/cpu/sparc/vm/cppInterpreter_sparc.cpp | 11 +++------- .../src/cpu/sparc/vm/interp_masm_sparc.cpp | 2 +- .../sparc/vm/templateInterpreter_sparc.cpp | 3 +-- hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp | 15 +++++--------- .../cpu/x86/vm/templateInterpreter_x86_32.cpp | 3 +-- .../cpu/x86/vm/templateInterpreter_x86_64.cpp | 3 +-- .../vm/interpreter/bytecodeInterpreter.cpp | 20 ++++++++++++++++++- hotspot/src/share/vm/oops/method.hpp | 14 +++++++------ hotspot/src/share/vm/opto/matcher.cpp | 10 ---------- 9 files changed, 39 insertions(+), 42 deletions(-) diff --git a/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp b/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp index 8a71d0923ab..5750e5f587f 100644 --- a/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp @@ -1065,7 +1065,7 @@ void CppInterpreterGenerator::generate_compute_interpreter_state(const Register const int slop_factor = 2*wordSize; const int fixed_size = ((sizeof(BytecodeInterpreter) + slop_factor) >> LogBytesPerWord) + // what is the slop factor? - //6815692//Method::extra_stack_words() + // extra push slots for MH adapters + Method::extra_stack_entries() + // extra stack for jsr 292 frame::memory_parameter_word_sp_offset + // register save area + param window (native ? frame::interpreter_frame_extra_outgoing_argument_words : 0); // JNI, class @@ -1221,9 +1221,7 @@ void CppInterpreterGenerator::generate_compute_interpreter_state(const Register // Full size expression stack __ ld_ptr(constMethod, O3); __ lduh(O3, in_bytes(ConstMethod::max_stack_offset()), O3); - guarantee(!EnableInvokeDynamic, "no support yet for java.lang.invoke.MethodHandle"); //6815692 - //6815692//if (EnableInvokeDynamic) - //6815692// __ inc(O3, Method::extra_stack_entries()); + __ inc(O3, Method::extra_stack_entries()); __ sll(O3, LogBytesPerWord, O3); __ sub(O2, O3, O3); // __ sub(O3, wordSize, O3); // so prepush doesn't look out of bounds @@ -2084,9 +2082,7 @@ static int size_activation_helper(int callee_extra_locals, int max_stack, int mo const int fixed_size = sizeof(BytecodeInterpreter)/wordSize + // interpreter state object frame::memory_parameter_word_sp_offset; // register save area + param window - const int extra_stack = 0; //6815692//Method::extra_stack_entries(); return (round_to(max_stack + - extra_stack + slop_factor + fixed_size + monitor_size + @@ -2173,8 +2169,7 @@ void BytecodeInterpreter::layout_interpreterState(interpreterState to_fill, // Need +1 here because stack_base points to the word just above the first expr stack entry // and stack_limit is supposed to point to the word just below the last expr stack entry. // See generate_compute_interpreter_state. - int extra_stack = 0; //6815692//Method::extra_stack_entries(); - to_fill->_stack_limit = stack_base - (method->max_stack() + 1 + extra_stack); + to_fill->_stack_limit = stack_base - (method->max_stack() + 1); to_fill->_monitor_base = (BasicObjectLock*) monitor_base; // sparc specific diff --git a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp index d4f8b9b2341..9775d2f871a 100644 --- a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp @@ -521,7 +521,7 @@ void InterpreterMacroAssembler::empty_expression_stack() { // Compute max expression stack+register save area ld_ptr(Lmethod, in_bytes(Method::const_offset()), Gframe_size); lduh(Gframe_size, in_bytes(ConstMethod::max_stack_offset()), Gframe_size); // Load max stack. - add( Gframe_size, frame::memory_parameter_word_sp_offset, Gframe_size ); + add(Gframe_size, frame::memory_parameter_word_sp_offset+Method::extra_stack_entries(), Gframe_size ); // // now set up a stack frame with the size computed above diff --git a/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp b/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp index d8281cadaec..135760ec0b4 100644 --- a/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp @@ -507,7 +507,7 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { const int extra_space = rounded_vm_local_words + // frame local scratch space - //6815692//Method::extra_stack_words() + // extra push slots for MH adapters + Method::extra_stack_entries() + // extra stack for jsr 292 frame::memory_parameter_word_sp_offset + // register save area (native_call ? frame::interpreter_frame_extra_outgoing_argument_words : 0); @@ -1558,7 +1558,6 @@ static int size_activation_helper(int callee_extra_locals, int max_stack, int mo round_to(callee_extra_locals * Interpreter::stackElementWords, WordsPerLong); const int max_stack_words = max_stack * Interpreter::stackElementWords; return (round_to((max_stack_words - //6815692//+ Method::extra_stack_words() + rounded_vm_local_words + frame::memory_parameter_word_sp_offset), WordsPerLong) // already rounded diff --git a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp index 08db8e074d0..1eef095b9a5 100644 --- a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp +++ b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp @@ -539,12 +539,11 @@ void CppInterpreterGenerator::generate_compute_interpreter_state(const Register // compute full expression stack limit - const int extra_stack = 0; //6815692//Method::extra_stack_words(); __ movptr(rdx, Address(rbx, Method::const_offset())); __ load_unsigned_short(rdx, Address(rdx, ConstMethod::max_stack_offset())); // get size of expression stack in words __ negptr(rdx); // so we can subtract in next step // Allocate expression stack - __ lea(rsp, Address(rsp, rdx, Address::times_ptr, -extra_stack)); + __ lea(rsp, Address(rsp, rdx, Address::times_ptr, -Method::extra_stack_words())); __ movptr(STATE(_stack_limit), rsp); } @@ -692,10 +691,9 @@ void InterpreterGenerator::generate_stack_overflow_check(void) { // Always give one monitor to allow us to start interp if sync method. // Any additional monitors need a check when moving the expression stack const int one_monitor = frame::interpreter_frame_monitor_size() * wordSize; - const int extra_stack = 0; //6815692//Method::extra_stack_entries(); __ movptr(rax, Address(rbx, Method::const_offset())); __ load_unsigned_short(rax, Address(rax, ConstMethod::max_stack_offset())); // get size of expression stack in words - __ lea(rax, Address(noreg, rax, Interpreter::stackElementScale(), extra_stack + one_monitor)); + __ lea(rax, Address(noreg, rax, Interpreter::stackElementScale(), one_monitor+Method::extra_stack_words())); __ lea(rax, Address(rax, rdx, Interpreter::stackElementScale(), overhead_size)); #ifdef ASSERT @@ -2265,8 +2263,7 @@ int AbstractInterpreter::size_top_interpreter_activation(Method* method) { const int overhead_size = sizeof(BytecodeInterpreter)/wordSize + ( frame::sender_sp_offset - frame::link_offset) + 2; - const int extra_stack = 0; //6815692//Method::extra_stack_entries(); - const int method_stack = (method->max_locals() + method->max_stack() + extra_stack) * + const int method_stack = (method->max_locals() + method->max_stack()) * Interpreter::stackElementWords; return overhead_size + method_stack + stub_code; } @@ -2331,8 +2328,7 @@ void BytecodeInterpreter::layout_interpreterState(interpreterState to_fill, // Need +1 here because stack_base points to the word just above the first expr stack entry // and stack_limit is supposed to point to the word just below the last expr stack entry. // See generate_compute_interpreter_state. - int extra_stack = 0; //6815692//Method::extra_stack_entries(); - to_fill->_stack_limit = stack_base - (method->max_stack() + extra_stack + 1); + to_fill->_stack_limit = stack_base - (method->max_stack() + 1); to_fill->_monitor_base = (BasicObjectLock*) monitor_base; to_fill->_self_link = to_fill; @@ -2380,8 +2376,7 @@ int AbstractInterpreter::layout_activation(Method* method, monitor_size); // Now with full size expression stack - int extra_stack = 0; //6815692//Method::extra_stack_entries(); - int full_frame_size = short_frame_size + (method->max_stack() + extra_stack) * BytesPerWord; + int full_frame_size = short_frame_size + method->max_stack() * BytesPerWord; // and now with only live portion of the expression stack short_frame_size = short_frame_size + tempcount * BytesPerWord; diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp index ca3ab92f2d0..3908a8c09da 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp @@ -1565,8 +1565,7 @@ int AbstractInterpreter::size_top_interpreter_activation(Method* method) { // be sure to change this if you add/subtract anything to/from the overhead area const int overhead_size = -frame::interpreter_frame_initial_sp_offset; - const int extra_stack = Method::extra_stack_entries(); - const int method_stack = (method->max_locals() + method->max_stack() + extra_stack) * + const int method_stack = (method->max_locals() + method->max_stack()) * Interpreter::stackElementWords; return overhead_size + method_stack + stub_code; } diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp index 4ad577ca4c9..50bb8a968f6 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp @@ -1574,8 +1574,7 @@ int AbstractInterpreter::size_top_interpreter_activation(Method* method) { -(frame::interpreter_frame_initial_sp_offset) + entry_size; const int stub_code = frame::entry_frame_after_call_words; - const int extra_stack = Method::extra_stack_entries(); - const int method_stack = (method->max_locals() + method->max_stack() + extra_stack) * + const int method_stack = (method->max_locals() + method->max_stack()) * Interpreter::stackElementWords; return (overhead_size + method_stack + stub_code); } diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp index 1b9a7d2fd9a..8f0ec849cca 100644 --- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp +++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp @@ -468,7 +468,25 @@ BytecodeInterpreter::run(interpreterState istate) { #ifdef ASSERT if (istate->_msg != initialize) { - assert(abs(istate->_stack_base - istate->_stack_limit) == (istate->_method->max_stack() + 1), "bad stack limit"); + // We have a problem here if we are running with a pre-hsx24 JDK (for example during bootstrap) + // because in that case, EnableInvokeDynamic is true by default but will be later switched off + // if java_lang_invoke_MethodHandle::compute_offsets() detects that the JDK only has the classes + // for the old JSR292 implementation. + // This leads to a situation where 'istate->_stack_limit' always accounts for + // methodOopDesc::extra_stack_entries() because it is computed in + // CppInterpreterGenerator::generate_compute_interpreter_state() which was generated while + // EnableInvokeDynamic was still true. On the other hand, istate->_method->max_stack() doesn't + // account for extra_stack_entries() anymore because at the time when it is called + // EnableInvokeDynamic was already set to false. + // So we have a second version of the assertion which handles the case where EnableInvokeDynamic was + // switched off because of the wrong classes. + if (EnableInvokeDynamic || FLAG_IS_CMDLINE(EnableInvokeDynamic)) { + assert(abs(istate->_stack_base - istate->_stack_limit) == (istate->_method->max_stack() + 1), "bad stack limit"); + } else { + const int extra_stack_entries = Method::extra_stack_entries_for_indy; + assert(labs(istate->_stack_base - istate->_stack_limit) == (istate->_method->max_stack() + extra_stack_entries + + 1), "bad stack limit"); + } #ifndef SHARK IA32_ONLY(assert(istate->_stack_limit == istate->_thread->last_Java_sp() + 1, "wrong")); #endif // !SHARK diff --git a/hotspot/src/share/vm/oops/method.hpp b/hotspot/src/share/vm/oops/method.hpp index 54c2647b790..250d5c0d65f 100644 --- a/hotspot/src/share/vm/oops/method.hpp +++ b/hotspot/src/share/vm/oops/method.hpp @@ -671,13 +671,15 @@ class Method : public Metadata { Symbol* signature, //anything at all TRAPS); static Klass* check_non_bcp_klass(Klass* klass); - // these operate only on invoke methods: + + // How many extra stack entries for invokedynamic when it's enabled + static const int extra_stack_entries_for_jsr292 = 1; + + // this operates only on invoke methods: // presize interpreter frames for extra interpreter stack entries, if needed - // method handles want to be able to push a few extra values (e.g., a bound receiver), and - // invokedynamic sometimes needs to push a bootstrap method, call site, and arglist, - // all without checking for a stack overflow - static int extra_stack_entries() { return EnableInvokeDynamic ? 2 : 0; } - static int extra_stack_words(); // = extra_stack_entries() * Interpreter::stackElementSize() + // Account for the extra appendix argument for invokehandle/invokedynamic + static int extra_stack_entries() { return EnableInvokeDynamic ? extra_stack_entries_for_jsr292 : 0; } + static int extra_stack_words(); // = extra_stack_entries() * Interpreter::stackElementSize // RedefineClasses() support: bool is_old() const { return access_flags().is_old(); } diff --git a/hotspot/src/share/vm/opto/matcher.cpp b/hotspot/src/share/vm/opto/matcher.cpp index ffd3cc28346..91b4448c9bc 100644 --- a/hotspot/src/share/vm/opto/matcher.cpp +++ b/hotspot/src/share/vm/opto/matcher.cpp @@ -1282,16 +1282,6 @@ MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) { mcall->_argsize = out_arg_limit_per_call - begin_out_arg_area; } - if (is_method_handle_invoke) { - // Kill some extra stack space in case method handles want to do - // a little in-place argument insertion. - // FIXME: Is this still necessary? - int regs_per_word = NOT_LP64(1) LP64_ONLY(2); // %%% make a global const! - out_arg_limit_per_call += Method::extra_stack_entries() * regs_per_word; - // Do not update mcall->_argsize because (a) the extra space is not - // pushed as arguments and (b) _argsize is dead (not used anywhere). - } - // Compute the max stack slot killed by any call. These will not be // available for debug info, and will be used to adjust FIRST_STACK_mask // after all call sites have been visited. From df78dbbf736d02540793c9aff47fed1a3b465228 Mon Sep 17 00:00:00 2001 From: James Laskey Date: Tue, 14 May 2013 11:15:12 -0300 Subject: [PATCH 007/206] 8014512: Exclude testing and infrastructure packages from code coverage Reviewed-by: sundar --- nashorn/make/code_coverage.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nashorn/make/code_coverage.xml b/nashorn/make/code_coverage.xml index 33980bdfdf6..457f6308154 100644 --- a/nashorn/make/code_coverage.xml +++ b/nashorn/make/code_coverage.xml @@ -139,6 +139,20 @@ + + + + + + + + + + + + + + From ca08772ec8f1f3b62f03dba6b9617c944c2c2d45 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Tue, 14 May 2013 19:18:17 +0200 Subject: [PATCH 008/206] 8011718: binding already bound function with extra arguments fails Reviewed-by: jlaskey, sundar --- .../internal/runtime/ScriptFunctionData.java | 9 ++-- nashorn/test/script/basic/JDK-8011718.js | 46 +++++++++++++++++++ .../test/script/basic/JDK-8011718.js.EXPECTED | 2 + 3 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8011718.js create mode 100644 nashorn/test/script/basic/JDK-8011718.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java index f83cfa2c954..1e899be5805 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java @@ -25,14 +25,13 @@ package jdk.nashorn.internal.runtime; +import static jdk.nashorn.internal.lookup.Lookup.MH; import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; -import static jdk.nashorn.internal.lookup.Lookup.MH; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; - import jdk.nashorn.internal.runtime.linker.JavaAdapterFactory; /** @@ -389,7 +388,9 @@ public abstract class ScriptFunctionData { boundInvoker = noArgBoundInvoker; } } else { - final Object[] boundArgs = new Object[Math.min(originalInvoker.type().parameterCount(), args.length + (isTargetBound ? 0 : (needsCallee ? 2 : 1)))]; + // If target is already bound, insert additional bound arguments after "this" argument, at position 1. + final int argInsertPos = isTargetBound ? 1 : 0; + final Object[] boundArgs = new Object[Math.min(originalInvoker.type().parameterCount() - argInsertPos, args.length + (isTargetBound ? 0 : (needsCallee ? 2 : 1)))]; int next = 0; if (!isTargetBound) { if (needsCallee) { @@ -403,7 +404,7 @@ public abstract class ScriptFunctionData { // "this" will get dropped anyway by the target invoker. We previously asserted that already bound functions // don't take a callee parameter, so we can know that the signature is (this[, args...]) therefore args // start at position 1. If the function is not bound, we start inserting arguments at position 0. - boundInvoker = MH.insertArguments(originalInvoker, isTargetBound ? 1 : 0, boundArgs); + boundInvoker = MH.insertArguments(originalInvoker, argInsertPos, boundArgs); } if (isTargetBound) { diff --git a/nashorn/test/script/basic/JDK-8011718.js b/nashorn/test/script/basic/JDK-8011718.js new file mode 100644 index 00000000000..7cb24f24f10 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8011718.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8011718: binding already bound function with extra arguments fails. + * + * @test + * @run + */ + +var obj = { + hello:"From obj", +}; +var obj2 = { + hello:"From obj2", +}; + +function doit(cb){ + cb(); + var cb2 = cb.bind(obj2, "This one is not acccepted"); + cb2(); +} + +doit(function(){ + print(this.hello); + }.bind(obj)); diff --git a/nashorn/test/script/basic/JDK-8011718.js.EXPECTED b/nashorn/test/script/basic/JDK-8011718.js.EXPECTED new file mode 100644 index 00000000000..58a7d55629a --- /dev/null +++ b/nashorn/test/script/basic/JDK-8011718.js.EXPECTED @@ -0,0 +1,2 @@ +From obj +From obj From 41f972c2ed5411b7d1862048268a9d265da16241 Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Tue, 14 May 2013 19:56:35 +0200 Subject: [PATCH 009/206] 8014426: Original exception no longer thrown away when a finally rethrows Reviewed-by: attila, jlaskey --- .../internal/codegen/CodeGenerator.java | 12 ++++- .../jdk/nashorn/internal/codegen/Lower.java | 4 +- .../jdk/nashorn/internal/ir/CatchNode.java | 30 ++++++++++-- .../jdk/nashorn/internal/ir/ThrowNode.java | 24 +++++++-- .../jdk/nashorn/internal/parser/Parser.java | 4 +- nashorn/test/script/basic/JDK-8014426.js | 49 +++++++++++++++++++ .../test/script/basic/JDK-8014426.js.EXPECTED | 1 + 7 files changed, 111 insertions(+), 13 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8014426.js create mode 100644 nashorn/test/script/basic/JDK-8014426.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index 1fae129468d..617b5ab8474 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -2028,6 +2028,13 @@ final class CodeGenerator extends NodeOperatorVisitor { public boolean enterThrowNode(final ThrowNode throwNode) { lineNumber(throwNode); + if (throwNode.isSyntheticRethrow()) { + //do not wrap whatever this is in an ecma exception, just rethrow it + load(throwNode.getExpression()); + method.athrow(); + return false; + } + method._new(ECMAException.class).dup(); final Source source = getLexicalContext().getCurrentFunction().getSource(); @@ -2096,13 +2103,16 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override protected void evaluate() { + if (catchNode.isSyntheticRethrow()) { + method.load(symbol); + return; + } /* * If caught object is an instance of ECMAException, then * bind obj.thrown to the script catch var. Or else bind the * caught object itself to the script catch var. */ final Label notEcmaException = new Label("no_ecma_exception"); - method.load(symbol).dup()._instanceof(ECMAException.class).ifeq(notEcmaException); method.checkcast(ECMAException.class); //TODO is this necessary? method.getField(ECMAException.THROWN); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java index 23e91b63026..a602ddf512c 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java @@ -288,10 +288,10 @@ final class Lower extends NodeOperatorVisitor { final IdentNode exception = new IdentNode(token, finish, getLexicalContext().getCurrentFunction().uniqueName("catch_all")); - final Block catchBody = new Block(lineNumber, token, finish, new ThrowNode(lineNumber, token, finish, new IdentNode(exception))). + final Block catchBody = new Block(lineNumber, token, finish, new ThrowNode(lineNumber, token, finish, new IdentNode(exception), ThrowNode.IS_SYNTHETIC_RETHROW)). setIsTerminal(getLexicalContext(), true); //ends with throw, so terminal - final CatchNode catchAllNode = new CatchNode(lineNumber, token, finish, new IdentNode(exception), null, catchBody); + final CatchNode catchAllNode = new CatchNode(lineNumber, token, finish, new IdentNode(exception), null, catchBody, CatchNode.IS_SYNTHETIC_RETHROW); final Block catchAllBlock = new Block(lineNumber, token, finish, catchAllNode); //catchallblock -> catchallnode (catchnode) -> exception -> throw diff --git a/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java b/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java index c4551492ed8..67da65f4041 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java @@ -42,6 +42,11 @@ public final class CatchNode extends Statement { /** Catch body. */ private final Block body; + private final int flags; + + /** Is this block a synthethic rethrow created by finally inlining? */ + public static final int IS_SYNTHETIC_RETHROW = 1; + /** * Constructors * @@ -51,19 +56,22 @@ public final class CatchNode extends Statement { * @param exception variable name of exception * @param exceptionCondition exception condition * @param body catch body + * @param flags flags */ - public CatchNode(final int lineNumber, final long token, final int finish, final IdentNode exception, final Node exceptionCondition, final Block body) { + public CatchNode(final int lineNumber, final long token, final int finish, final IdentNode exception, final Node exceptionCondition, final Block body, final int flags) { super(lineNumber, token, finish); this.exception = exception; this.exceptionCondition = exceptionCondition; this.body = body; + this.flags = flags; } - private CatchNode(final CatchNode catchNode, final IdentNode exception, final Node exceptionCondition, final Block body) { + private CatchNode(final CatchNode catchNode, final IdentNode exception, final Node exceptionCondition, final Block body, final int flags) { super(catchNode); this.exception = exception; this.exceptionCondition = exceptionCondition; this.body = body; + this.flags = flags; } /** @@ -124,7 +132,7 @@ public final class CatchNode extends Statement { if (this.exceptionCondition == exceptionCondition) { return this; } - return new CatchNode(this, exception, exceptionCondition, body); + return new CatchNode(this, exception, exceptionCondition, body, flags); } /** @@ -144,13 +152,25 @@ public final class CatchNode extends Statement { if (this.exception == exception) { return this; } - return new CatchNode(this, exception, exceptionCondition, body); + return new CatchNode(this, exception, exceptionCondition, body, flags); } private CatchNode setBody(final Block body) { if (this.body == body) { return this; } - return new CatchNode(this, exception, exceptionCondition, body); + return new CatchNode(this, exception, exceptionCondition, body, flags); } + + /** + * Is this catch block a non-JavaScript constructor, for example created as + * part of the rethrow mechanism of a finally block in Lower? Then we just + * pass the exception on and need not unwrap whatever is in the ECMAException + * object catch symbol + * @return true if a finally synthetic rethrow + */ + public boolean isSyntheticRethrow() { + return (flags & IS_SYNTHETIC_RETHROW) == IS_SYNTHETIC_RETHROW; + } + } diff --git a/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java b/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java index e37302e6902..70d385733be 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java @@ -36,6 +36,11 @@ public final class ThrowNode extends Statement { /** Exception expression. */ private final Node expression; + private final int flags; + + /** Is this block a synthethic rethrow created by finally inlining? */ + public static final int IS_SYNTHETIC_RETHROW = 1; + /** * Constructor * @@ -43,15 +48,18 @@ public final class ThrowNode extends Statement { * @param token token * @param finish finish * @param expression expression to throw + * @param flags flags */ - public ThrowNode(final int lineNumber, final long token, final int finish, final Node expression) { + public ThrowNode(final int lineNumber, final long token, final int finish, final Node expression, final int flags) { super(lineNumber, token, finish); this.expression = expression; + this.flags = flags; } - private ThrowNode(final ThrowNode node, final Node expression) { + private ThrowNode(final ThrowNode node, final Node expression, final int flags) { super(node); this.expression = expression; + this.flags = flags; } @Override @@ -98,7 +106,17 @@ public final class ThrowNode extends Statement { if (this.expression == expression) { return this; } - return new ThrowNode(this, expression); + return new ThrowNode(this, expression, flags); + } + + /** + * Is this a throw a synthetic rethrow in a synthetic catch-all block + * created when inlining finally statements? In that case we never + * wrap whatever is thrown into an ECMAException, just rethrow it. + * @return true if synthetic throw node + */ + public boolean isSyntheticRethrow() { + return (flags & IS_SYNTHETIC_RETHROW) == IS_SYNTHETIC_RETHROW; } } diff --git a/nashorn/src/jdk/nashorn/internal/parser/Parser.java b/nashorn/src/jdk/nashorn/internal/parser/Parser.java index efb7a391586..03f65b86e11 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/Parser.java +++ b/nashorn/src/jdk/nashorn/internal/parser/Parser.java @@ -1537,7 +1537,7 @@ loop: endOfLine(); - appendStatement(new ThrowNode(throwLine, throwToken, finish, expression)); + appendStatement(new ThrowNode(throwLine, throwToken, finish, expression, 0)); } /** @@ -1597,7 +1597,7 @@ loop: try { // Get CATCH body. final Block catchBody = getBlock(true); - final CatchNode catchNode = new CatchNode(catchLine, catchToken, finish, exception, ifExpression, catchBody); + final CatchNode catchNode = new CatchNode(catchLine, catchToken, finish, exception, ifExpression, catchBody, 0); appendStatement(catchNode); } finally { catchBlock = restoreBlock(catchBlock); diff --git a/nashorn/test/script/basic/JDK-8014426.js b/nashorn/test/script/basic/JDK-8014426.js new file mode 100644 index 00000000000..220aa7f3683 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8014426.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * Ensure catchall exceptions from finally inlining are rethrown as is + * + * @test + * @run + */ + +function runScriptEngine() { + var fac = new Packages.jdk.nashorn.api.scripting.NashornScriptEngineFactory(); + var engine = fac.getScriptEngine(); + engine.eval( +"try {\n\ + doIt();\n\ +} finally { \n\ + var x = 17;\n\ +}\n\ +function doIt() {\n\ + throw new TypeError('en stor graa noshoerning!');\n\ +}\n"); +} + +try { + runScriptEngine(); +} catch(e) { + print(e); +} diff --git a/nashorn/test/script/basic/JDK-8014426.js.EXPECTED b/nashorn/test/script/basic/JDK-8014426.js.EXPECTED new file mode 100644 index 00000000000..8a8b2a06ae3 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8014426.js.EXPECTED @@ -0,0 +1 @@ +javax.script.ScriptException: TypeError: en stor graa noshoerning! in at line number 7 at column number 2 From 3710d6fcf605500bc62ef1ec1de87b8b3647542a Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Wed, 15 May 2013 10:28:18 +0200 Subject: [PATCH 010/206] 8014639: Remove debug flag from test runs Reviewed-by: hannesw, lagergren --- nashorn/make/project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties index 2d66dfef6fb..9ed8125e14a 100644 --- a/nashorn/make/project.properties +++ b/nashorn/make/project.properties @@ -216,7 +216,7 @@ run.test.xms=2G # -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMethods # add '-Dtest.js.outofprocess' to run each test in a new sub-process -run.test.jvmargs.main=-server -Xmx${run.test.xmx} -XX:+TieredCompilation -ea -Dnashorn.debug=true -Dfile.encoding=UTF-8 +run.test.jvmargs.main=-server -Xmx${run.test.xmx} -XX:+TieredCompilation -ea -Dfile.encoding=UTF-8 #-XX:+HeapDumpOnOutOfMemoryError -XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M run.test.jvmargs.octane.main=-Xms${run.test.xms} ${run.test.jvmargs.main} From a3e2765ce8d04539669fab63099bc821fd36c6cb Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Wed, 15 May 2013 14:54:28 +0200 Subject: [PATCH 011/206] 8014646: Update the Java interop documentation in the Java Scripting Programmer's Guide Reviewed-by: jlaskey, hannesw, lagergren --- .../docs/JavaScriptingProgrammersGuide.html | 234 ++++++++++++++++-- 1 file changed, 216 insertions(+), 18 deletions(-) diff --git a/nashorn/docs/JavaScriptingProgrammersGuide.html b/nashorn/docs/JavaScriptingProgrammersGuide.html index 811b29c9d51..a9af9612271 100644 --- a/nashorn/docs/JavaScriptingProgrammersGuide.html +++ b/nashorn/docs/JavaScriptingProgrammersGuide.html @@ -71,9 +71,20 @@ Classes Arrays
  • Implementing Java Interfaces
  • -
  • Extending Java classes +
  • Extending Abstract Java Classes +
  • +
  • Extending Concrete Java Classes +
  • +
  • Implementing Multiple Java Interfaces +
  • +
  • Class-Bound Implementations
  • Overload Resolution
  • +
  • Mapping of Data Types Between Java +and JavaScript
  • + + +
  • Implementing Your Own Script @@ -466,10 +477,10 @@ language rather than JavaScript.

    -Note that the name of the type is always a string for a fully qualified name. You can use any of these types to create new instances, e.g.: +Note that the name of the type is always a string for a fully qualified name. You can use any of these expressions to create new instances, e.g.:
    
    - var anArrayList = new Java.type("java.util.ArrayList")
    + var anArrayList = new (Java.type("java.util.ArrayList"))
     
    or @@ -496,6 +507,37 @@ However, once you retrieved the outer class, you can access the inner class as a

    You can access both static and non-static inner classes. If you want to create an instance of a non-static inner class, remember to pass an instance of its outer class as the first argument to the constructor.

    +

    +In addition to creating new instances, the type objects returned from Java.type calls can also be used to access the +static fields and methods of the classes: +

    
    + var File = Java.type("java.io.File")
    + File.createTempFile("nashorn", ".tmp")
    +
    +

    +Methods with names of the form isXxx(), getXxx(), and setXxx() can also be used as properties, for both instances and statics. +

    +

    +A type object returned from Java.type is distinct from a java.lang.Class object. You can obtain one from the other using properties class and static on them. +

    
    + var ArrayList = Java.type("java.util.ArrayList")
    + var a = new ArrayList
    +
    + // All of the following print true:
    + print("Type acts as target of instanceof: " + (a instanceof ArrayList))
    + print("Class doesn't act as target of instanceof: " + !(a instanceof a.getClass()))
    + print("Type is not same as instance's getClass(): " + (a.getClass() !== ArrayList))
    + print("Type's `class` property is same as instance getClass(): " + (a.getClass() === ArrayList.class))
    + print("Type is same as instance getClass()'s `static` property: " + (a.getClass().static === ArrayList))
    +
    +

    +You can think of the type object as similar to the class names as used in Java source code: you use them as the +arguments to the new and instanceof operators and as the namespace for the static fields +and methods, but they are different than the runtime Class objects returned by getClass() calls. +Syntactically and semantically, this separation produces code that is most similar to Java code, where a distinction +between compile-time class expressions and runtime class objects also exists. (Also, Java can't have the equivalent of static +property on a Class object since compile-time class expressions are never reified as objects). +


    Importing Java Packages, Classes

    @@ -558,10 +600,7 @@ with (SwingGui) {

    Creating, Converting and Using Java Arrays

    -Array element access or length access is -the same as in Java. Also, a script array can be used when a Java -method expects a Java array (auto conversion). So in most cases we -don't have to create Java arrays explicitly.

    +Array element access or length access is the same as in Java.

    
     // javaarray.js
     
    @@ -587,7 +626,11 @@ Given a JavaScript array and a Java type, Java.toJavaArray returns
      print(javaIntArray[2]) // prints 0, as boolean false was converted to number 0 as per ECMAScript ToNumber conversion
     

    -Given a Java array or Collection, Java.toJavaScriptArray returns a JavaScript array with a shallow copy of its contents. Note that in most cases, you can use Java arrays and lists natively in Nashorn; in cases where for some reason you need to have an actual JavaScript native array (e.g. to work with the array comprehensions functions), you will want to use this method.i +You can use either a string or a type object returned from Java.type() to specify the component type of the array. +You can also omit the array type, in which case a Object[] will be created. +

    +

    +Given a Java array or Collection, Java.toJavaScriptArray returns a JavaScript array with a shallow copy of its contents. Note that in most cases, you can use Java arrays and lists natively in Nashorn; in cases where for some reason you need to have an actual JavaScript native array (e.g. to work with the array comprehensions functions), you will want to use this method.

    
     var File = Java.type("java.io.File");
    @@ -597,7 +640,7 @@ print(jsList);
     

    -

    Implementing Java Interfaces

    +

    Implementing Java interfaces

    A Java interface can be implemented in JavaScript by using a Java anonymous class-like syntax:

    
    @@ -631,8 +674,8 @@ th.join();
     
     

    - -

    Extending Java classes

    + +

    Extending Abstract Java Classes

    If a Java class is abstract, you can instantiate an anonymous subclass of it using an argument list that is applicable to any of its public or protected constructors, but inserting a JavaScript object with functions properties that provide JavaScript implementations of the abstract methods. If method names are overloaded, the JavaScript function will provide implementation for all overloads. E.g.:

    @@ -671,6 +714,9 @@ The use of functions can be taken even further; if you are invoking a Java metho Here, Timer.schedule() expects a TimerTask as its argument, so Nashorn creates an instance of a TimerTask subclass and uses the passed function to implement its only abstract method, run(). In this usage though, you can't use non-default constructors; the type must be either an interface, or must have a protected or public no-arg constructor. +
    + +

    Extending Concrete Java Classes

    To extend a concrete Java class, you have to use Java.extend function. Java.extend returns a type object for a subclass of the specified Java class (or implementation of the specified interface) that acts as a script-to-Java adapter for it. @@ -695,26 +741,178 @@ var printAddInvokedArrayList = new ArrayListExtender() { printSizeInvokedArrayList.size(); printAddInvokedArrayList.add(33, 33); +

    +The reason you must use Java.extend() with concrete classes is that with concrete classes, there can be a +syntactic ambiguity if you just invoke their constructor. Consider this example: +

    +
    
    +var t = new java.lang.Thread({ run: function() { print("Hello!") } })
    +
    +

    +If we allowed subclassing of concrete classes with constructor syntax, Nashorn couldn't tell if you're creating a new +Thread and passing it a Runnable at this point, or you are subclassing Thread and +passing it a new implementation for its own run() method. +

    +
    + +

    Implementing Multiple Interfaces

    +

    +Java.extend can in fact take a list of multiple types. At most one of the types can be a class, and the rest must +be interfaces (the class doesn't have to be the first in the list). You will get back an object that extends the class and +implements all the interfaces. (Obviously, if you only specify interfaces and no class, the object will extend java.lang.Object). +


    + +

    Class-Bound Implementations

    +

    +The methods shown so far for extending Java classes and implementing interfaces – passing an implementation JavaScript object +or function to a constructor, or using Java.extend with new – all produce classes that take an +extra JavaScript object parameter in their constructors that specifies the implementation. The implementation is therefore always bound +to the actual instance being created with new, and not to the whole class. This has some advantages, for example in the +memory footprint of the runtime, as Nashorn can just create a single "universal adapter" for every combination of types being implemented. +In reality, the below code shows that different instantiations of, say, Runnable have the same class regardless of them having +different JavaScript implementation objects: +

    +
    
    +var Runnable = java.lang.Runnable;
    +var r1 = new Runnable(function() { print("I'm runnable 1!") })
    +var r2 = new Runnable(function() { print("I'm runnable 2!") })
    +r1.run()
    +r2.run()
    +print("We share the same class: " + (r1.class === r2.class))
    +
    +

    +prints: +

    +
    
    +I'm runnable 1!
    +I'm runnable 2!
    +We share the same class: true
    +
    +

    +Sometimes, however, you'll want to extend a Java class or implement an interface with implementation bound to the class, not to +its instances. Such a need arises, for example, when you need to pass the class for instantiation to an external API; prime example +of this is the JavaFX framework where you need to pass an Application class to the FX API and let it instantiate it. +

    +

    +Fortunately, there's a solution for that: Java.extend() – aside from being able to take any number of type parameters +denoting a class to extend and interfaces to implement – can also take one last argument that has to be a JavaScript object +that serves as the implementation for the methods. In this case, Java.extend() will create a class that has the same +constructors as the original class had, as they don't need to take an an extra implementation object parameter. The example below +shows how you can create class-bound implementations, and shows that in this case, the implementation classes for different invocations +are indeed different: +

    +
    
    +var RunnableImpl1 = Java.extend(java.lang.Runnable, function() { print("I'm runnable 1!") })
    +var RunnableImpl2 = Java.extend(java.lang.Runnable, function() { print("I'm runnable 2!") })
    +var r1 = new RunnableImpl1()
    +var r2 = new RunnableImpl2()
    +r1.run()
    +r2.run()
    +print("We share the same class: " + (r1.class === r2.class))
    +
    +

    +prints: +

    +
    
    +I'm runnable 1!
    +I'm runnable 2!
    +We share the same class: false
    +
    +

    +As you can see, the major difference here is that we moved the implementation object into the invocation of Java.extend +from the constructor invocations – indeed the constructor invocations now don't even need to take an extra parameter! Since +the implementations are bound to a class, the two classes obviously can't be the same, and we indeed see that the two runnables no +longer share the same class – every invocation of Java.extend() with a class-specific implementation object triggers +the creation of a new Java adapter class. +

    +

    +Finally, the adapter classes with class-bound implementations can still take an additional constructor parameter to further +override the behavior on a per-instance basis. Thus, you can even combine the two approaches: you can provide part of the implementation +in a class-based JavaScript implementation object passed to Java.extend, and part in another object passed to the constructor. +Whatever functions are provided by the constructor-passed object will override the functions in the class-bound object. +

    +
    
    +var RunnableImpl = Java.extend(java.lang.Runnable, function() { print("I'm runnable 1!") })
    +var r1 = new RunnableImpl()
    +var r2 = new RunnableImpl(function() { print("I'm runnable 2!") })
    +r1.run()
    +r2.run()
    +print("We share the same class: " + (r1.class === r2.class))
    +
    +

    +prints: +

    +
    
    +I'm runnable 1!
    +I'm runnable 2!
    +We share the same class: true
    +

    Overload Resolution

    Java methods can be overloaded by argument types. In Java, overload resolution occurs at compile time (performed by javac). -When calling Java methods from a script, the script -interpreter/compiler needs to select the appropriate method. With -the JavaScript engine, you do not need to do anything special - the -correct Java method overload variant is selected based on the -argument types. But, sometimes you may want (or have) to explicitly -select a particular overload variant.

    +When calling Java methods from Nashorn, the appropriate method will be +selected based on the argument types at invocation time. You do not need +to do anything special – the correct Java method overload variant +is selected based automatically. You still have the option of explicitly +specifying a particular overload variant. Reasons for this include +either running into a genuine ambiguity with actual argument types, or +rarely reasons of performance – if you specify the actual overload +then the engine doesn't have to perform resolution during invocation. +Individual overloads of a Java methods are exposed as special properties +with the name of the method followed with its signature in parentheses. +You can invoke them like this:

    
     // overload.js
     
     var out = java.lang.System.out;
     
     // select a particular print function 
    -out["println(java.lang.Object)"]("hello");
    +out["println(Object)"]("hello");
     
     
    +

    +Note that you normally don't even have to use qualified class names in +the signatures as long as the unqualified name of the type is sufficient +for uniquely identifying the signature. In practice this means that only +in the extremely unlikely case that two overloads only differ in +parameter types that have identical unqualified names but come from +different packages would you need to use the fully qualified name of the +class. +

    +
    + +

    Mapping of Data Types Between Java and JavaScript

    +

    +We have previously shown some of the data type mappings between Java and JavaScript. +We saw that arrays need to be explicitly converted. We have also shown that JavaScript functions +are automatically converted to SAM types when passed as parameters to Java methods. Most other +conversions work as you would expect. +

    +

    +Every JavaScript object is also a java.util.Map so APIs receiving maps will receive them directly. +

    +

    +When numbers are passed to a Java API, they will be converted to the expected target numeric type, either boxed or +primitive, but if the target type is less specific, say Number or Object, you can only +count on them being a Number, and have to test specifically for whether it's a boxed Double, +Integer, Long, etc. – it can be any of these due to internal optimizations. Also, you +can pass any JavaScript value to a Java API expecting either a boxed or primitive number; the JavaScript specification's +ToNumber conversion algorithm will be applied to the value. +

    +

    +In a similar vein, if a Java method expects a String or a Boolean, the values will be +converted using all conversions allowed by the JavaScript specification's ToString and ToBoolean +conversions. +

    +

    +Finally, a word of caution about strings. Due to internal performance optimizations of string operations, JavaScript strings are +not always necessarily of type java.lang.String, but they will always be of type java.lang.CharSequence. +If you pass them to a Java method that expects a java.lang.String parameter, then you will naturally receive a Java +String, but if the signature of your method is more generic, i.e. it receives a java.lang.Object parameter, you can +end up with an object of private engine implementation class that implements CharSequence but is not a Java String. +


    Implementing Your Own Script Engine

    From 8bbf3e9b524c0bd260da5294218e7623f24229e7 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 15 May 2013 19:45:16 +0530 Subject: [PATCH 012/206] 8012305: Function.bind can't be called on prototype function inside constructor Reviewed-by: lagergren, attila --- nashorn/test/script/basic/JDK-8012305.js | 39 +++++++++++++++++++ .../test/script/basic/JDK-8012305.js.EXPECTED | 1 + 2 files changed, 40 insertions(+) create mode 100644 nashorn/test/script/basic/JDK-8012305.js create mode 100644 nashorn/test/script/basic/JDK-8012305.js.EXPECTED diff --git a/nashorn/test/script/basic/JDK-8012305.js b/nashorn/test/script/basic/JDK-8012305.js new file mode 100644 index 00000000000..d08502defb1 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8012305.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8012305: Function.bind can't be called on prototype function inside constructor + * + * @test + * @run + */ + +function MyObject() { + // If the call to bind is removed, then the function is properly printed. + print("function " + this._process); + this._process = this._process.bind(this); +} + +MyObject.prototype._process = function() { print("Message "); } + +var s = new MyObject(); diff --git a/nashorn/test/script/basic/JDK-8012305.js.EXPECTED b/nashorn/test/script/basic/JDK-8012305.js.EXPECTED new file mode 100644 index 00000000000..b509e0c1051 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8012305.js.EXPECTED @@ -0,0 +1 @@ +function function() { print("Message "); } From e5be7a02eaf8f90d5c7f84338af5854c2e164e7f Mon Sep 17 00:00:00 2001 From: James Laskey Date: Wed, 15 May 2013 12:09:38 -0300 Subject: [PATCH 013/206] 8014648: Exclude testing and infrastructure packages from code coverage, round two Reviewed-by: sundar --- nashorn/make/code_coverage.xml | 12 ++++ .../internal/runtime/options/Option.java | 4 -- .../internal/runtime/options/Options.java | 2 - .../internal/runtime/options/ValueOption.java | 59 ------------------- nashorn/test/script/basic/allgettersetters.js | 3 + 5 files changed, 15 insertions(+), 65 deletions(-) delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/options/ValueOption.java diff --git a/nashorn/make/code_coverage.xml b/nashorn/make/code_coverage.xml index 457f6308154..3e2860f8d9d 100644 --- a/nashorn/make/code_coverage.xml +++ b/nashorn/make/code_coverage.xml @@ -153,6 +153,18 @@ + + + + + + + + + + + + diff --git a/nashorn/src/jdk/nashorn/internal/runtime/options/Option.java b/nashorn/src/jdk/nashorn/internal/runtime/options/Option.java index ddbeba184d4..feaff1f1805 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/options/Option.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/options/Option.java @@ -42,10 +42,6 @@ public class Option { this.value = value; } - void setValue(final T value) { - this.value = value; - } - /** * Return the value of an option * @return the option value diff --git a/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java b/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java index 286feec907b..52864a6652a 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java @@ -501,8 +501,6 @@ public final class Options { return new Option<>(TimeZone.getTimeZone(value)); case "keyvalues": return new KeyValueOption(value); - case "values": - return new ValueOption(value); case "log": final KeyValueOption kv = new KeyValueOption(value); Logging.initialize(kv.getValues()); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/options/ValueOption.java b/nashorn/src/jdk/nashorn/internal/runtime/options/ValueOption.java deleted file mode 100644 index 2f4461f44ca..00000000000 --- a/nashorn/src/jdk/nashorn/internal/runtime/options/ValueOption.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2010, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.nashorn.internal.runtime.options; - -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.StringTokenizer; - -/** - * This option represents a collection of comma separated values - */ -public class ValueOption extends Option { - - private Collection values; - - ValueOption(final String value) { - super(value); - if (value != null) { - values = new LinkedHashSet<>(); - final StringTokenizer st = new StringTokenizer(getValue(), ","); - while (st.hasMoreElements()) { - values.add(st.nextToken()); - } - } - } - - /** - * Get the values in the option - * @return collection of strings - */ - public Collection getValues() { - return Collections.unmodifiableCollection(values); - } - -} diff --git a/nashorn/test/script/basic/allgettersetters.js b/nashorn/test/script/basic/allgettersetters.js index 0f6753c23a4..1cb956239e5 100644 --- a/nashorn/test/script/basic/allgettersetters.js +++ b/nashorn/test/script/basic/allgettersetters.js @@ -34,6 +34,9 @@ function checkGetterSetter(obj, expectError) { for (var i in properties) { var prop = properties[i]; try { + if (!/\d.*/.test(prop)) { + eval("obj." + prop + " = " + "obj." + prop + ";"); + } obj[prop] = obj[prop]; } catch (e) { if (!expectError || !(e instanceof TypeError)) { From 18bdc5fd42353d59f803b64377033e4d76af90af Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Wed, 15 May 2013 20:21:59 +0200 Subject: [PATCH 014/206] 8014647: Allow class-based overrides to be initialized with a ScriptFunction Reviewed-by: hannesw, jlaskey, sundar --- .../linker/JavaAdapterBytecodeGenerator.java | 32 ++++++++++++++- nashorn/test/script/basic/JDK-8014647.js | 40 +++++++++++++++++++ .../test/script/basic/JDK-8014647.js.EXPECTED | 5 +++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 nashorn/test/script/basic/JDK-8014647.js create mode 100644 nashorn/test/script/basic/JDK-8014647.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java index 37786b1e685..1fe76954391 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java @@ -310,7 +310,34 @@ final class JavaAdapterBytecodeGenerator extends JavaAdapterGeneratorBase { Type.getMethodDescriptor(Type.VOID_TYPE), null, null)); mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getClassOverrides", GET_CLASS_INITIALIZER_DESCRIPTOR); - // Assign MethodHandle fields through invoking getHandle() + final Label initGlobal; + if(samName != null) { + // If the class is a SAM, allow having a ScriptFunction passed as class overrides + final Label notAFunction = new Label(); + mv.dup(); + mv.instanceOf(SCRIPT_FUNCTION_TYPE); + mv.ifeq(notAFunction); + mv.checkcast(SCRIPT_FUNCTION_TYPE); + + // Assign MethodHandle fields through invoking getHandle() for a ScriptFunction, only assigning the SAM + // method(s). + for (final MethodInfo mi : methodInfos) { + if(mi.getName().equals(samName)) { + mv.dup(); + mv.aconst(Type.getMethodType(mi.type.toMethodDescriptorString())); + mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getHandle", GET_HANDLE_FUNCTION_DESCRIPTOR); + } else { + mv.visitInsn(ACONST_NULL); + } + mv.putstatic(generatedClassName, mi.methodHandleClassFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); + } + initGlobal = new Label(); + mv.goTo(initGlobal); + mv.visitLabel(notAFunction); + } else { + initGlobal = null; + } + // Assign MethodHandle fields through invoking getHandle() for a ScriptObject for (final MethodInfo mi : methodInfos) { mv.dup(); mv.aconst(mi.getName()); @@ -319,6 +346,9 @@ final class JavaAdapterBytecodeGenerator extends JavaAdapterGeneratorBase { mv.putstatic(generatedClassName, mi.methodHandleClassFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); } + if(initGlobal != null) { + mv.visitLabel(initGlobal); + } // Assign "staticGlobal = Context.getGlobal()" invokeGetGlobalWithNullCheck(mv); mv.putstatic(generatedClassName, STATIC_GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); diff --git a/nashorn/test/script/basic/JDK-8014647.js b/nashorn/test/script/basic/JDK-8014647.js new file mode 100644 index 00000000000..8ecc21101d5 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8014647.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8014647: Allow class-based overrides to be initialized with a ScriptFunction + * + * @test + * @run + */ + +var RunnableImpl1 = Java.extend(java.lang.Runnable, function() { print("I'm runnable 1!") }) +var RunnableImpl2 = Java.extend(java.lang.Runnable, function() { print("I'm runnable 2!") }) +var r1 = new RunnableImpl1() +var r2 = new RunnableImpl2() +var r3 = new RunnableImpl2(function() { print("I'm runnable 3!") }) +r1.run() +r2.run() +r3.run() +print("r1.class === r2.class: " + (r1.class === r2.class)) +print("r2.class === r3.class: " + (r2.class === r3.class)) diff --git a/nashorn/test/script/basic/JDK-8014647.js.EXPECTED b/nashorn/test/script/basic/JDK-8014647.js.EXPECTED new file mode 100644 index 00000000000..641a13b1d45 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8014647.js.EXPECTED @@ -0,0 +1,5 @@ +I'm runnable 1! +I'm runnable 2! +I'm runnable 3! +r1.class === r2.class: false +r2.class === r3.class: true From 6e9157648062e24fa6a84bb0d06f32e5674c88bd Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Thu, 16 May 2013 14:52:48 +0530 Subject: [PATCH 015/206] 8009141: Avoid netscape.javascript.JSObject in nashorn code Reviewed-by: lagergren, hannesw --- .../nashorn/api/scripting}/JSObject.java | 18 ++---------------- .../api/scripting/ScriptObjectMirror.java | 1 - .../runtime/linker/JSObjectLinker.java | 2 +- .../api/scripting/ScriptEngineTest.java | 1 - 4 files changed, 3 insertions(+), 19 deletions(-) rename nashorn/src/{netscape/javascript => jdk/nashorn/api/scripting}/JSObject.java (87%) diff --git a/nashorn/src/netscape/javascript/JSObject.java b/nashorn/src/jdk/nashorn/api/scripting/JSObject.java similarity index 87% rename from nashorn/src/netscape/javascript/JSObject.java rename to nashorn/src/jdk/nashorn/api/scripting/JSObject.java index 23054c6321d..583e8f7a199 100644 --- a/nashorn/src/netscape/javascript/JSObject.java +++ b/nashorn/src/jdk/nashorn/api/scripting/JSObject.java @@ -23,26 +23,12 @@ * questions. */ -package netscape.javascript; - -import java.applet.Applet; +package jdk.nashorn.api.scripting; /** - * Stub for JSObject to get compilation going. + * netscape.javascript.JSObject-like interface for nashorn script objects. */ public abstract class JSObject { - - /** - * Get the window for an {@link Applet}. Not supported - * by Nashorn - * - * @param a applet - * @return the window instance - */ - public static JSObject getWindow(final Applet a) { - throw new UnsupportedOperationException("getWindow"); - } - /** * Call a JavaScript method * diff --git a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java index 266ce87f48d..e53903d3c3f 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java +++ b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java @@ -42,7 +42,6 @@ import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptRuntime; -import netscape.javascript.JSObject; /** * Mirror object that wraps a given ScriptObject instance. User can diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java index df9c47ff623..edd75e4dafd 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java @@ -38,7 +38,7 @@ import jdk.internal.dynalink.linker.LinkerServices; import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker; import jdk.internal.dynalink.support.CallSiteDescriptorFactory; import jdk.nashorn.internal.runtime.JSType; -import netscape.javascript.JSObject; +import jdk.nashorn.api.scripting.JSObject; /** * A Dynalink linker to handle web browser built-in JS (DOM etc.) objects as well diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java index d12c9057246..a6c015a1e54 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java @@ -47,7 +47,6 @@ import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineManager; import javax.script.ScriptException; import javax.script.SimpleScriptContext; -import netscape.javascript.JSObject; import org.testng.Assert; import org.testng.annotations.Test; From aeda283b752d5e8b74cf849bdaf151540ce503a0 Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Thu, 16 May 2013 13:44:25 +0200 Subject: [PATCH 016/206] 8013919: Original exception no longer thrown away when a finally rethrows Reviewed-by: jlaskey, sundar --- .../jdk/nashorn/internal/codegen/Lower.java | 32 ++++++++------- .../jdk/nashorn/internal/ir/FunctionNode.java | 38 ++++++++++++------ nashorn/test/script/basic/JDK-8013919.js | 39 +++++++++++++++++++ .../test/script/basic/JDK-8013919.js.EXPECTED | 2 + 4 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8013919.js create mode 100644 nashorn/test/script/basic/JDK-8013919.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java index a602ddf512c..a7089674d82 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java @@ -261,19 +261,25 @@ final class Lower extends NodeOperatorVisitor { return throwNode; } - private static Node ensureUniqueLabelsIn(final Node node) { + private static Node ensureUniqueNamesIn(final LexicalContext lc, final Node node) { return node.accept(new NodeVisitor() { - @Override - public Node leaveDefault(final Node labelledNode) { - return labelledNode.ensureUniqueLabels(getLexicalContext()); - } + @Override + public Node leaveFunctionNode(final FunctionNode functionNode) { + final String name = functionNode.getName(); + return functionNode.setName(getLexicalContext(), lc.getCurrentFunction().uniqueName(name)); + } + + @Override + public Node leaveDefault(final Node labelledNode) { + return labelledNode.ensureUniqueLabels(getLexicalContext()); + } }); } - private static List copyFinally(final Block finallyBody) { + private static List copyFinally(final LexicalContext lc, final Block finallyBody) { final List newStatements = new ArrayList<>(); for (final Statement statement : finallyBody.getStatements()) { - newStatements.add((Statement)ensureUniqueLabelsIn(statement)); + newStatements.add((Statement)ensureUniqueNamesIn(lc, statement)); if (statement.hasTerminalFlags()) { return newStatements; } @@ -316,9 +322,9 @@ final class Lower extends NodeOperatorVisitor { * @return new try node after splicing finally code (same if nop) */ private Node spliceFinally(final TryNode tryNode, final List rethrows, final Block finallyBody) { - final int finish = tryNode.getFinish(); - assert tryNode.getFinallyBody() == null; + final int finish = tryNode.getFinish(); + final LexicalContext lc = getLexicalContext(); final TryNode newTryNode = (TryNode)tryNode.accept(new NodeVisitor() { final List insideTry = new ArrayList<>(); @@ -338,7 +344,7 @@ final class Lower extends NodeOperatorVisitor { @Override public Node leaveThrowNode(final ThrowNode throwNode) { if (rethrows.contains(throwNode)) { - final List newStatements = copyFinally(finallyBody); + final List newStatements = copyFinally(lc, finallyBody); if (!isTerminal(newStatements)) { newStatements.add(throwNode); } @@ -372,7 +378,7 @@ final class Lower extends NodeOperatorVisitor { resultNode = null; } - newStatements.addAll(copyFinally(finallyBody)); + newStatements.addAll(copyFinally(lc, finallyBody)); if (!isTerminal(newStatements)) { newStatements.add(expr == null ? returnNode : returnNode.setExpression(resultNode)); } @@ -382,7 +388,7 @@ final class Lower extends NodeOperatorVisitor { private Node copy(final Statement endpoint, final Node targetNode) { if (!insideTry.contains(targetNode)) { - final List newStatements = copyFinally(finallyBody); + final List newStatements = copyFinally(lc, finallyBody); if (!isTerminal(newStatements)) { newStatements.add(endpoint); } @@ -548,7 +554,7 @@ final class Lower extends NodeOperatorVisitor { final FunctionNode currentFunction = getLexicalContext().getCurrentFunction(); return callNode.setEvalArgs( new CallNode.EvalArgs( - ensureUniqueLabelsIn(args.get(0)).accept(this), + ensureUniqueNamesIn(getLexicalContext(), args.get(0)).accept(this), compilerConstant(THIS), evalLocation(callee), currentFunction.isStrict())); diff --git a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java index 2b6d19bf501..715d4507ac3 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java @@ -250,6 +250,7 @@ public final class FunctionNode extends LexicalContextNode implements Flags compilationState, @@ -260,6 +261,7 @@ public final class FunctionNode extends LexicalContextNode implements Flags newState = EnumSet.copyOf(this.compilationState); newState.add(state); - return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, returnType, compileUnit, newState, body, parameters, snapshot, hints)); + return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, name, returnType, compileUnit, newState, body, parameters, snapshot, hints)); } /** @@ -410,7 +411,7 @@ public final class FunctionNode extends LexicalContextNode implements Flags Date: Thu, 16 May 2013 19:52:39 +0200 Subject: [PATCH 017/206] 8012359: Increase code coverage in Joni Reviewed-by: jlaskey, lagergren --- nashorn/make/build.xml | 2 + .../{DefaultRegExp.java => JdkRegExp.java} | 4 +- .../internal/runtime/regexp/JoniRegExp.java | 2 +- .../runtime/regexp/RegExpFactory.java | 6 +- .../runtime/regexp/joni/Analyser.java | 837 +----------------- .../runtime/regexp/joni/ArrayCompiler.java | 410 ++------- .../runtime/regexp/joni/AsmCompiler.java | 109 --- .../regexp/joni/AsmCompilerSupport.java | 267 ------ .../internal/runtime/regexp/joni/BitSet.java | 8 - .../runtime/regexp/joni/BitStatus.java | 7 +- .../runtime/regexp/joni/ByteCodeMachine.java | 263 ------ .../runtime/regexp/joni/ByteCodePrinter.java | 237 ++++- .../runtime/regexp/joni/CaptureTreeNode.java | 74 -- .../runtime/regexp/joni/Compiler.java | 28 +- .../internal/runtime/regexp/joni/Config.java | 17 +- .../runtime/regexp/joni/EncodingHelper.java | 14 - .../internal/runtime/regexp/joni/Lexer.java | 376 +------- .../internal/runtime/regexp/joni/Matcher.java | 18 - .../runtime/regexp/joni/NameEntry.java | 97 -- .../runtime/regexp/joni/NativeMachine.java | 27 - .../internal/runtime/regexp/joni/Parser.java | 195 +--- .../internal/runtime/regexp/joni/Regex.java | 139 +-- .../internal/runtime/regexp/joni/Region.java | 19 - .../runtime/regexp/joni/ScanEnvironment.java | 10 - .../runtime/regexp/joni/ScannerSupport.java | 4 +- .../runtime/regexp/joni/StackMachine.java | 104 --- .../internal/runtime/regexp/joni/Syntax.java | 2 +- .../runtime/regexp/joni/UnsetAddrList.java | 69 -- .../runtime/regexp/joni/ast/CClassNode.java | 40 +- .../runtime/regexp/joni/ast/CTypeNode.java | 50 -- .../runtime/regexp/joni/ast/CallNode.java | 86 -- .../runtime/regexp/joni/ast/EncloseNode.java | 38 +- .../regexp/joni/ast/QuantifierNode.java | 44 +- .../runtime/regexp/joni/ast/StateNode.java | 65 -- .../regexp/joni/bench/AbstractBench.java | 49 - .../joni/bench/BenchGreedyBacktrack.java | 7 - .../regexp/joni/bench/BenchRailsRegs.java | 31 - .../joni/bench/BenchSeveralRegexps.java | 17 - .../runtime/regexp/joni/constants/OPCode.java | 235 ----- .../runtime/regexp/joni/constants/Reduce.java | 61 -- .../regexp/joni/encoding/AsciiTables.java | 157 ---- .../runtime/regexp/joni/encoding/ObjPtr.java | 1 - .../regexp/joni/encoding/PosixBracket.java | 77 -- .../runtime/regexp/joni/encoding/Ptr.java | 35 - .../regexp/joni/exception/ErrorMessages.java | 29 +- .../regexp/joni/exception/ValueException.java | 4 - .../runtime/regexp/JdkRegExpTest.java | 61 ++ .../runtime/regexp/joni/JoniTest.java | 52 ++ 48 files changed, 531 insertions(+), 3953 deletions(-) rename nashorn/src/jdk/nashorn/internal/runtime/regexp/{DefaultRegExp.java => JdkRegExp.java} (97%) delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/AsmCompiler.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/AsmCompilerSupport.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/CaptureTreeNode.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/NameEntry.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/NativeMachine.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/UnsetAddrList.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/CTypeNode.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/CallNode.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/bench/AbstractBench.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/bench/BenchGreedyBacktrack.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/bench/BenchRailsRegs.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/bench/BenchSeveralRegexps.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/constants/Reduce.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/AsciiTables.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/PosixBracket.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/Ptr.java create mode 100644 nashorn/test/src/jdk/nashorn/internal/runtime/regexp/JdkRegExpTest.java create mode 100644 nashorn/test/src/jdk/nashorn/internal/runtime/regexp/joni/JoniTest.java diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index d884b2fe009..c647ba4b922 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -305,6 +305,8 @@ + + diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/DefaultRegExp.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/JdkRegExp.java similarity index 97% rename from nashorn/src/jdk/nashorn/internal/runtime/regexp/DefaultRegExp.java rename to nashorn/src/jdk/nashorn/internal/runtime/regexp/JdkRegExp.java index e3157ba5cb8..9250331deda 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/DefaultRegExp.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/JdkRegExp.java @@ -41,7 +41,7 @@ import java.util.regex.PatternSyntaxException; * Note that this class is not thread-safe as it stores the current match result * and the string being matched in instance fields. */ -public class DefaultRegExp extends RegExp { +public class JdkRegExp extends RegExp { /** Java regexp pattern to use for match. We compile to one of these */ private Pattern pattern; @@ -56,7 +56,7 @@ public class DefaultRegExp extends RegExp { * @param flags RegExp flag string * @throws ParserException if flags is invalid or source string has syntax error. */ - public DefaultRegExp(final String source, final String flags) throws ParserException { + public JdkRegExp(final String source, final String flags) throws ParserException { super(source, flags); int intFlags = 0; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java index 1047221af69..f797b051adc 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java @@ -113,7 +113,7 @@ public class JoniRegExp extends RegExp { public static class Factory extends RegExpFactory { @Override - protected RegExp compile(final String pattern, final String flags) throws ParserException { + public RegExp compile(final String pattern, final String flags) throws ParserException { return new JoniRegExp(pattern, flags); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpFactory.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpFactory.java index 4a7ac11bc99..08168b63779 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpFactory.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpFactory.java @@ -29,7 +29,7 @@ import jdk.nashorn.internal.runtime.ParserException; import jdk.nashorn.internal.runtime.options.Options; /** - * Factory class for regular expressions. This class creates instances of {@link DefaultRegExp}. + * Factory class for regular expressions. This class creates instances of {@link JdkRegExp}. * An alternative factory can be installed using the {@code nashorn.regexp.impl} system property. */ public class RegExpFactory { @@ -62,8 +62,8 @@ public class RegExpFactory { * @return new RegExp * @throws ParserException if flags is invalid or pattern string has syntax error. */ - protected RegExp compile(final String pattern, final String flags) throws ParserException { - return new DefaultRegExp(pattern, flags); + public RegExp compile(final String pattern, final String flags) throws ParserException { + return new JdkRegExp(pattern, flags); } /** diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Analyser.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Analyser.java index 49a2a925ec8..c0dbf0d8740 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Analyser.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Analyser.java @@ -21,10 +21,7 @@ package jdk.nashorn.internal.runtime.regexp.joni; import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsAll; import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsAt; -import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsClear; import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsOnAt; -import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsOnAtSimple; -import static jdk.nashorn.internal.runtime.regexp.joni.Option.isCaptureGroup; import static jdk.nashorn.internal.runtime.regexp.joni.Option.isFindCondition; import static jdk.nashorn.internal.runtime.regexp.joni.Option.isIgnoreCase; import static jdk.nashorn.internal.runtime.regexp.joni.Option.isMultiline; @@ -36,8 +33,6 @@ import java.util.HashSet; import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.CTypeNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.CallNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; @@ -49,9 +44,7 @@ import jdk.nashorn.internal.runtime.regexp.joni.constants.NodeType; import jdk.nashorn.internal.runtime.regexp.joni.constants.RegexState; import jdk.nashorn.internal.runtime.regexp.joni.constants.StackPopLevel; import jdk.nashorn.internal.runtime.regexp.joni.constants.TargetInfo; -import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; import jdk.nashorn.internal.runtime.regexp.joni.encoding.ObjPtr; -import jdk.nashorn.internal.runtime.regexp.joni.encoding.Ptr; final class Analyser extends Parser { @@ -74,38 +67,9 @@ final class Analyser extends Parser { //regex.repeatRangeAlloc = 0; regex.repeatRangeLo = null; regex.repeatRangeHi = null; - regex.numCombExpCheck = 0; - - if (Config.USE_COMBINATION_EXPLOSION_CHECK) regex.numCombExpCheck = 0; parse(); - if (Config.USE_NAMED_GROUP) { - /* mixed use named group and no-named group */ - if (env.numNamed > 0 && syntax.captureOnlyNamedGroup() && !isCaptureGroup(regex.options)) { - if (env.numNamed != env.numMem) { - root = disableNoNameGroupCapture(root); - } else { - numberedRefCheck(root); - } - } - } // USE_NAMED_GROUP - - if (Config.USE_NAMED_GROUP) { - if (env.numCall > 0) { - env.unsetAddrList = new UnsetAddrList(env.numCall); - setupSubExpCall(root); - // r != 0 ??? - subexpRecursiveCheckTrav(root); - // r < 0 -< err, FOUND_CALLED_NODE = 1 - subexpInfRecursiveCheckTrav(root); - // r != 0 recursion infinite ??? - regex.numCall = env.numCall; - } else { - regex.numCall = 0; - } - } // USE_NAMED_GROUP - if (Config.DEBUG_PARSE_TREE_RAW && Config.DEBUG_PARSE_TREE) { Config.log.println(""); Config.log.println(root + "\n"); @@ -129,27 +93,6 @@ final class Analyser extends Parser { regex.btMemEnd |= regex.captureHistory; } - if (Config.USE_COMBINATION_EXPLOSION_CHECK) { - if (env.backrefedMem == 0 || (Config.USE_SUBEXP_CALL && env.numCall == 0)) { - setupCombExpCheck(root, 0); - - if (Config.USE_SUBEXP_CALL && env.hasRecursion) { - env.numCombExpCheck = 0; - } else { // USE_SUBEXP_CALL - if (env.combExpMaxRegNum > 0) { - for (int i=1; ic)/ - node = noNameDisableMap(node, map, counter); - } - } else { - //en.target = noNameDisableMap(en.target, map, counter); - en.setTarget(noNameDisableMap(en.target, map, counter)); // ??? - } - return node; - } - - private void noNameDisableMapFor_anchor(Node node, int[]map, Ptr counter) { - AnchorNode an = (AnchorNode)node; - switch (an.type) { - case AnchorNode.PREC_READ: - case AnchorNode.PREC_READ_NOT: - case AnchorNode.LOOK_BEHIND: - case AnchorNode.LOOK_BEHIND_NOT: - an.setTarget(noNameDisableMap(an.target, map, counter)); - } - } - - private Node noNameDisableMap(Node node, int[]map, Ptr counter) { - switch (node.getType()) { - case NodeType.LIST: - case NodeType.ALT: - noNameDisableMapFor_cosAlt(node, map, counter); - break; - case NodeType.QTFR: - noNameDisableMapFor_quantifier(node, map, counter); - break; - case NodeType.ENCLOSE: - node = noNameDisableMapFor_enclose(node, map, counter); - break; - case NodeType.ANCHOR: - noNameDisableMapFor_anchor(node, map, counter); - break; - } // switch - return node; - } - - private void renumberByMap(Node node, int[]map) { - switch (node.getType()) { - case NodeType.LIST: - case NodeType.ALT: - ConsAltNode can = (ConsAltNode)node; - do { - renumberByMap(can.car, map); - } while ((can = can.cdr) != null); - break; - - case NodeType.QTFR: - renumberByMap(((QuantifierNode)node).target, map); - break; - - case NodeType.ENCLOSE: - renumberByMap(((EncloseNode)node).target, map); - break; - - case NodeType.BREF: - ((BackRefNode)node).renumber(map); - break; - } // switch - } - - protected final void numberedRefCheck(Node node) { - switch (node.getType()) { - case NodeType.LIST: - case NodeType.ALT: - ConsAltNode can = (ConsAltNode)node; - do { - numberedRefCheck(can.car); - } while ((can = can.cdr) != null); - break; - - case NodeType.QTFR: - numberedRefCheck(((QuantifierNode)node).target); - break; - - case NodeType.ENCLOSE: - numberedRefCheck(((EncloseNode)node).target); - break; - - case NodeType.BREF: - BackRefNode br = (BackRefNode)node; - if (!br.isNameRef()) newValueException(ERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED); - break; - } // switch - } - - protected final Node disableNoNameGroupCapture(Node root) { - int[]map = new int[env.numMem + 1]; - - for (int i=1; i<=env.numMem; i++) map[i] = 0; - - root = noNameDisableMap(root, map, new Ptr(0)); - renumberByMap(root, map); - - for (int i=1, pos=1; i<=env.numMem; i++) { - if (map[i] > 0) { - env.memNodes[pos] = env.memNodes[i]; - pos++; - } - } - - int loc = env.captureHistory; - env.captureHistory = bsClear(); - - for (int i=1; i<=Config.MAX_CAPTURE_HISTORY_GROUP; i++) { - if (bsAt(loc, i)) { - env.captureHistory = bsOnAtSimple(env.captureHistory, map[i]); - } - } - - env.numMem = env.numNamed; - regex.numMem = env.numNamed; - - regex.renumberNameTable(map); - - return root; - } - private void swap(Node a, Node b) { a.swap(b); @@ -352,17 +143,6 @@ final class Analyser extends Parser { } while ((can = can.cdr) != null); break; - case NodeType.CALL: - if (Config.USE_SUBEXP_CALL) { - CallNode cn = (CallNode)node; - if (cn.isRecursion()) { - return TargetInfo.IS_EMPTY_REC; /* tiny version */ - } else { - info = quantifiersMemoryInfo(cn.target); - } - } // USE_SUBEXP_CALL - break; - case NodeType.QTFR: QuantifierNode qn = (QuantifierNode)node; if (qn.upper != 0) { @@ -417,18 +197,6 @@ final class Analyser extends Parser { } break; - case NodeType.CALL: - if (Config.USE_SUBEXP_CALL) { - CallNode cn = (CallNode)node; - if (cn.isRecursion()) { - EncloseNode en = (EncloseNode)cn.target; - if (en.isMinFixed()) min = en.minLength; - } else { - min = getMinMatchLength(cn.target); - } - } // USE_SUBEXP_CALL - break; - case NodeType.LIST: ConsAltNode can = (ConsAltNode)node; do { @@ -474,15 +242,13 @@ final class Analyser extends Parser { EncloseNode en = (EncloseNode)node; switch (en.type) { case EncloseType.MEMORY: - if (Config.USE_SUBEXP_CALL) { - if (en.isMinFixed()) { - min = en.minLength; - } else { - min = getMinMatchLength(en.target); - en.minLength = min; - en.setMinFixed(); - } - } // USE_SUBEXP_CALL + if (en.isMinFixed()) { + min = en.minLength; + } else { + min = getMinMatchLength(en.target); + en.minLength = min; + en.setMinFixed(); + } break; case EncloseType.OPTION: @@ -547,17 +313,6 @@ final class Analyser extends Parser { } break; - case NodeType.CALL: - if (Config.USE_SUBEXP_CALL) { - CallNode cn = (CallNode)node; - if (!cn.isRecursion()) { - max = getMaxMatchLength(cn.target); - } else { - max = MinMaxLen.INFINITE_DISTANCE; - } - } // USE_SUBEXP_CALL - break; - case NodeType.QTFR: QuantifierNode qn = (QuantifierNode)node; if (qn.upper != 0) { @@ -576,15 +331,13 @@ final class Analyser extends Parser { EncloseNode en = (EncloseNode)node; switch (en.type) { case EncloseType.MEMORY: - if (Config.USE_SUBEXP_CALL) { - if (en.isMaxFixed()) { - max = en.maxLength; - } else { - max = getMaxMatchLength(en.target); - en.maxLength = max; - en.setMaxFixed(); - } - } // USE_SUBEXP_CALL + if (en.isMaxFixed()) { + max = en.maxLength; + } else { + max = getMaxMatchLength(en.target); + en.maxLength = max; + en.setMaxFixed(); + } break; case EncloseType.OPTION: @@ -663,17 +416,6 @@ final class Analyser extends Parser { } break; - case NodeType.CALL: - if (Config.USE_SUBEXP_CALL) { - CallNode cn = (CallNode)node; - if (!cn.isRecursion()) { - len = getCharLengthTree(cn.target, level); - } else { - returnCode = GET_CHAR_LEN_VARLEN; - } - } // USE_SUBEXP_CALL - break; - case NodeType.CTYPE: len = 1; @@ -686,17 +428,15 @@ final class Analyser extends Parser { EncloseNode en = (EncloseNode)node; switch(en.type) { case EncloseType.MEMORY: - if (Config.USE_SUBEXP_CALL) { - if (en.isCLenFixed()) { - len = en.charLength; - } else { - len = getCharLengthTree(en.target, level); - if (returnCode == 0) { - en.charLength = len; - en.setCLenFixed(); - } + if (en.isCLenFixed()) { + len = en.charLength; + } else { + len = getCharLengthTree(en.target, level); + if (returnCode == 0) { + en.charLength = len; + en.setCLenFixed(); } - } // USE_SUBEXP_CALL + } break; case EncloseType.OPTION: @@ -727,10 +467,6 @@ final class Analyser extends Parser { switch(x.getType()) { case NodeType.CTYPE: switch(yType) { - case NodeType.CTYPE: - CTypeNode cny = (CTypeNode)y; - CTypeNode cnx = (CTypeNode)x; - return cny.ctype == cnx.ctype && cny.not != cnx.not; case NodeType.CCLASS: // !swap:! @@ -756,37 +492,6 @@ final class Analyser extends Parser { CClassNode xc = (CClassNode)x; switch(yType) { - case NodeType.CTYPE: - switch(((CTypeNode)y).ctype) { - case CharacterType.WORD: - if (!((CTypeNode)y).not) { - if (xc.mbuf == null && !xc.isNot()) { - for (int i=0; i 0) newValueException(ERR_NEVER_ENDING_RECURSION); - en.clearMark1(); - } - r = subexpInfRecursiveCheckTrav(en.target); - break; - - default: - break; - } // switch - - return r; - } - - private int subexpRecursiveCheck(Node node) { - int r = 0; - - switch (node.getType()) { - case NodeType.LIST: - case NodeType.ALT: - ConsAltNode can = (ConsAltNode)node; - do { - r |= subexpRecursiveCheck(can.car); - } while ((can = can.cdr) != null); - break; - - case NodeType.QTFR: - r = subexpRecursiveCheck(((QuantifierNode)node).target); - break; - - case NodeType.ANCHOR: - AnchorNode an = (AnchorNode)node; - switch (an.type) { - case AnchorType.PREC_READ: - case AnchorType.PREC_READ_NOT: - case AnchorType.LOOK_BEHIND: - case AnchorType.LOOK_BEHIND_NOT: - r = subexpRecursiveCheck(an.target); - break; - } // inner switch - break; - - case NodeType.CALL: - CallNode cn = (CallNode)node; - r = subexpRecursiveCheck(cn.target); - if (r != 0) cn.setRecursion(); - break; - - case NodeType.ENCLOSE: - EncloseNode en = (EncloseNode)node; - if (en.isMark2()) { - return 0; - } else if (en.isMark1()) { - return 1; /* recursion */ - } else { - en.setMark2(); - r = subexpRecursiveCheck(en.target); - en.clearMark2(); - } - break; - - default: - break; - } // switch - - return r; - } - - private static final int FOUND_CALLED_NODE = 1; - protected final int subexpRecursiveCheckTrav(Node node) { - int r = 0; - - switch (node.getType()) { - case NodeType.LIST: - case NodeType.ALT: - ConsAltNode can = (ConsAltNode)node; - do { - int ret = subexpRecursiveCheckTrav(can.car); - if (ret == FOUND_CALLED_NODE) { - r = FOUND_CALLED_NODE; - } - // else if (ret < 0) return ret; ??? - } while ((can = can.cdr) != null); - break; - - case NodeType.QTFR: - QuantifierNode qn = (QuantifierNode)node; - r = subexpRecursiveCheckTrav(qn.target); - if (qn.upper == 0) { - if (r == FOUND_CALLED_NODE) qn.isRefered = true; - } - break; - - case NodeType.ANCHOR: - AnchorNode an = (AnchorNode)node; - switch (an.type) { - case AnchorType.PREC_READ: - case AnchorType.PREC_READ_NOT: - case AnchorType.LOOK_BEHIND: - case AnchorType.LOOK_BEHIND_NOT: - r = subexpRecursiveCheckTrav(an.target); - break; - } // inner switch - break; - - case NodeType.ENCLOSE: - EncloseNode en = (EncloseNode)node; - if (!en.isRecursion()) { - if (en.isCalled()) { - en.setMark1(); - r = subexpRecursiveCheck(en.target); - if (r != 0) en.setRecursion(); - en.clearMark1(); - } - } - r = subexpRecursiveCheckTrav(en.target); - if (en.isCalled()) r |= FOUND_CALLED_NODE; - break; - - default: - break; - } // switch - - return r; - } - - private void setCallAttr(CallNode cn) { - cn.target = env.memNodes[cn.groupNum]; // no setTarget in call nodes! - if (cn.target == null) newValueException(ERR_UNDEFINED_NAME_REFERENCE, cn.nameP, cn.nameEnd); - - ((EncloseNode)cn.target).setCalled(); - env.btMemStart = BitStatus.bsOnAt(env.btMemStart, cn.groupNum); - cn.unsetAddrList = env.unsetAddrList; - } - - protected final void setupSubExpCall(Node node) { - - switch(node.getType()) { - case NodeType.LIST: - ConsAltNode ln = (ConsAltNode)node; - do { - setupSubExpCall(ln.car); - } while ((ln = ln.cdr) != null); - break; - - case NodeType.ALT: - ConsAltNode can = (ConsAltNode)node; - do { - setupSubExpCall(can.car); - } while ((can = can.cdr) != null); - break; - - case NodeType.QTFR: - setupSubExpCall(((QuantifierNode)node).target); - break; - - case NodeType.ENCLOSE: - setupSubExpCall(((EncloseNode)node).target); - break; - - case NodeType.CALL: - CallNode cn = (CallNode)node; - - if (cn.groupNum != 0) { - int gNum = cn.groupNum; - - if (Config.USE_NAMED_GROUP) { - if (env.numNamed > 0 && syntax.captureOnlyNamedGroup() && !isCaptureGroup(env.option)) { - newValueException(ERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED); - } - } // USE_NAMED_GROUP - if (gNum > env.numMem) newValueException(ERR_UNDEFINED_GROUP_REFERENCE, cn.nameP, cn.nameEnd); - setCallAttr(cn); - } else { - if (Config.USE_NAMED_GROUP) { - NameEntry ne = regex.nameToGroupNumbers(cn.name, cn.nameP, cn.nameEnd); - - if (ne == null) { - newValueException(ERR_UNDEFINED_NAME_REFERENCE, cn.nameP, cn.nameEnd); - } else if (ne.backNum > 1) { - newValueException(ERR_MULTIPLEX_DEFINITION_NAME_CALL, cn.nameP, cn.nameEnd); - } else { - cn.groupNum = ne.backRef1; // ne.backNum == 1 ? ne.backRef1 : ne.backRefs[0]; // ??? need to check ? - setCallAttr(cn); - } - } - } - break; - - case NodeType.ANCHOR: - AnchorNode an = (AnchorNode)node; - switch (an.type) { - case AnchorType.PREC_READ: - case AnchorType.PREC_READ_NOT: - case AnchorType.LOOK_BEHIND: - case AnchorType.LOOK_BEHIND_NOT: - setupSubExpCall(an.target); - break; - } - break; - - } // switch - } - /* divide different length alternatives in look-behind. (?<=A|B) ==> (?<=A)|(?<=B) (? (?= 0 && (ln = ln.cdr) != null); - break; - - case NodeType.ALT: - ConsAltNode an = (ConsAltNode)node; - do { - ret = setupCombExpCheck(an.car, state); - r |= ret; - } while (ret >= 0 && (an = an.cdr) != null); - break; - - case NodeType.QTFR: - QuantifierNode qn = (QuantifierNode)node; - int childState = state; - int addState = 0; - int varNum; - - if (!isRepeatInfinite(qn.upper)) { - if (qn.upper > 1) { - /* {0,1}, {1,1} are allowed */ - childState |= CEC_IN_FINITE_REPEAT; - - /* check (a*){n,m}, (a+){n,m} => (a*){n,n}, (a+){n,n} */ - if (env.backrefedMem == 0) { - if (qn.target.getType() == NodeType.ENCLOSE) { - EncloseNode en = (EncloseNode)qn.target; - if (en.type == EncloseType.MEMORY) { - if (en.target.getType() == NodeType.QTFR) { - QuantifierNode q = (QuantifierNode)en.target; - if (isRepeatInfinite(q.upper) && q.greedy == qn.greedy) { - qn.upper = qn.lower == 0 ? 1 : qn.lower; - if (qn.upper == 1) childState = state; - } - } - } - } - } - } - } - - if ((state & CEC_IN_FINITE_REPEAT) != 0) { - qn.combExpCheckNum = -1; - } else { - if (isRepeatInfinite(qn.upper)) { - varNum = CEC_INFINITE_NUM; - childState |= CEC_IN_INFINITE_REPEAT; - } else { - varNum = qn.upper - qn.lower; - } - - if (varNum >= CEC_THRES_NUM_BIG_REPEAT) addState |= CEC_CONT_BIG_REPEAT; - - if (((state & CEC_IN_INFINITE_REPEAT) != 0 && varNum != 0) || - ((state & CEC_CONT_BIG_REPEAT) != 0 && varNum >= CEC_THRES_NUM_BIG_REPEAT)) { - if (qn.combExpCheckNum == 0) { - env.numCombExpCheck++; - qn.combExpCheckNum = env.numCombExpCheck; - if (env.currMaxRegNum > env.combExpMaxRegNum) { - env.combExpMaxRegNum = env.currMaxRegNum; - } - } - } - } - r = setupCombExpCheck(qn.target, childState); - r |= addState; - break; - - case NodeType.ENCLOSE: - EncloseNode en = (EncloseNode)node; - switch( en.type) { - case EncloseNode.MEMORY: - if (env.currMaxRegNum < en.regNum) { - env.currMaxRegNum = en.regNum; - } - r = setupCombExpCheck(en.target, state); - break; - - default: - r = setupCombExpCheck(en.target, state); - } // inner switch - break; - - case NodeType.CALL: - if (Config.USE_SUBEXP_CALL) { - CallNode cn = (CallNode)node; - if (cn.isRecursion()) { - env.hasRecursion = true; - } else { - r = setupCombExpCheck(cn.target, state); - } - } // USE_SUBEXP_CALL - break; - - default: - break; - - } // switch - - return r; - } - private static final int IN_ALT = (1<<0); private static final int IN_NOT = (1<<1); private static final int IN_REPEAT = (1<<2); @@ -1691,20 +953,12 @@ final class Analyser extends Parser { case NodeType.CANY: break; - case NodeType.CALL: // if (Config.USE_SUBEXP_CALL) ? - break; - case NodeType.BREF: BackRefNode br = (BackRefNode)node; for (int i=0; i env.numMem) newValueException(ERR_INVALID_BACKREF); env.backrefedMem = bsOnAt(env.backrefedMem, br.back[i]); env.btMemStart = bsOnAt(env.btMemStart, br.back[i]); - if (Config.USE_BACKREF_WITH_LEVEL) { - if (br.isNestLevel()) { - env.btMemEnd = bsOnAt(env.btMemEnd, br.back[i]); - } - } // USE_BACKREF_AT_LEVEL ((EncloseNode)env.memNodes[br.back[i]]).setMemBackrefed(); } break; @@ -1916,37 +1170,6 @@ final class Analyser extends Parser { break; } - case NodeType.CTYPE: { - int min; - int max = 1; - if (max == 1) { - min = 1; - CTypeNode cn = (CTypeNode)node; - - switch (cn.ctype) { - case CharacterType.WORD: - if (cn.not) { - for (int i=0; i MAX_NODE_OPT_INFO_REF_COUNT) { + if (++en.optCount > MAX_NODE_OPT_INFO_REF_COUNT) { int min = 0; int max = MinMaxLen.INFINITE_DISTANCE; if (en.isMinFixed()) min = en.minLength; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java index b55991698b6..f348a205289 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java @@ -28,8 +28,6 @@ import static jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode.isRepe import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.CTypeNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.CallNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; @@ -71,11 +69,6 @@ final class ArrayCompiler extends Compiler { regex.templates = templates; regex.templateNum = templateNum; regex.factory = MatcherFactory.DEFAULT; - - if (Config.USE_SUBEXP_CALL && analyser.env.unsetAddrList != null) { - analyser.env.unsetAddrList.fix(regex); - analyser.env.unsetAddrList = null; - } } @Override @@ -119,7 +112,7 @@ final class ArrayCompiler extends Compiler { return isNeedStrLenOpExact(op); } - private int selectStrOpcode(int mbLength, int strLength, boolean ignoreCase) { + private int selectStrOpcode(int strLength, boolean ignoreCase) { int op; if (ignoreCase) { @@ -128,31 +121,14 @@ final class ArrayCompiler extends Compiler { default:op = OPCode.EXACTN_IC; break; } // switch } else { - switch (mbLength) { - case 1: - switch (strLength) { - case 1: op = OPCode.EXACT1; break; - case 2: op = OPCode.EXACT2; break; - case 3: op = OPCode.EXACT3; break; - case 4: op = OPCode.EXACT4; break; - case 5: op = OPCode.EXACT5; break; - default:op = OPCode.EXACTN; break; - } // inner switch - break; - case 2: - switch (strLength) { - case 1: op = OPCode.EXACTMB2N1; break; - case 2: op = OPCode.EXACTMB2N2; break; - case 3: op = OPCode.EXACTMB2N3; break; - default:op = OPCode.EXACTMB2N; break; - } // inner switch - break; - case 3: - op = OPCode.EXACTMB3N; - break; - default: - op = OPCode.EXACTMBN; - } // switch + switch (strLength) { + case 1: op = OPCode.EXACT1; break; + case 2: op = OPCode.EXACT2; break; + case 3: op = OPCode.EXACT3; break; + case 4: op = OPCode.EXACT4; break; + case 5: op = OPCode.EXACT5; break; + default:op = OPCode.EXACTN; break; + } // inner switch } return op; } @@ -185,8 +161,8 @@ final class ArrayCompiler extends Compiler { } } - private int addCompileStringlength(char[] chars, int p, int mbLength, int strLength, boolean ignoreCase) { - int op = selectStrOpcode(mbLength, strLength, ignoreCase); + private int addCompileStringlength(char[] chars, int p, int strLength, boolean ignoreCase) { + int op = selectStrOpcode(strLength, ignoreCase); int len = OPSize.OPCODE; if (Config.USE_STRING_TEMPLATES && opTemplated(op)) { @@ -194,25 +170,21 @@ final class ArrayCompiler extends Compiler { len += OPSize.LENGTH + OPSize.INDEX + OPSize.INDEX; } else { if (isNeedStrLenOpExact(op)) len += OPSize.LENGTH; - len += mbLength * strLength; + len += strLength; } if (op == OPCode.EXACTMBN) len += OPSize.LENGTH; return len; } @Override - protected final void addCompileString(char[] chars, int p, int mbLength, int strLength, boolean ignoreCase) { - int op = selectStrOpcode(mbLength, strLength, ignoreCase); + protected final void addCompileString(char[] chars, int p, int strLength, boolean ignoreCase) { + int op = selectStrOpcode(strLength, ignoreCase); addOpcode(op); - if (op == OPCode.EXACTMBN) addLength(mbLength); + if (op == OPCode.EXACTMBN) addLength(1); if (isNeedStrLenOpExact(op)) { - if (op == OPCode.EXACTN_IC || op == OPCode.EXACTN_IC_SB) { - addLength(mbLength * strLength); - } else { - addLength(strLength); - } + addLength(strLength); } if (Config.USE_STRING_TEMPLATES && opTemplated(op)) { @@ -220,7 +192,7 @@ final class ArrayCompiler extends Compiler { addInt(p); addTemplate(chars); } else { - addChars(chars, p, mbLength * strLength); + addChars(chars, p, strLength); } } @@ -242,14 +214,14 @@ final class ArrayCompiler extends Compiler { slen++; p++; } - int r = addCompileStringlength(chars, prev, 1, slen, ambig); + int r = addCompileStringlength(chars, prev, slen, ambig); rlen += r; return rlen; } private int compileLengthStringRawNode(StringNode sn) { if (sn.length() <= 0) return 0; - return addCompileStringlength(sn.chars, sn.p, 1 /*sb*/, sn.length(), false); + return addCompileStringlength(sn.chars, sn.p, sn.length(), false); } private void addMultiByteCClass(CodeRangeBuffer mbuf) { @@ -311,26 +283,6 @@ final class ArrayCompiler extends Compiler { } } - @Override - protected void compileCTypeNode(CTypeNode node) { - CTypeNode cn = node; - int op; - switch (cn.ctype) { - case CharacterType.WORD: - if (cn.not) { - op = OPCode.NOT_WORD; - } else { - op = OPCode.WORD; - } - break; - - default: - newInternalException(ERR_PARSER_BUG); - return; // not reached - } // inner switch - addOpcode(op); - } - @Override protected void compileAnyCharNode() { if (isMultiline(regex.options)) { @@ -340,31 +292,16 @@ final class ArrayCompiler extends Compiler { } } - @Override - protected void compileCallNode(CallNode node) { - addOpcode(OPCode.CALL); - node.unsetAddrList.add(codeLength, node.target); - addAbsAddr(0); /*dummy addr.*/ - } - @Override protected void compileBackrefNode(BackRefNode node) { BackRefNode br = node; - if (Config.USE_BACKREF_WITH_LEVEL && br.isNestLevel()) { - addOpcode(OPCode.BACKREF_WITH_LEVEL); - addOption(regex.options & Option.IGNORECASE); - addLength(br.nestLevel); - // !goto add_bacref_mems;! - addLength(br.backNum); - for (int i=br.backNum-1; i>=0; i--) addMemNum(br.back[i]); - return; - } else { // USE_BACKREF_AT_LEVEL - if (br.backNum == 1) { - if (isIgnoreCase(regex.options)) { - addOpcode(OPCode.BACKREFN_IC); - addMemNum(br.back[0]); - } else { - switch (br.back[0]) { + // USE_BACKREF_AT_LEVEL + if (br.backNum == 1) { + if (isIgnoreCase(regex.options)) { + addOpcode(OPCode.BACKREFN_IC); + addMemNum(br.back[0]); + } else { + switch (br.back[0]) { case 1: addOpcode(OPCode.BACKREF1); break; @@ -375,18 +312,17 @@ final class ArrayCompiler extends Compiler { addOpcode(OPCode.BACKREFN); addOpcode(br.back[0]); break; - } // switch - } - } else { - if (isIgnoreCase(regex.options)) { - addOpcode(OPCode.BACKREF_MULTI_IC); - } else { - addOpcode(OPCode.BACKREF_MULTI); - } - // !add_bacref_mems:! - addLength(br.backNum); - for (int i=br.backNum-1; i>=0; i--) addMemNum(br.back[i]); + } // switch } + } else { + if (isIgnoreCase(regex.options)) { + addOpcode(OPCode.BACKREF_MULTI_IC); + } else { + addOpcode(OPCode.BACKREF_MULTI); + } + // !add_bacref_mems:! + addLength(br.backNum); + for (int i=br.backNum-1; i>=0; i--) addMemNum(br.back[i]); } } @@ -419,7 +355,7 @@ final class ArrayCompiler extends Compiler { compileTreeEmptyCheck(qn.target, emptyInfo); - if ((Config.USE_SUBEXP_CALL && regex.numCall > 0) || qn.isInRepeat()) { + if (qn.isInRepeat()) { addOpcode(qn.greedy ? OPCode.REPEAT_INC_SG : OPCode.REPEAT_INC_NG_SG); } else { addOpcode(qn.greedy ? OPCode.REPEAT_INC : OPCode.REPEAT_INC_NG); @@ -434,193 +370,6 @@ final class ArrayCompiler extends Compiler { return ckn > 0; } - private int compileCECLengthQuantifierNode(QuantifierNode qn) { - boolean infinite = isRepeatInfinite(qn.upper); - int emptyInfo = qn.targetEmptyInfo; - - int tlen = compileLengthTree(qn.target); - int ckn = regex.numCombExpCheck > 0 ? qn.combExpCheckNum : 0; - int cklen = cknOn(ckn) ? OPSize.STATE_CHECK_NUM : 0; - - /* anychar repeat */ - if (qn.target.getType() == NodeType.CANY) { - if (qn.greedy && infinite) { - if (qn.nextHeadExact != null && !cknOn(ckn)) { - return OPSize.ANYCHAR_STAR_PEEK_NEXT + tlen * qn.lower + cklen; - } else { - return OPSize.ANYCHAR_STAR + tlen * qn.lower + cklen; - } - } - } - - int modTLen; - if (emptyInfo != 0) { - modTLen = tlen + (OPSize.NULL_CHECK_START + OPSize.NULL_CHECK_END); - } else { - modTLen = tlen; - } - - int len; - if (infinite && qn.lower <= 1) { - if (qn.greedy) { - if (qn.lower == 1) { - len = OPSize.JUMP; - } else { - len = 0; - } - len += OPSize.PUSH + cklen + modTLen + OPSize.JUMP; - } else { - if (qn.lower == 0) { - len = OPSize.JUMP; - } else { - len = 0; - } - len += modTLen + OPSize.PUSH + cklen; - } - } else if (qn.upper == 0) { - if (qn.isRefered) { /* /(?..){0}/ */ - len = OPSize.JUMP + tlen; - } else { - len = 0; - } - } else if (qn.upper == 1 && qn.greedy) { - if (qn.lower == 0) { - if (cknOn(ckn)) { - len = OPSize.STATE_CHECK_PUSH + tlen; - } else { - len = OPSize.PUSH + tlen; - } - } else { - len = tlen; - } - } else if (!qn.greedy && qn.upper == 1 && qn.lower == 0) { /* '??' */ - len = OPSize.PUSH + cklen + OPSize.JUMP + tlen; - } else { - len = OPSize.REPEAT_INC + modTLen + OPSize.OPCODE + OPSize.RELADDR + OPSize.MEMNUM; - - if (cknOn(ckn)) { - len += OPSize.STATE_CHECK; - } - } - return len; - } - - @Override - protected void compileCECQuantifierNode(QuantifierNode qn) { - boolean infinite = isRepeatInfinite(qn.upper); - int emptyInfo = qn.targetEmptyInfo; - - int tlen = compileLengthTree(qn.target); - - int ckn = regex.numCombExpCheck > 0 ? qn.combExpCheckNum : 0; - - if (qn.isAnyCharStar()) { - compileTreeNTimes(qn.target, qn.lower); - if (qn.nextHeadExact != null && !cknOn(ckn)) { - if (isMultiline(regex.options)) { - addOpcode(OPCode.ANYCHAR_ML_STAR_PEEK_NEXT); - } else { - addOpcode(OPCode.ANYCHAR_STAR_PEEK_NEXT); - } - if (cknOn(ckn)) { - addStateCheckNum(ckn); - } - StringNode sn = (StringNode)qn.nextHeadExact; - addChars(sn.chars, sn.p, 1); - return; - } else { - if (isMultiline(regex.options)) { - if (cknOn(ckn)) { - addOpcode(OPCode.STATE_CHECK_ANYCHAR_ML_STAR); - } else { - addOpcode(OPCode.ANYCHAR_ML_STAR); - } - } else { - if (cknOn(ckn)) { - addOpcode(OPCode.STATE_CHECK_ANYCHAR_STAR); - } else { - addOpcode(OPCode.ANYCHAR_STAR); - } - } - if (cknOn(ckn)) { - addStateCheckNum(ckn); - } - return; - } - } - - int modTLen; - if (emptyInfo != 0) { - modTLen = tlen + (OPSize.NULL_CHECK_START + OPSize.NULL_CHECK_END); - } else { - modTLen = tlen; - } - if (infinite && qn.lower <= 1) { - if (qn.greedy) { - if (qn.lower == 1) { - addOpcodeRelAddr(OPCode.JUMP, cknOn(ckn) ? OPSize.STATE_CHECK_PUSH : - OPSize.PUSH); - } - if (cknOn(ckn)) { - addOpcode(OPCode.STATE_CHECK_PUSH); - addStateCheckNum(ckn); - addRelAddr(modTLen + OPSize.JUMP); - } else { - addOpcodeRelAddr(OPCode.PUSH, modTLen + OPSize.JUMP); - } - compileTreeEmptyCheck(qn.target, emptyInfo); - addOpcodeRelAddr(OPCode.JUMP, -(modTLen + OPSize.JUMP + (cknOn(ckn) ? - OPSize.STATE_CHECK_PUSH : - OPSize.PUSH))); - } else { - if (qn.lower == 0) { - addOpcodeRelAddr(OPCode.JUMP, modTLen); - } - compileTreeEmptyCheck(qn.target, emptyInfo); - if (cknOn(ckn)) { - addOpcode(OPCode.STATE_CHECK_PUSH_OR_JUMP); - addStateCheckNum(ckn); - addRelAddr(-(modTLen + OPSize.STATE_CHECK_PUSH_OR_JUMP)); - } else { - addOpcodeRelAddr(OPCode.PUSH, -(modTLen + OPSize.PUSH)); - } - } - } else if (qn.upper == 0) { - if (qn.isRefered) { /* /(?..){0}/ */ - addOpcodeRelAddr(OPCode.JUMP, tlen); - compileTree(qn.target); - } // else r=0 ??? - } else if (qn.upper == 1 && qn.greedy) { - if (qn.lower == 0) { - if (cknOn(ckn)) { - addOpcode(OPCode.STATE_CHECK_PUSH); - addStateCheckNum(ckn); - addRelAddr(tlen); - } else { - addOpcodeRelAddr(OPCode.PUSH, tlen); - } - } - compileTree(qn.target); - } else if (!qn.greedy && qn.upper == 1 && qn.lower == 0){ /* '??' */ - if (cknOn(ckn)) { - addOpcode(OPCode.STATE_CHECK_PUSH); - addStateCheckNum(ckn); - addRelAddr(OPSize.JUMP); - } else { - addOpcodeRelAddr(OPCode.PUSH, OPSize.JUMP); - } - - addOpcodeRelAddr(OPCode.JUMP, tlen); - compileTree(qn.target); - } else { - compileRangeRepeatNode(qn, modTLen, emptyInfo); - if (cknOn(ckn)) { - addOpcode(OPCode.STATE_CHECK); - addStateCheckNum(ckn); - } - } - } - private int compileNonCECLengthQuantifierNode(QuantifierNode qn) { boolean infinite = isRepeatInfinite(qn.upper); int emptyInfo = qn.targetEmptyInfo; @@ -821,21 +570,12 @@ final class ArrayCompiler extends Compiler { int len; switch (node.type) { case EncloseType.MEMORY: - if (Config.USE_SUBEXP_CALL && node.isCalled()) { - len = OPSize.MEMORY_START_PUSH + tlen + OPSize.CALL + OPSize.JUMP + OPSize.RETURN; - if (bsAt(regex.btMemEnd, node.regNum)) { - len += node.isRecursion() ? OPSize.MEMORY_END_PUSH_REC : OPSize.MEMORY_END_PUSH; - } else { - len += node.isRecursion() ? OPSize.MEMORY_END_REC : OPSize.MEMORY_END; - } - } else { // USE_SUBEXP_CALL - if (bsAt(regex.btMemStart, node.regNum)) { - len = OPSize.MEMORY_START_PUSH; - } else { - len = OPSize.MEMORY_START; - } - len += tlen + (bsAt(regex.btMemEnd, node.regNum) ? OPSize.MEMORY_END_PUSH : OPSize.MEMORY_END); + if (bsAt(regex.btMemStart, node.regNum)) { + len = OPSize.MEMORY_START_PUSH; + } else { + len = OPSize.MEMORY_START; } + len += tlen + (bsAt(regex.btMemEnd, node.regNum) ? OPSize.MEMORY_END_PUSH : OPSize.MEMORY_END); break; case EncloseType.STOP_BACKTRACK: @@ -860,23 +600,6 @@ final class ArrayCompiler extends Compiler { int len; switch (node.type) { case EncloseType.MEMORY: - if (Config.USE_SUBEXP_CALL) { - if (node.isCalled()) { - addOpcode(OPCode.CALL); - node.callAddr = codeLength + OPSize.ABSADDR + OPSize.JUMP; - node.setAddrFixed(); - addAbsAddr(node.callAddr); - len = compileLengthTree(node.target); - len += OPSize.MEMORY_START_PUSH + OPSize.RETURN; - if (bsAt(regex.btMemEnd, node.regNum)) { - len += node.isRecursion() ? OPSize.MEMORY_END_PUSH_REC : OPSize.MEMORY_END_PUSH; - } else { - len += node.isRecursion() ? OPSize.MEMORY_END_REC : OPSize.MEMORY_END; - } - addOpcodeRelAddr(OPCode.JUMP, len); - } - } // USE_SUBEXP_CALL - if (bsAt(regex.btMemStart, node.regNum)) { addOpcode(OPCode.MEMORY_START_PUSH); } else { @@ -886,22 +609,12 @@ final class ArrayCompiler extends Compiler { addMemNum(node.regNum); compileTree(node.target); - if (Config.USE_SUBEXP_CALL && node.isCalled()) { - if (bsAt(regex.btMemEnd, node.regNum)) { - addOpcode(node.isRecursion() ? OPCode.MEMORY_END_PUSH_REC : OPCode.MEMORY_END_PUSH); - } else { - addOpcode(node.isRecursion() ? OPCode.MEMORY_END_REC : OPCode.MEMORY_END); - } - addMemNum(node.regNum); - addOpcode(OPCode.RETURN); - } else { // USE_SUBEXP_CALL - if (bsAt(regex.btMemEnd, node.regNum)) { - addOpcode(OPCode.MEMORY_END_PUSH); - } else { - addOpcode(OPCode.MEMORY_END); - } - addMemNum(node.regNum); + if (bsAt(regex.btMemEnd, node.regNum)) { + addOpcode(OPCode.MEMORY_END_PUSH); + } else { + addOpcode(OPCode.MEMORY_END); } + addMemNum(node.regNum); break; case EncloseType.STOP_BACKTRACK: @@ -1078,32 +791,17 @@ final class ArrayCompiler extends Compiler { case NodeType.BREF: BackRefNode br = (BackRefNode)node; - if (Config.USE_BACKREF_WITH_LEVEL && br.isNestLevel()) { - len = OPSize.OPCODE + OPSize.OPTION + OPSize.LENGTH + - OPSize.LENGTH + (OPSize.MEMNUM * br.backNum); - } else { // USE_BACKREF_AT_LEVEL - if (br.backNum == 1) { - len = ((!isIgnoreCase(regex.options) && br.back[0] <= 2) - ? OPSize.OPCODE : (OPSize.OPCODE + OPSize.MEMNUM)); - } else { - len = OPSize.OPCODE + OPSize.LENGTH + (OPSize.MEMNUM * br.backNum); - } + // USE_BACKREF_AT_LEVEL + if (br.backNum == 1) { + len = ((!isIgnoreCase(regex.options) && br.back[0] <= 2) + ? OPSize.OPCODE : (OPSize.OPCODE + OPSize.MEMNUM)); + } else { + len = OPSize.OPCODE + OPSize.LENGTH + (OPSize.MEMNUM * br.backNum); } break; - case NodeType.CALL: - if (Config.USE_SUBEXP_CALL) { - len = OPSize.CALL; - break; - } // USE_SUBEXP_CALL - break; - case NodeType.QTFR: - if (Config.USE_COMBINATION_EXPLOSION_CHECK) { - len = compileCECLengthQuantifierNode((QuantifierNode)node); - } else { - len = compileNonCECLengthQuantifierNode((QuantifierNode)node); - } + len = compileNonCECLengthQuantifierNode((QuantifierNode)node); break; case NodeType.ENCLOSE: diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/AsmCompiler.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/AsmCompiler.java deleted file mode 100644 index 475d6595bcd..00000000000 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/AsmCompiler.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package jdk.nashorn.internal.runtime.regexp.joni; - -import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.CTypeNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.CallNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode; - -final class AsmCompiler extends AsmCompilerSupport { - - public AsmCompiler(Analyser analyser) { - super(analyser); - } - - @Override - protected void prepare() { - REG_NUM++; - prepareMachine(); - prepareMachineInit(); - prepareMachineMatch(); - - prepareFactory(); - prepareFactoryInit(); - } - - @Override - protected void finish() { - setupFactoryInit(); - - setupMachineInit(); - setupMachineMatch(); - - setupClasses(); - } - - @Override - protected void compileAltNode(ConsAltNode node) { - } - - @Override - protected void addCompileString(char[] chars, int p, int mbLength, int strLength, boolean ignoreCase) { - String template = installTemplate(chars, p, strLength); - } - - @Override - protected void compileCClassNode(CClassNode node) { - if (node.bs != null) { - String bitsetName = installBitSet(node.bs.bits); - } - } - - @Override - protected void compileCTypeNode(CTypeNode node) { - } - - @Override - protected void compileAnyCharNode() { - } - - @Override - protected void compileBackrefNode(BackRefNode node) { - } - - @Override - protected void compileCallNode(CallNode node) { - } - - @Override - protected void compileCECQuantifierNode(QuantifierNode node) { - } - - @Override - protected void compileNonCECQuantifierNode(QuantifierNode node) { - } - - @Override - protected void compileOptionNode(EncloseNode node) { - } - - @Override - protected void compileEncloseNode(EncloseNode node) { - } - - @Override - protected void compileAnchorNode(AnchorNode node) { - } -} diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/AsmCompilerSupport.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/AsmCompilerSupport.java deleted file mode 100644 index 06ca21a9b06..00000000000 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/AsmCompilerSupport.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package jdk.nashorn.internal.runtime.regexp.joni; - -import java.io.FileOutputStream; -import java.io.IOException; - -import jdk.nashorn.internal.runtime.regexp.joni.constants.AsmConstants; -import jdk.internal.org.objectweb.asm.ClassWriter; -import jdk.internal.org.objectweb.asm.MethodVisitor; -import jdk.internal.org.objectweb.asm.Opcodes; - -abstract class AsmCompilerSupport extends Compiler implements Opcodes, AsmConstants { - protected ClassWriter factory; // matcher allocator, also bit set, code rage and string template container - protected MethodVisitor factoryInit;// factory constructor - protected String factoryName; - - protected ClassWriter machine; // matcher - protected MethodVisitor machineInit;// matcher constructor - protected MethodVisitor match; // actual matcher implementation (the matchAt method) - protected String machineName; - - // we will? try to manage visitMaxs ourselves for efficiency - protected int maxStack = 1; - protected int maxVars = LAST_INDEX; - - // for field generation - protected int bitsets, ranges, templates; - - // simple class name postfix scheme for now - static int REG_NUM = 0; - - // dummy class loader for now - private static final class DummyClassLoader extends ClassLoader { - public Class defineClass(String name, byte[] bytes) { - return super.defineClass(name, bytes, 0, bytes.length); - } - }; - - private static final DummyClassLoader loader = new DummyClassLoader(); - - AsmCompilerSupport(Analyser analyser) { - super(analyser); - } - - protected final void prepareFactory() { - factory = new ClassWriter(ClassWriter.COMPUTE_MAXS); - factoryName = "jdk/nashorn/internal/runtime/regexp/joni/MatcherFactory" + REG_NUM; - - factory.visit(V1_4, ACC_PUBLIC + ACC_FINAL, factoryName, null, "jdk/nashorn/internal/runtime/regexp/joni/MatcherFactory", null); - - MethodVisitor create = factory.visitMethod(ACC_SYNTHETIC, "create", "(Lorg/joni/Regex;[BII)Lorg/joni/Matcher;", null, null); - create.visitTypeInsn(NEW, machineName); - create.visitInsn(DUP); // instance - create.visitVarInsn(ALOAD, 1); // Regex - create.visitVarInsn(ALOAD, 2); // bytes[] - create.visitVarInsn(ILOAD, 3); // p - create.visitVarInsn(ILOAD, 4); // end - create.visitMethodInsn(INVOKESPECIAL, machineName, "", "(Lorg/joni/Regex;[BII)V"); - create.visitInsn(ARETURN); - create.visitMaxs(0, 0); - //create.visitMaxs(6, 5); - create.visitEnd(); - } - - protected final void prepareFactoryInit() { - factoryInit = factory.visitMethod(ACC_PUBLIC, "", "()V", null, null); - factoryInit.visitVarInsn(ALOAD, 0); - factoryInit.visitMethodInsn(INVOKESPECIAL, "jdk/nashorn/internal/runtime/regexp/joni/MatcherFactory", "", "()V"); - } - - protected final void setupFactoryInit() { - factoryInit.visitInsn(RETURN); - factoryInit.visitMaxs(0, 0); - //init.visitMaxs(1, 1); - factoryInit.visitEnd(); - } - - protected final void prepareMachine() { - machine = new ClassWriter(ClassWriter.COMPUTE_MAXS); - machineName = "jdk/nashorn/internal/runtime/regexp/joni/NativeMachine" + REG_NUM; - } - - protected final void prepareMachineInit() { - machine.visit(V1_4, ACC_PUBLIC + ACC_FINAL, machineName, null, "jdk/nashorn/internal/runtime/regexp/joni/NativeMachine", null); - machineInit = machine.visitMethod(ACC_PROTECTED, "", "(Lorg/joni/Regex;[BII)V", null, null); - machineInit.visitVarInsn(ALOAD, THIS); // this - machineInit.visitVarInsn(ALOAD, 1); // Regex - machineInit.visitVarInsn(ALOAD, 2); // bytes[] - machineInit.visitVarInsn(ILOAD, 3); // p - machineInit.visitVarInsn(ILOAD, 4); // end - machineInit.visitMethodInsn(INVOKESPECIAL, "jdk/nashorn/internal/runtime/regexp/joni/NativeMachine", "", "(Lorg/joni/Regex;[BII)V"); - } - - protected final void setupMachineInit() { - if (bitsets + ranges + templates > 0) { // ok, some of these are in use, we'd like to cache the factory - machine.visitField(ACC_PRIVATE + ACC_FINAL, "factory", "L" + factoryName + ";", null, null); - machineInit.visitVarInsn(ALOAD, THIS); // this - machineInit.visitVarInsn(ALOAD, 1); // this, Regex - machineInit.visitFieldInsn(GETFIELD, "jdk/nashorn/internal/runtime/regexp/joni/Regex", "factory", "Lorg/joni/MatcherFactory;"); // this, factory - machineInit.visitTypeInsn(CHECKCAST, factoryName); - machineInit.visitFieldInsn(PUTFIELD, machineName, "factory", "L" + factoryName + ";"); // [] - } - - machineInit.visitInsn(RETURN); - machineInit.visitMaxs(0, 0); - //init.visitMaxs(5, 5); - machineInit.visitEnd(); - } - - protected final void prepareMachineMatch() { - match = machine.visitMethod(ACC_SYNTHETIC, "matchAt", "(III)I", null, null); - move(S, SSTART); // s = sstart - load("bytes", "[B"); // - astore(BYTES); // byte[]bytes = this.bytes - } - - protected final void setupMachineMatch() { - match.visitInsn(ICONST_M1); - match.visitInsn(IRETURN); - - match.visitMaxs(maxStack, maxVars); - match.visitEnd(); - } - - protected final void setupClasses() { - byte[]factoryCode = factory.toByteArray(); - byte[]machineCode = machine.toByteArray(); - - if (Config.DEBUG_ASM) { - try { - FileOutputStream fos; - fos = new FileOutputStream(factoryName.substring(factoryName.lastIndexOf('/') + 1) + ".class"); - fos.write(factoryCode); - fos.close(); - fos = new FileOutputStream(machineName.substring(machineName.lastIndexOf('/') + 1) + ".class"); - fos.write(machineCode); - fos.close(); - } catch (IOException ioe) { - ioe.printStackTrace(Config.err); - } - } - - loader.defineClass(machineName.replace('/', '.'), machineCode); - Class cls = loader.defineClass(factoryName.replace('/', '.'), factoryCode); - try { - regex.factory = (MatcherFactory)cls.newInstance(); - } catch(Exception e) { - e.printStackTrace(Config.err); - } - } - - protected final void aload(int var) { - match.visitVarInsn(ALOAD, var); - } - - protected final void astore(int var) { - match.visitVarInsn(ASTORE, var); - } - - protected final void loadThis() { - match.visitVarInsn(ALOAD, THIS); - } - - protected final void load(int var) { - match.visitVarInsn(ILOAD, var); - } - - protected final void store(int var) { - match.visitVarInsn(ISTORE, var); - } - - protected final void move(int to, int from) { - load(from); - store(to); - } - - protected final void load(String field, String singature) { - loadThis(); - match.visitFieldInsn(GETFIELD, machineName, field, singature); - } - - protected final void load(String field) { - load(field, "I"); - } - - protected final void store(String field, String singature) { - loadThis(); - match.visitFieldInsn(PUTFIELD, machineName, field, singature); - } - - protected final void store(String field) { - store(field, "I"); - } - - protected final String installTemplate(char[] arr, int p, int length) { - String templateName = TEMPLATE + ++templates; - installArray(templateName, arr, p, length); - return templateName; - } - - protected final String installCodeRange(int[]arr) { - String coreRangeName = CODERANGE + ++ranges; - installArray(coreRangeName, arr); - return coreRangeName; - } - - protected final String installBitSet(int[]arr) { - String bitsetName = BITSET + ++bitsets; - installArray(bitsetName, arr); - return bitsetName; - } - - private void installArray(String name, int[]arr) { - factory.visitField(ACC_PRIVATE + ACC_FINAL, name, "[I", null, null); - factoryInit.visitVarInsn(ALOAD, THIS); // this; - loadInt(factoryInit, arr.length); // this, length - factoryInit.visitIntInsn(NEWARRAY, T_INT); // this, arr - for (int i=0;i < arr.length; i++) buildArray(i, arr[i], IASTORE); - factoryInit.visitFieldInsn(PUTFIELD, factoryName, name, "[I"); - } - - private void installArray(String name, char[]arr, int p, int length) { - factory.visitField(ACC_PRIVATE + ACC_FINAL, name, "[B", null, null); - factoryInit.visitVarInsn(ALOAD, THIS); // this; - loadInt(factoryInit, arr.length); // this, length - factoryInit.visitIntInsn(NEWARRAY, T_BYTE); // this, arr - for (int i=p, j=0; i < p + length; i++, j++) buildArray(j, arr[i] & 0xff, BASTORE); - factoryInit.visitFieldInsn(PUTFIELD, factoryName, name, "[B"); - } - - private void buildArray(int index, int value, int type) { - factoryInit.visitInsn(DUP); // ... arr, arr - loadInt(factoryInit, index); // ... arr, arr, index - loadInt(factoryInit, value); // ... arr, arr, index, value - factoryInit.visitInsn(type); // ... arr - } - - private void loadInt(MethodVisitor mv, int value) { - if (value >= -1 && value <= 5) { - mv.visitInsn(value + ICONST_0); // ICONST_0 == 3 - } else if (value >= 6 && value <= 127 || value >= -128 && value <= -2) { - mv.visitIntInsn(BIPUSH, value); - } else if (value >= 128 && value <= 32767 || value >= -32768 && value <= -129) { - mv.visitIntInsn(SIPUSH, value); - } else { - mv.visitLdcInsn(new Integer(value)); - } - } -} diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java index bf715987428..5f98fe6411b 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java @@ -51,10 +51,6 @@ public final class BitSet { bits[pos >>> ROOM_SHIFT] &= ~bit(pos); } - public void invert(int pos) { - bits[pos >>> ROOM_SHIFT] ^= bit(pos); - } - public void clear() { for (int i=0; i range) {opFail(); return;} - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - sprev = sbegin; // break; - } - - private void opExactMB2N2() { - if (s + 4 > range) {opFail(); return;} - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - sprev = s; - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - } - - private void opExactMB2N3() { - if (s + 6 > range) {opFail(); return;} - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - sprev = s; - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - } - - private void opExactMB2N() { - int tlen = code[ip++]; - if (s + tlen * 2 > range) {opFail(); return;} - - if (Config.USE_STRING_TEMPLATES) { - char[] bs = regex.templates[code[ip++]]; - int ps = code[ip++]; - - while(tlen-- > 0) { - if (bs[ps] != chars[s]) {opFail(); return;} - ps++; s++; - if (bs[ps] != chars[s]) {opFail(); return;} - ps++; s++; - } - } else { - while(tlen-- > 0) { - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - } - } - sprev = s - 2; - } - - private void opExactMB3N() { - int tlen = code[ip++]; - if (s + tlen * 3 > range) {opFail(); return;} - - if (Config.USE_STRING_TEMPLATES) { - char[] bs = regex.templates[code[ip++]]; - int ps = code[ip++]; - - while (tlen-- > 0) { - if (bs[ps] != chars[s]) {opFail(); return;} - ps++; s++; - if (bs[ps] != chars[s]) {opFail(); return;} - ps++; s++; - if (bs[ps] != chars[s]) {opFail(); return;} - ps++; s++; - } - } else { - while (tlen-- > 0) { - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - } - } - - sprev = s - 3; - } - - private void opExactMBN() { - int tlen = code[ip++]; /* mb-len */ - int tlen2= code[ip++]; /* string len */ - - tlen2 *= tlen; - if (s + tlen2 > range) {opFail(); return;} - - if (Config.USE_STRING_TEMPLATES) { - char[] bs = regex.templates[code[ip++]]; - int ps = code[ip++]; - - while (tlen2-- > 0) { - if (bs[ps] != chars[s]) {opFail(); return;} - ps++; s++; - } - } else { - while (tlen2-- > 0) { - if (code[ip] != chars[s]) {opFail(); return;} - ip++; s++; - } - } - - sprev = s - tlen; - } - private void opExact1IC() { if (s >= range || code[ip] != Character.toLowerCase(chars[s++])) {opFail(); return;} ip++; @@ -748,34 +558,6 @@ class ByteCodeMachine extends StackMachine { sprev = sbegin; // break; } - // CEC - private void opStateCheckAnyCharStar() { - int mem = code[ip++]; - final char[] chars = this.chars; - - while (s < range) { - if (stateCheckVal(s, mem)) {opFail(); return;} - pushAltWithStateCheck(ip, s, sprev, mem); - if (chars[s] == EncodingHelper.NEW_LINE) {opFail(); return;} - sprev = s; - s++; - } - sprev = sbegin; // break; - } - - // CEC - private void opStateCheckAnyCharMLStar() { - int mem = code[ip++]; - - while (s < range) { - if (stateCheckVal(s, mem)) {opFail(); return;} - pushAltWithStateCheck(ip, s, sprev, mem); - sprev = s; - s++; - } - sprev = sbegin; // break; - } - private void opWord() { if (s >= range || !EncodingHelper.isWord(chars[s])) {opFail(); return;} s++; @@ -1223,33 +1005,6 @@ class ByteCodeMachine extends StackMachine { pushAlt(ip + addr, s, sprev); } - // CEC - private void opStateCheckPush() { - int mem = code[ip++]; - if (stateCheckVal(s, mem)) {opFail(); return;} - int addr = code[ip++]; - pushAltWithStateCheck(ip + addr, s, sprev, mem); - } - - // CEC - private void opStateCheckPushOrJump() { - int mem = code[ip++]; - int addr= code[ip++]; - - if (stateCheckVal(s, mem)) { - ip += addr; - } else { - pushAltWithStateCheck(ip + addr, s, sprev, mem); - } - } - - // CEC - private void opStateCheck() { - int mem = code[ip++]; - if (stateCheckVal(s, mem)) {opFail(); return;} - pushStateCheck(s, mem); - } - private void opPop() { popOne(); } @@ -1425,17 +1180,6 @@ class ByteCodeMachine extends StackMachine { opFail(); } - private void opCall() { - int addr = code[ip++]; - pushCallFrame(ip); - ip = addr; // absolute address - } - - private void opReturn() { - ip = sreturn(); - pushReturn(); - } - private void opFail() { if (stack == null) { ip = regex.codeLength - 1; @@ -1447,13 +1191,6 @@ class ByteCodeMachine extends StackMachine { ip = e.getStatePCode(); s = e.getStatePStr(); sprev = e.getStatePStrPrev(); - - if (Config.USE_COMBINATION_EXPLOSION_CHECK) { - if (e.getStateCheck() != 0) { - e.type = STATE_CHECK_MARK; - stk++; - } - } } private int finish() { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodePrinter.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodePrinter.java index 86a558b0e0c..d56164d116f 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodePrinter.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodePrinter.java @@ -34,6 +34,239 @@ class ByteCodePrinter { int operantCount; WarnCallback warnings; + private final static String OpCodeNames[] = new String[] { + "finish", /*OP_FINISH*/ + "end", /*OP_END*/ + "exact1", /*OP_EXACT1*/ + "exact2", /*OP_EXACT2*/ + "exact3", /*OP_EXACT3*/ + "exact4", /*OP_EXACT4*/ + "exact5", /*OP_EXACT5*/ + "exactn", /*OP_EXACTN*/ + "exactmb2-n1", /*OP_EXACTMB2N1*/ + "exactmb2-n2", /*OP_EXACTMB2N2*/ + "exactmb2-n3", /*OP_EXACTMB2N3*/ + "exactmb2-n", /*OP_EXACTMB2N*/ + "exactmb3n", /*OP_EXACTMB3N*/ + "exactmbn", /*OP_EXACTMBN*/ + "exact1-ic", /*OP_EXACT1_IC*/ + "exactn-ic", /*OP_EXACTN_IC*/ + "cclass", /*OP_CCLASS*/ + "cclass-mb", /*OP_CCLASS_MB*/ + "cclass-mix", /*OP_CCLASS_MIX*/ + "cclass-not", /*OP_CCLASS_NOT*/ + "cclass-mb-not", /*OP_CCLASS_MB_NOT*/ + "cclass-mix-not", /*OP_CCLASS_MIX_NOT*/ + "cclass-node", /*OP_CCLASS_NODE*/ + "anychar", /*OP_ANYCHAR*/ + "anychar-ml", /*OP_ANYCHAR_ML*/ + "anychar*", /*OP_ANYCHAR_STAR*/ + "anychar-ml*", /*OP_ANYCHAR_ML_STAR*/ + "anychar*-peek-next", /*OP_ANYCHAR_STAR_PEEK_NEXT*/ + "anychar-ml*-peek-next", /*OP_ANYCHAR_ML_STAR_PEEK_NEXT*/ + "word", /*OP_WORD*/ + "not-word", /*OP_NOT_WORD*/ + "word-bound", /*OP_WORD_BOUND*/ + "not-word-bound", /*OP_NOT_WORD_BOUND*/ + "word-begin", /*OP_WORD_BEGIN*/ + "word-end", /*OP_WORD_END*/ + "begin-buf", /*OP_BEGIN_BUF*/ + "end-buf", /*OP_END_BUF*/ + "begin-line", /*OP_BEGIN_LINE*/ + "end-line", /*OP_END_LINE*/ + "semi-end-buf", /*OP_SEMI_END_BUF*/ + "begin-position", /*OP_BEGIN_POSITION*/ + "backref1", /*OP_BACKREF1*/ + "backref2", /*OP_BACKREF2*/ + "backrefn", /*OP_BACKREFN*/ + "backrefn-ic", /*OP_BACKREFN_IC*/ + "backref_multi", /*OP_BACKREF_MULTI*/ + "backref_multi-ic", /*OP_BACKREF_MULTI_IC*/ + "backref_at_level", /*OP_BACKREF_AT_LEVEL*/ + "mem-start", /*OP_MEMORY_START*/ + "mem-start-push", /*OP_MEMORY_START_PUSH*/ + "mem-end-push", /*OP_MEMORY_END_PUSH*/ + "mem-end-push-rec", /*OP_MEMORY_END_PUSH_REC*/ + "mem-end", /*OP_MEMORY_END*/ + "mem-end-rec", /*OP_MEMORY_END_REC*/ + "fail", /*OP_FAIL*/ + "jump", /*OP_JUMP*/ + "push", /*OP_PUSH*/ + "pop", /*OP_POP*/ + "push-or-jump-e1", /*OP_PUSH_OR_JUMP_EXACT1*/ + "push-if-peek-next", /*OP_PUSH_IF_PEEK_NEXT*/ + "repeat", /*OP_REPEAT*/ + "repeat-ng", /*OP_REPEAT_NG*/ + "repeat-inc", /*OP_REPEAT_INC*/ + "repeat-inc-ng", /*OP_REPEAT_INC_NG*/ + "repeat-inc-sg", /*OP_REPEAT_INC_SG*/ + "repeat-inc-ng-sg", /*OP_REPEAT_INC_NG_SG*/ + "null-check-start", /*OP_NULL_CHECK_START*/ + "null-check-end", /*OP_NULL_CHECK_END*/ + "null-check-end-memst", /*OP_NULL_CHECK_END_MEMST*/ + "null-check-end-memst-push", /*OP_NULL_CHECK_END_MEMST_PUSH*/ + "push-pos", /*OP_PUSH_POS*/ + "pop-pos", /*OP_POP_POS*/ + "push-pos-not", /*OP_PUSH_POS_NOT*/ + "fail-pos", /*OP_FAIL_POS*/ + "push-stop-bt", /*OP_PUSH_STOP_BT*/ + "pop-stop-bt", /*OP_POP_STOP_BT*/ + "look-behind", /*OP_LOOK_BEHIND*/ + "push-look-behind-not", /*OP_PUSH_LOOK_BEHIND_NOT*/ + "fail-look-behind-not", /*OP_FAIL_LOOK_BEHIND_NOT*/ + "call", /*OP_CALL*/ + "return", /*OP_RETURN*/ + "state-check-push", /*OP_STATE_CHECK_PUSH*/ + "state-check-push-or-jump", /*OP_STATE_CHECK_PUSH_OR_JUMP*/ + "state-check", /*OP_STATE_CHECK*/ + "state-check-anychar*", /*OP_STATE_CHECK_ANYCHAR_STAR*/ + "state-check-anychar-ml*", /*OP_STATE_CHECK_ANYCHAR_ML_STAR*/ + "set-option-push", /*OP_SET_OPTION_PUSH*/ + "set-option", /*OP_SET_OPTION*/ + + // single byte versions + "anychar-sb", /*OP_ANYCHAR*/ + "anychar-ml-sb", /*OP_ANYCHAR_ML*/ + "anychar*-sb", /*OP_ANYCHAR_STAR*/ + "anychar-ml*-sb", /*OP_ANYCHAR_ML_STAR*/ + "anychar*-peek-next-sb", /*OP_ANYCHAR_STAR_PEEK_NEXT*/ + "anychar-ml*-peek-next-sb", /*OP_ANYCHAR_ML_STAR_PEEK_NEXT*/ + "state-check-anychar*-sb", /*OP_STATE_CHECK_ANYCHAR_STAR*/ + "state-check-anychar-ml*-sb", /*OP_STATE_CHECK_ANYCHAR_ML_STAR*/ + + "cclass-sb", /*OP_CCLASS*/ + "cclass-not-sb", /*OP_CCLASS_NOT*/ + + "word-sb", /*OP_WORD*/ + "not-word-sb", /*OP_NOT_WORD*/ + "word-bound-sb", /*OP_WORD_BOUND*/ + "not-word-bound-sb", /*OP_NOT_WORD_BOUND*/ + "word-begin-sb", /*OP_WORD_BEGIN*/ + "word-end-sb", /*OP_WORD_END*/ + + "look-behind-sb", /*OP_LOOK_BEHIND*/ + + "exact1-ic-sb", /*OP_EXACT1_IC*/ + "exactn-ic-sb", /*OP_EXACTN_IC*/ + + }; + + private final static int OpCodeArgTypes[] = new int[] { + Arguments.NON, /*OP_FINISH*/ + Arguments.NON, /*OP_END*/ + Arguments.SPECIAL, /*OP_EXACT1*/ + Arguments.SPECIAL, /*OP_EXACT2*/ + Arguments.SPECIAL, /*OP_EXACT3*/ + Arguments.SPECIAL, /*OP_EXACT4*/ + Arguments.SPECIAL, /*OP_EXACT5*/ + Arguments.SPECIAL, /*OP_EXACTN*/ + Arguments.SPECIAL, /*OP_EXACTMB2N1*/ + Arguments.SPECIAL, /*OP_EXACTMB2N2*/ + Arguments.SPECIAL, /*OP_EXACTMB2N3*/ + Arguments.SPECIAL, /*OP_EXACTMB2N*/ + Arguments.SPECIAL, /*OP_EXACTMB3N*/ + Arguments.SPECIAL, /*OP_EXACTMBN*/ + Arguments.SPECIAL, /*OP_EXACT1_IC*/ + Arguments.SPECIAL, /*OP_EXACTN_IC*/ + Arguments.SPECIAL, /*OP_CCLASS*/ + Arguments.SPECIAL, /*OP_CCLASS_MB*/ + Arguments.SPECIAL, /*OP_CCLASS_MIX*/ + Arguments.SPECIAL, /*OP_CCLASS_NOT*/ + Arguments.SPECIAL, /*OP_CCLASS_MB_NOT*/ + Arguments.SPECIAL, /*OP_CCLASS_MIX_NOT*/ + Arguments.SPECIAL, /*OP_CCLASS_NODE*/ + Arguments.NON, /*OP_ANYCHAR*/ + Arguments.NON, /*OP_ANYCHAR_ML*/ + Arguments.NON, /*OP_ANYCHAR_STAR*/ + Arguments.NON, /*OP_ANYCHAR_ML_STAR*/ + Arguments.SPECIAL, /*OP_ANYCHAR_STAR_PEEK_NEXT*/ + Arguments.SPECIAL, /*OP_ANYCHAR_ML_STAR_PEEK_NEXT*/ + Arguments.NON, /*OP_WORD*/ + Arguments.NON, /*OP_NOT_WORD*/ + Arguments.NON, /*OP_WORD_BOUND*/ + Arguments.NON, /*OP_NOT_WORD_BOUND*/ + Arguments.NON, /*OP_WORD_BEGIN*/ + Arguments.NON, /*OP_WORD_END*/ + Arguments.NON, /*OP_BEGIN_BUF*/ + Arguments.NON, /*OP_END_BUF*/ + Arguments.NON, /*OP_BEGIN_LINE*/ + Arguments.NON, /*OP_END_LINE*/ + Arguments.NON, /*OP_SEMI_END_BUF*/ + Arguments.NON, /*OP_BEGIN_POSITION*/ + Arguments.NON, /*OP_BACKREF1*/ + Arguments.NON, /*OP_BACKREF2*/ + Arguments.MEMNUM, /*OP_BACKREFN*/ + Arguments.SPECIAL, /*OP_BACKREFN_IC*/ + Arguments.SPECIAL, /*OP_BACKREF_MULTI*/ + Arguments.SPECIAL, /*OP_BACKREF_MULTI_IC*/ + Arguments.SPECIAL, /*OP_BACKREF_AT_LEVEL*/ + Arguments.MEMNUM, /*OP_MEMORY_START*/ + Arguments.MEMNUM, /*OP_MEMORY_START_PUSH*/ + Arguments.MEMNUM, /*OP_MEMORY_END_PUSH*/ + Arguments.MEMNUM, /*OP_MEMORY_END_PUSH_REC*/ + Arguments.MEMNUM, /*OP_MEMORY_END*/ + Arguments.MEMNUM, /*OP_MEMORY_END_REC*/ + Arguments.NON, /*OP_FAIL*/ + Arguments.RELADDR, /*OP_JUMP*/ + Arguments.RELADDR, /*OP_PUSH*/ + Arguments.NON, /*OP_POP*/ + Arguments.SPECIAL, /*OP_PUSH_OR_JUMP_EXACT1*/ + Arguments.SPECIAL, /*OP_PUSH_IF_PEEK_NEXT*/ + Arguments.SPECIAL, /*OP_REPEAT*/ + Arguments.SPECIAL, /*OP_REPEAT_NG*/ + Arguments.MEMNUM, /*OP_REPEAT_INC*/ + Arguments.MEMNUM, /*OP_REPEAT_INC_NG*/ + Arguments.MEMNUM, /*OP_REPEAT_INC_SG*/ + Arguments.MEMNUM, /*OP_REPEAT_INC_NG_SG*/ + Arguments.MEMNUM, /*OP_NULL_CHECK_START*/ + Arguments.MEMNUM, /*OP_NULL_CHECK_END*/ + Arguments.MEMNUM, /*OP_NULL_CHECK_END_MEMST*/ + Arguments.MEMNUM, /*OP_NULL_CHECK_END_MEMST_PUSH*/ + Arguments.NON, /*OP_PUSH_POS*/ + Arguments.NON, /*OP_POP_POS*/ + Arguments.RELADDR, /*OP_PUSH_POS_NOT*/ + Arguments.NON, /*OP_FAIL_POS*/ + Arguments.NON, /*OP_PUSH_STOP_BT*/ + Arguments.NON, /*OP_POP_STOP_BT*/ + Arguments.SPECIAL, /*OP_LOOK_BEHIND*/ + Arguments.SPECIAL, /*OP_PUSH_LOOK_BEHIND_NOT*/ + Arguments.NON, /*OP_FAIL_LOOK_BEHIND_NOT*/ + Arguments.ABSADDR, /*OP_CALL*/ + Arguments.NON, /*OP_RETURN*/ + Arguments.SPECIAL, /*OP_STATE_CHECK_PUSH*/ + Arguments.SPECIAL, /*OP_STATE_CHECK_PUSH_OR_JUMP*/ + Arguments.STATE_CHECK, /*OP_STATE_CHECK*/ + Arguments.STATE_CHECK, /*OP_STATE_CHECK_ANYCHAR_STAR*/ + Arguments.STATE_CHECK, /*OP_STATE_CHECK_ANYCHAR_ML_STAR*/ + Arguments.OPTION, /*OP_SET_OPTION_PUSH*/ + Arguments.OPTION, /*OP_SET_OPTION*/ + + // single byte versions + Arguments.NON, /*OP_ANYCHAR*/ + Arguments.NON, /*OP_ANYCHAR_ML*/ + Arguments.NON, /*OP_ANYCHAR_STAR*/ + Arguments.NON, /*OP_ANYCHAR_ML_STAR*/ + Arguments.SPECIAL, /*OP_ANYCHAR_STAR_PEEK_NEXT*/ + Arguments.SPECIAL, /*OP_ANYCHAR_ML_STAR_PEEK_NEXT*/ + Arguments.STATE_CHECK, /*OP_STATE_CHECK_ANYCHAR_STAR*/ + Arguments.STATE_CHECK, /*OP_STATE_CHECK_ANYCHAR_ML_STAR*/ + + Arguments.SPECIAL, /*OP_CCLASS*/ + Arguments.SPECIAL, /*OP_CCLASS_NOT*/ + + Arguments.NON, /*OP_WORD*/ + Arguments.NON, /*OP_NOT_WORD*/ + Arguments.NON, /*OP_WORD_BOUND*/ + Arguments.NON, /*OP_NOT_WORD_BOUND*/ + Arguments.NON, /*OP_WORD_BEGIN*/ + Arguments.NON, /*OP_WORD_END*/ + + Arguments.SPECIAL, /*OP_LOOK_BEHIND*/ + + Arguments.SPECIAL, /*OP_EXACT1_IC*/ + Arguments.SPECIAL, /*OP_EXACTN_IC*/ + }; + public ByteCodePrinter(Regex regex) { code = regex.code; codeLength = regex.codeLength; @@ -76,8 +309,8 @@ class ByteCodePrinter { CClassNode cc; int tm, idx; - sb.append("[" + OPCode.OpCodeNames[code[bp]]); - int argType = OPCode.OpCodeArgTypes[code[bp]]; + sb.append("[" + OpCodeNames[code[bp]]); + int argType = OpCodeArgTypes[code[bp]]; int ip = bp; if (argType != Arguments.SPECIAL) { bp++; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/CaptureTreeNode.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/CaptureTreeNode.java deleted file mode 100644 index 268f682c92e..00000000000 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/CaptureTreeNode.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package jdk.nashorn.internal.runtime.regexp.joni; - -public class CaptureTreeNode { - - - int group; - int beg; - int end; - // int allocated; - int numChildren; - CaptureTreeNode[]children; - - CaptureTreeNode() { - beg = Region.REGION_NOTPOS; - end = Region.REGION_NOTPOS; - group = -1; - } - - static final int HISTORY_TREE_INIT_ALLOC_SIZE = 8; - void addChild(CaptureTreeNode child) { - if (children == null) { - children = new CaptureTreeNode[HISTORY_TREE_INIT_ALLOC_SIZE]; - } else if (numChildren >= children.length) { - CaptureTreeNode[]tmp = new CaptureTreeNode[children.length << 1]; - System.arraycopy(children, 0, tmp, 0, children.length); - children = tmp; - } - - children[numChildren] = child; - numChildren++; - } - - void clear() { - for (int i=0; i, \k */ - final boolean USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT = true; /* /(?:()|())*\2/ */ final boolean USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE = true; /* /\n$/ =~ "\n" */ final boolean USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR = false; @@ -42,12 +38,10 @@ public interface Config { final boolean CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS = true; final boolean USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE = false; - final boolean USE_CAPTURE_HISTORY = false; final boolean USE_VARIABLE_META_CHARS = true; final boolean USE_WORD_BEGIN_END = true; /* "\<": word-begin, "\>": word-end */ - final boolean USE_POSIX_API_REGION_OPTION = true; /* needed for POSIX API support */ + final boolean USE_POSIX_API_REGION_OPTION = false; /* needed for POSIX API support */ final boolean USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE = true; - final boolean USE_COMBINATION_EXPLOSION_CHECK = false; final int NREGION = 10; final int MAX_BACKREF_NUM = 1000; @@ -73,13 +67,6 @@ public interface Config { final boolean USE_STRING_TEMPLATES = true; // use embeded string templates in Regex object as byte arrays instead of compiling them into int bytecode array - - final int MAX_CAPTURE_HISTORY_GROUP = 31; - - - final int CHECK_STRING_THRESHOLD_LEN = 7; - final int CHECK_BUFF_MAX_SIZE = 0x4000; - final boolean NON_UNICODE_SDW = true; @@ -95,6 +82,4 @@ public interface Config { final boolean DEBUG_COMPILE_BYTE_CODE_INFO = DEBUG_ALL; final boolean DEBUG_SEARCH = DEBUG_ALL; final boolean DEBUG_MATCH = DEBUG_ALL; - final boolean DEBUG_ASM = true; - final boolean DEBUG_ASM_EXEC = true; } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/EncodingHelper.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/EncodingHelper.java index d3e54947aea..8c274fe0365 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/EncodingHelper.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/EncodingHelper.java @@ -95,20 +95,6 @@ public class EncodingHelper { return s; } - /* onigenc_with_ascii_strncmp */ - public static int strNCmp(char[] chars1, int p1, int end, char[] chars2, int p2, int n) { - while (n-- > 0) { - if (p1 >= end) return chars2[p2]; - int c = chars1[p1]; - int x = chars2[p2] - c; - if (x != 0) return x; - - p2++; - p1++; - } - return 0; - } - public static int mbcToCode(byte[] bytes, int p, int end) { int code = 0; for (int i = p; i < end; i++) { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Lexer.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Lexer.java index c289f33d34d..53ab3ec066b 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Lexer.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Lexer.java @@ -27,10 +27,7 @@ import jdk.nashorn.internal.runtime.regexp.joni.constants.AnchorType; import jdk.nashorn.internal.runtime.regexp.joni.constants.MetaChar; import jdk.nashorn.internal.runtime.regexp.joni.constants.TokenType; import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; -import jdk.nashorn.internal.runtime.regexp.joni.encoding.PosixBracket; -import jdk.nashorn.internal.runtime.regexp.joni.encoding.Ptr; import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; -import jdk.nashorn.internal.runtime.regexp.joni.exception.JOniException; class Lexer extends ScannerSupport { protected final ScanEnvironment env; @@ -215,198 +212,6 @@ class Lexer extends ScannerSupport { \k<-num+n>, \k<-num-n> */ - // value implicit (rnameEnd) - private boolean fetchNameWithLevel(int startCode, Ptr rbackNum, Ptr rlevel) { - int src = p; - boolean existLevel = false; - int isNum = 0; - int sign = 1; - - int endCode = nameEndCodePoint(startCode); - int pnumHead = p; - int nameEnd = stop; - - String err = null; - if (!left()) { - newValueException(ERR_EMPTY_GROUP_NAME); - } else { - fetch(); - if (c == endCode) newValueException(ERR_EMPTY_GROUP_NAME); - if (Character.isDigit(c)) { - isNum = 1; - } else if (c == '-') { - isNum = 2; - sign = -1; - pnumHead = p; - } else if (!EncodingHelper.isWord(c)) { - err = ERR_INVALID_GROUP_NAME; - } - } - - while (left()) { - nameEnd = p; - fetch(); - if (c == endCode || c == ')' || c == '+' || c == '-') { - if (isNum == 2) err = ERR_INVALID_GROUP_NAME; - break; - } - - if (isNum != 0) { - if (EncodingHelper.isDigit(c)) { - isNum = 1; - } else { - err = ERR_INVALID_GROUP_NAME; - // isNum = 0; - } - } else if (!EncodingHelper.isWord(c)) { - err = ERR_INVALID_CHAR_IN_GROUP_NAME; - } - } - - boolean isEndCode = false; - if (err == null && c != endCode) { - if (c == '+' || c == '-') { - int flag = c == '-' ? -1 : 1; - - fetch(); - if (!EncodingHelper.isDigit(c)) newValueException(ERR_INVALID_GROUP_NAME, src, stop); - unfetch(); - int level = scanUnsignedNumber(); - if (level < 0) newValueException(ERR_TOO_BIG_NUMBER); - rlevel.p = level * flag; - existLevel = true; - - fetch(); - isEndCode = c == endCode; - } - - if (!isEndCode) { - err = ERR_INVALID_GROUP_NAME; - nameEnd = stop; - } - } - - if (err == null) { - if (isNum != 0) { - mark(); - p = pnumHead; - int backNum = scanUnsignedNumber(); - restore(); - if (backNum < 0) { - newValueException(ERR_TOO_BIG_NUMBER); - } else if (backNum == 0) { - newValueException(ERR_INVALID_GROUP_NAME, src, stop); - } - rbackNum.p = backNum * sign; - } - value = nameEnd; - return existLevel; - } else { - newValueException(ERR_INVALID_GROUP_NAME, src, nameEnd); - return false; // not reached - } - } - - // USE_NAMED_GROUP - // ref: 0 -> define name (don't allow number name) - // 1 -> reference name (allow number name) - private int fetchNameForNamedGroup(int startCode, boolean ref) { - int src = p; - value = 0; - - int isNum = 0; - int sign = 1; - - int endCode = nameEndCodePoint(startCode); - int pnumHead = p; - int nameEnd = stop; - - String err = null; - if (!left()) { - newValueException(ERR_EMPTY_GROUP_NAME); - } else { - fetch(); - if (c == endCode) newValueException(ERR_EMPTY_GROUP_NAME); - if (EncodingHelper.isDigit(c)) { - if (ref) { - isNum = 1; - } else { - err = ERR_INVALID_GROUP_NAME; - // isNum = 0; - } - } else if (c == '-') { - if (ref) { - isNum = 2; - sign = -1; - pnumHead = p; - } else { - err = ERR_INVALID_GROUP_NAME; - // isNum = 0; - } - } else if (!EncodingHelper.isWord(c)) { - err = ERR_INVALID_CHAR_IN_GROUP_NAME; - } - } - - if (err == null) { - while (left()) { - nameEnd = p; - fetch(); - if (c == endCode || c == ')') { - if (isNum == 2) err = ERR_INVALID_GROUP_NAME; - break; - } - - if (isNum != 0) { - if (EncodingHelper.isDigit(c)) { - isNum = 1; - } else { - if (!EncodingHelper.isWord(c)) { - err = ERR_INVALID_CHAR_IN_GROUP_NAME; - } else { - err = ERR_INVALID_GROUP_NAME; - } - // isNum = 0; - } - } else { - if (!EncodingHelper.isWord(c)) { - err = ERR_INVALID_CHAR_IN_GROUP_NAME; - } - } - } - - if (c != endCode) { - err = ERR_INVALID_GROUP_NAME; - nameEnd = stop; - } - - int backNum = 0; - if (isNum != 0) { - mark(); - p = pnumHead; - backNum = scanUnsignedNumber(); - restore(); - if (backNum < 0) { - newValueException(ERR_TOO_BIG_NUMBER); - } else if (backNum == 0) { - newValueException(ERR_INVALID_GROUP_NAME, src, nameEnd); - } - backNum *= sign; - } - value = nameEnd; - return backNum; - } else { - while (left()) { - nameEnd = p; - fetch(); - if (c == endCode || c == ')') break; - } - if (!left()) nameEnd = stop; - newValueException(err, src, nameEnd); - return 0; // not reached - } - } - // #else USE_NAMED_GROUP // make it return nameEnd! private final int fetchNameForNoNamedGroup(int startCode, boolean ref) { @@ -472,11 +277,7 @@ class Lexer extends ScannerSupport { } protected final int fetchName(int startCode, boolean ref) { - if (Config.USE_NAMED_GROUP) { - return fetchNameForNamedGroup(startCode, ref); - } else { - return fetchNameForNoNamedGroup(startCode, ref); - } + return fetchNameForNoNamedGroup(startCode, ref); } private boolean strExistCheckWithEsc(int[]s, int n, int bad) { @@ -519,26 +320,6 @@ class Lexer extends ScannerSupport { token.setPropNot(flag); } - private void fetchTokenInCCFor_p() { - int c2 = peek(); // !!! migrate to peekIs - if (c2 == '{' && syntax.op2EscPBraceCharProperty()) { - inc(); - token.type = TokenType.CHAR_PROPERTY; - token.setPropNot(c == 'P'); - - if (syntax.op2EscPBraceCircumflexNot()) { - c2 = fetchTo(); - if (c2 == '^') { - token.setPropNot(!token.getPropNot()); - } else { - unfetch(); - } - } - } else { - syntaxWarn(Warnings.INVALID_UNICODE_PROPERTY, (char)c); - } - } - private void fetchTokenInCCFor_x() { if (!left()) return; int last = p; @@ -604,30 +385,6 @@ class Lexer extends ScannerSupport { } } - private void fetchTokenInCCFor_posixBracket() { - if (syntax.opPosixBracket() && peekIs(':')) { - token.backP = p; /* point at '[' is readed */ - inc(); - if (strExistCheckWithEsc(send, send.length, ']')) { - token.type = TokenType.POSIX_BRACKET_OPEN; - } else { - unfetch(); - // remove duplication, goto cc_in_cc; - if (syntax.op2CClassSetOp()) { - token.type = TokenType.CC_CC_OPEN; - } else { - env.ccEscWarn("["); - } - } - } else { // cc_in_cc: - if (syntax.op2CClassSetOp()) { - token.type = TokenType.CC_CC_OPEN; - } else { - env.ccEscWarn("["); - } - } - } - private void fetchTokenInCCFor_and() { if (syntax.op2CClassSetOp() && left() && peekIs('&')) { inc(); @@ -683,10 +440,6 @@ class Lexer extends ScannerSupport { case 'H': if (syntax.op2EscHXDigit()) fetchTokenInCCFor_charType(true, CharacterType.XDIGIT); break; - case 'p': - case 'P': - fetchTokenInCCFor_p(); - break; case 'x': fetchTokenInCCFor_x(); break; @@ -714,18 +467,12 @@ class Lexer extends ScannerSupport { break; } // switch - } else if (c == '[') { - fetchTokenInCCFor_posixBracket(); } else if (c == '&') { fetchTokenInCCFor_and(); } return token.type; } - protected final int backrefRelToAbs(int relNo) { - return env.numMem + 1 + relNo; - } - private void fetchTokenFor_repeat(int lower, int upper) { token.type = TokenType.OP_REPEAT; token.setRepeatLower(lower); @@ -815,7 +562,6 @@ class Lexer extends ScannerSupport { token.setBackrefNum(1); token.setBackrefRef1(num); token.setBackrefByName(false); - if (Config.USE_BACKREF_WITH_LEVEL) token.setBackrefExistLevel(false); return; } @@ -845,76 +591,6 @@ class Lexer extends ScannerSupport { } } - private void fetchTokenFor_namedBackref() { - if (syntax.op2EscKNamedBackref()) { - if (left()) { - fetch(); - if (c =='<' || c == '\'') { - int last = p; - int backNum; - if (Config.USE_BACKREF_WITH_LEVEL) { - Ptr rbackNum = new Ptr(); - Ptr rlevel = new Ptr(); - token.setBackrefExistLevel(fetchNameWithLevel(c, rbackNum, rlevel)); - token.setBackrefLevel(rlevel.p); - backNum = rbackNum.p; - } else { - backNum = fetchName(c, true); - } // USE_BACKREF_AT_LEVEL - int nameEnd = value; // set by fetchNameWithLevel/fetchName - - if (backNum != 0) { - if (backNum < 0) { - backNum = backrefRelToAbs(backNum); - if (backNum <= 0) newValueException(ERR_INVALID_BACKREF); - } - - if (syntax.strictCheckBackref() && (backNum > env.numMem || env.memNodes == null)) { - newValueException(ERR_INVALID_BACKREF); - } - token.type = TokenType.BACKREF; - token.setBackrefByName(false); - token.setBackrefNum(1); - token.setBackrefRef1(backNum); - } else { - NameEntry e = env.reg.nameToGroupNumbers(chars, last, nameEnd); - if (e == null) newValueException(ERR_UNDEFINED_NAME_REFERENCE, last, nameEnd); - - if (syntax.strictCheckBackref()) { - if (e.backNum == 1) { - if (e.backRef1 > env.numMem || - env.memNodes == null || - env.memNodes[e.backRef1] == null) newValueException(ERR_INVALID_BACKREF); - } else { - for (int i=0; i env.numMem || - env.memNodes == null || - env.memNodes[e.backRefs[i]] == null) newValueException(ERR_INVALID_BACKREF); - } - } - } - - token.type = TokenType.BACKREF; - token.setBackrefByName(true); - - if (e.backNum == 1) { - token.setBackrefNum(1); - token.setBackrefRef1(e.backRef1); - } else { - token.setBackrefNum(e.backNum); - token.setBackrefRefs(e.backRefs); - } - } - } else { - unfetch(); - syntaxWarn(Warnings.INVALID_BACKREFERENCE); - } - } else { - syntaxWarn(Warnings.INVALID_BACKREFERENCE); - } - } - } - private void fetchTokenFor_subexpCall() { if (syntax.op2EscGSubexpCall()) { if (left()) { @@ -937,25 +613,6 @@ class Lexer extends ScannerSupport { } } - private void fetchTokenFor_charProperty() { - if (peekIs('{') && syntax.op2EscPBraceCharProperty()) { - inc(); - token.type = TokenType.CHAR_PROPERTY; - token.setPropNot(c == 'P'); - - if (syntax.op2EscPBraceCircumflexNot()) { - fetch(); - if (c == '^') { - token.setPropNot(!token.getPropNot()); - } else { - unfetch(); - } - } - } else { - syntaxWarn(Warnings.INVALID_UNICODE_PROPERTY, (char)c); - } - } - private void fetchTokenFor_metaChars() { if (c == syntax.metaCharTable.anyChar) { token.type = TokenType.ANYCHAR; @@ -1091,19 +748,6 @@ class Lexer extends ScannerSupport { case '0': fetchTokenFor_zero(); break; - case 'k': - if (Config.USE_NAMED_GROUP) fetchTokenFor_namedBackref(); - break; - case 'g': - if (Config.USE_SUBEXP_CALL) fetchTokenFor_subexpCall(); - break; - case 'Q': - if (syntax.op2EscCapitalQQuote()) token.type = TokenType.QUOTE_OPEN; - break; - case 'p': - case 'P': - fetchTokenFor_charProperty(); - break; default: unfetch(); @@ -1244,24 +888,6 @@ class Lexer extends ScannerSupport { } } - protected final int fetchCharPropertyToCType() { - mark(); - - while (left()) { - int last = p; - fetch(); - if (c == '}') { - String name = new String(chars, _p, last - _p); - return PosixBracket.propertyNameToCType(name); - } else if (c == '(' || c == ')' || c == '{' || c == '|') { - String name = new String(chars, _p, last - _p); - throw new JOniException(ERR_INVALID_CHAR_PROPERTY_NAME.replaceAll("%n", name)); - } - } - newInternalException(ERR_PARSER_BUG); - return 0; // not reached - } - protected final void syntaxWarn(String message, char c) { syntaxWarn(message.replace("<%n>", Character.toString(c))); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Matcher.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Matcher.java index 4aea4acb787..911b23b391e 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Matcher.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Matcher.java @@ -58,17 +58,10 @@ public abstract class Matcher extends IntHolder { // main matching method protected abstract int matchAt(int range, int sstart, int sprev); - protected abstract void stateCheckBuffInit(int strLength, int offset, int stateNum); - protected abstract void stateCheckBuffClear(); - public final Region getRegion() { return msaRegion; } - public final Region getEagerRegion() { - return msaRegion != null ? msaRegion : new Region(msaBegin, msaEnd); - } - public final int getBegin() { return msaBegin; } @@ -86,11 +79,6 @@ public abstract class Matcher extends IntHolder { public final int match(int at, int range, int option) { msaInit(option, at); - if (Config.USE_COMBINATION_EXPLOSION_CHECK) { - int offset = at = str; - stateCheckBuffInit(end - str, offset, regex.numCombExpCheck); // move it to construction? - } // USE_COMBINATION_EXPLOSION_CHECK - int prev = EncodingHelper.prevCharHead(str, at); if (Config.USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE) { @@ -377,8 +365,6 @@ public abstract class Matcher extends IntHolder { prev = -1; msaInit(option, start); - if (Config.USE_COMBINATION_EXPLOSION_CHECK) stateCheckBuffClear(); - if (matchCheck(end, s, prev)) return match(s); return mismatch(); } @@ -393,10 +379,6 @@ public abstract class Matcher extends IntHolder { } msaInit(option, origStart); - if (Config.USE_COMBINATION_EXPLOSION_CHECK) { - int offset = Math.min(start, range) - str; - stateCheckBuffInit(end - str, offset, regex.numCombExpCheck); - } s = start; if (range > start) { /* forward search */ diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/NameEntry.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/NameEntry.java deleted file mode 100644 index d35f725155e..00000000000 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/NameEntry.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package jdk.nashorn.internal.runtime.regexp.joni; - -public final class NameEntry { - static final int INIT_NAME_BACKREFS_ALLOC_NUM = 8; - - public final char[] name; - public final int nameP; - public final int nameEnd; - - int backNum; - int backRef1; - int backRefs[]; - - public NameEntry(char[] chars, int p, int end) { - name = chars; - nameP = p; - nameEnd = end; - } - - public int[] getBackRefs() { - switch (backNum) { - case 0: - return new int[]{}; - case 1: - return new int[]{backRef1}; - default: - int[]result = new int[backNum]; - System.arraycopy(backRefs, 0, result, 0, backNum); - return result; - } - } - - private void alloc() { - backRefs = new int[INIT_NAME_BACKREFS_ALLOC_NUM]; - } - - private void ensureSize() { - if (backNum > backRefs.length) { - int[]tmp = new int[backRefs.length << 1]; - System.arraycopy(backRefs, 0, tmp, 0, backRefs.length); - backRefs = tmp; - } - } - - public void addBackref(int backRef) { - backNum++; - - switch (backNum) { - case 1: - backRef1 = backRef; - break; - case 2: - alloc(); - backRefs[0] = backRef1; - backRefs[1] = backRef; - break; - default: - ensureSize(); - backRefs[backNum - 1] = backRef; - } - } - - public String toString() { - StringBuilder buff = new StringBuilder(new String(name, nameP, nameEnd - nameP) + " "); - if (backNum == 0) { - buff.append("-"); - } else if (backNum == 1){ - buff.append(backRef1); - } else { - for (int i=0; i 0) buff.append(", "); - buff.append(backRefs[i]); - } - } - return buff.toString(); - } - -} diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/NativeMachine.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/NativeMachine.java deleted file mode 100644 index 2a3f2a13144..00000000000 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/NativeMachine.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package jdk.nashorn.internal.runtime.regexp.joni; - -public abstract class NativeMachine extends Matcher { - - protected NativeMachine(Regex regex, char[] chars, int p, int end) { - super(regex, chars, p, end); - } -} diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java index 13d569b7b08..749b1d4196d 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java @@ -19,20 +19,15 @@ */ package jdk.nashorn.internal.runtime.regexp.joni; -import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsOnAtSimple; import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsOnOff; import static jdk.nashorn.internal.runtime.regexp.joni.Option.isDontCaptureGroup; import static jdk.nashorn.internal.runtime.regexp.joni.Option.isIgnoreCase; import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; -import jdk.nashorn.internal.runtime.regexp.joni.encoding.PosixBracket; -import jdk.nashorn.internal.runtime.regexp.joni.encoding.Ptr; import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.AnyCharNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.CTypeNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.CallNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; @@ -66,65 +61,6 @@ class Parser extends Lexer { return root; } - private static final int POSIX_BRACKET_NAME_MIN_LEN = 4; - private static final int POSIX_BRACKET_CHECK_LIMIT_LENGTH = 20; - private static final char BRACKET_END[] = ":]".toCharArray(); - private boolean parsePosixBracket(CClassNode cc) { - mark(); - - boolean not; - if (peekIs('^')) { - inc(); - not = true; - } else { - not = false; - } - if (stop - p >= POSIX_BRACKET_NAME_MIN_LEN + 3) { // else goto not_posix_bracket - char[][] pbs = PosixBracket.PBSNamesLower; - for (int i=0; i POSIX_BRACKET_CHECK_LIMIT_LENGTH) break; - } - - if (c == ':' && left()) { - inc(); - if (left()) { - fetch(); - if (c == ']') newSyntaxException(ERR_INVALID_POSIX_BRACKET_TYPE); - } - } - restore(); - return true; /* 1: is not POSIX bracket, but no error. */ - } - - private CClassNode parseCharProperty() { - int ctype = fetchCharPropertyToCType(); - CClassNode n = new CClassNode(); - n.addCType(ctype, false, env, this); - if (token.getPropNot()) n.setNot(); - return n; - } - private boolean codeExistCheck(int code, boolean ignoreEscaped) { mark(); @@ -225,29 +161,11 @@ class Parser extends Lexer { parseCharClassValEntry(cc, arg); // val_entry:, val_entry2 break; - case POSIX_BRACKET_OPEN: - if (parsePosixBracket(cc)) { /* true: is not POSIX bracket */ - env.ccEscWarn("["); - p = token.backP; - arg.v = token.getC(); - arg.vIsRaw = false; - parseCharClassValEntry(cc, arg); // goto val_entry - break; - } - cc.nextStateClass(arg, env); // goto next_class - break; - case CHAR_TYPE: cc.addCType(token.getPropCType(), token.getPropNot(), env, this); cc.nextStateClass(arg, env); // next_class: break; - case CHAR_PROPERTY: - int ctype = fetchCharPropertyToCType(); - cc.addCType(ctype, token.getPropNot(), env, this); - cc.nextStateClass(arg, env); // goto next_class - break; - case CC_RANGE: if (arg.state == CCSTATE.VALUE) { fetchTokenInCC(); @@ -413,15 +331,6 @@ class Parser extends Lexer { node = new EncloseNode(EncloseType.STOP_BACKTRACK); // node_new_enclose break; case '\'': - if (Config.USE_NAMED_GROUP) { - if (syntax.op2QMarkLtNamedGroup()) { - listCapture = false; // goto named_group1 - node = parseEncloseNamedGroup2(listCapture); - break; - } else { - newSyntaxException(ERR_UNDEFINED_GROUP_OPTION); - } - } // USE_NAMED_GROUP break; case '<': /* look behind (?<=...), (?...) */ - } - unfetch(); - } - } // USE_NAMED_GROUP - EncloseNode en = new EncloseNode(env.option, false); // node_new_enclose_memory + EncloseNode en = new EncloseNode(); // node_new_enclose_memory int num = env.addMemEntry(); if (num >= BitStatus.BIT_STATUS_BITS_NUM) newValueException(ERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY); en.regNum = num; @@ -546,7 +431,7 @@ class Parser extends Lexer { returnCode = 1; /* group */ return node; } - EncloseNode en = new EncloseNode(env.option, false); // node_new_enclose_memory + EncloseNode en = new EncloseNode(); // node_new_enclose_memory int num = env.addMemEntry(); en.regNum = num; node = en; @@ -570,48 +455,6 @@ class Parser extends Lexer { return node; // ?? } - private Node parseEncloseNamedGroup2(boolean listCapture) { - int nm = p; - int num = fetchName(c, false); - int nameEnd = value; - num = env.addMemEntry(); - if (listCapture && num >= BitStatus.BIT_STATUS_BITS_NUM) newValueException(ERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY); - - regex.nameAdd(chars, nm, nameEnd, num, syntax); - EncloseNode en = new EncloseNode(env.option, true); // node_new_enclose_memory - en.regNum = num; - - Node node = en; - - if (listCapture) env.captureHistory = bsOnAtSimple(env.captureHistory, num); - env.numNamed++; - return node; - } - - private int findStrPosition(int[]s, int n, int from, int to, Ptr nextChar) { - int x; - int q; - int p = from; - int i = 0; - while (p < to) { - x = chars[p]; - q = p + 1; - if (x == s[0]) { - for (i=1; i= n) { - if (chars[nextChar.p] != 0) nextChar.p = q; // we may need zero term semantics... - return p; - } - } - p = q; - } - return -1; - } - private Node parseExp(TokenType term) { if (token.type == term) return StringNode.EMPTY; // goto end_of_token @@ -656,16 +499,6 @@ class Parser extends Lexer { node = new StringNode(buf, 0, 1); break; - case QUOTE_OPEN: - int[] endOp = new int[] {syntax.metaCharTable.esc, 'E'}; - int qstart = p; - Ptr nextChar = new Ptr(); - int qend = findStrPosition(endOp, endOp.length, qstart, stop, nextChar); - if (qend == -1) nextChar.p = qend = stop; - node = new StringNode(chars, qstart, qend); - p = nextChar.p; - break; - case CHAR_TYPE: switch(token.getPropCType()) { case CharacterType.D: @@ -679,10 +512,6 @@ class Parser extends Lexer { } break; - case CharacterType.WORD: - node = new CTypeNode(token.getPropCType(), token.getPropNot()); - break; - case CharacterType.SPACE: case CharacterType.DIGIT: case CharacterType.XDIGIT: @@ -699,10 +528,6 @@ class Parser extends Lexer { } // inner switch break; - case CHAR_PROPERTY: - node = parseCharProperty(); - break; - case CC_CC_OPEN: CClassNode cc = parseCharClass(); node = cc; @@ -735,20 +560,6 @@ class Parser extends Lexer { token.getBackrefExistLevel(), // #ifdef USE_BACKREF_AT_LEVEL token.getBackrefLevel(), // ... env); - - break; - - case CALL: - if (Config.USE_SUBEXP_CALL) { - int gNum = token.getCallGNum(); - - if (gNum < 0) { - gNum = backrefRelToAbs(gNum); - if (gNum <= 0) newValueException(ERR_INVALID_BACKREF); - } - node = new CallNode(chars, token.getCallNameP(), token.getCallNameEnd(), gNum); - env.numCall++; - } // USE_SUBEXP_CALL break; case ANCHOR: diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Regex.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Regex.java index da5b98271b7..b27814a71ce 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Regex.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Regex.java @@ -23,9 +23,11 @@ import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsAt; import static jdk.nashorn.internal.runtime.regexp.joni.Option.isCaptureGroup; import static jdk.nashorn.internal.runtime.regexp.joni.Option.isDontCaptureGroup; +import java.nio.file.Files; import java.util.HashMap; import java.util.Iterator; +import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; import jdk.nashorn.internal.runtime.regexp.joni.constants.AnchorType; import jdk.nashorn.internal.runtime.regexp.joni.constants.RegexState; import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; @@ -44,7 +46,6 @@ public final class Regex implements RegexState { int numMem; /* used memory(...) num counted from 1 */ int numRepeat; /* OP_REPEAT/OP_REPEAT_NG id-counter */ int numNullCheck; /* OP_NULL_CHECK_START/END id counter */ - int numCombExpCheck; /* combination explosion check */ int numCall; /* number of subexp call */ int captureHistory; /* (?@...) flag (1-31) */ int btMemStart; /* need backtrack flag */ @@ -57,7 +58,7 @@ public final class Regex implements RegexState { WarnCallback warnings; MatcherFactory factory; - private Analyser analyser; + protected Analyser analyser; int options; int userOptions; @@ -65,8 +66,6 @@ public final class Regex implements RegexState { //final Syntax syntax; final int caseFoldFlag; - HashMap nameTable; // named entries - /* optimization info (string search, char-map and anchors) */ SearchAlgorithm searchAlgorithm; /* optimize flag */ int thresholdLength; /* search str-length for apply optimize */ @@ -172,112 +171,6 @@ public final class Regex implements RegexState { return numMem; } - public int numberOfCaptureHistories() { - if (Config.USE_CAPTURE_HISTORY) { - int n = 0; - for (int i=0; i<=Config.MAX_CAPTURE_HISTORY_GROUP; i++) { - if (bsAt(captureHistory, i)) n++; - } - return n; - } else { - return 0; - } - } - - String nameTableToString() { - StringBuilder sb = new StringBuilder(); - - if (nameTable != null) { - sb.append("name table\n"); - for (NameEntry ne : nameTable.values()) { - sb.append(" " + ne + "\n"); - } - sb.append("\n"); - } - return sb.toString(); - } - - NameEntry nameFind(char[] name, int nameP, int nameEnd) { - if (nameTable != null) return nameTable.get(new String(name, nameP, nameEnd - nameP)); - return null; - } - - void renumberNameTable(int[]map) { - if (nameTable != null) { - for (NameEntry e : nameTable.values()) { - if (e.backNum > 1) { - for (int i=0; i(); // 13, oni defaults to 5 - } else { - e = nameFind(name, nameP, nameEnd); - } - - if (e == null) { - // dup the name here as oni does ?, what for ? (it has to manage it, we don't) - e = new NameEntry(name, nameP, nameEnd); - nameTable.put(new String(name, nameP, nameEnd - nameP), e); - } else if (e.backNum >= 1 && !syntax.allowMultiplexDefinitionName()) { - throw new ValueException(ErrorMessages.ERR_MULTIPLEX_DEFINED_NAME, new String(name, nameP, nameEnd - nameP)); - } - - e.addBackref(backRef); - } - - NameEntry nameToGroupNumbers(char[] name, int nameP, int nameEnd) { - return nameFind(name, nameP, nameEnd); - } - - public int nameToBackrefNumber(char[] name, int nameP, int nameEnd, Region region) { - NameEntry e = nameToGroupNumbers(name, nameP, nameEnd); - if (e == null) throw new ValueException(ErrorMessages.ERR_UNDEFINED_NAME_REFERENCE, - new String(name, nameP, nameEnd - nameP)); - - switch(e.backNum) { - case 0: - throw new InternalException(ErrorMessages.ERR_PARSER_BUG); - case 1: - return e.backRef1; - default: - if (region != null) { - for (int i = e.backNum - 1; i >= 0; i--) { - if (region.beg[e.backRefs[i]] != Region.REGION_NOTPOS) return e.backRefs[i]; - } - } - return e.backRefs[e.backNum - 1]; - } - } - - public Iterator namedBackrefIterator() { - return nameTable.values().iterator(); - } - - public boolean noNameGroupIsActive(Syntax syntax) { - if (isDontCaptureGroup(options)) return false; - - if (Config.USE_NAMED_GROUP) { - if (numberOfNames() > 0 && syntax.captureOnlyNamedGroup() && !isCaptureGroup(options)) return false; - } - return true; - } - /* set skip map for Boyer-Moor search */ void setupBMSkipMap() { char[] chars = exact; @@ -353,16 +246,6 @@ public final class Regex implements RegexState { exactP = exactEnd = 0; } - public String encStringToString(byte[]bytes, int p, int end) { - StringBuilder sb = new StringBuilder("\nPATTERN: /"); - - while (p < end) { - sb.append(new String(new byte[]{bytes[p]})); - p++; - } - return sb.append("/").toString(); - } - public String optimizeInfoToString() { String s = ""; s += "optimize: " + searchAlgorithm.getName() + "\n"; @@ -410,19 +293,13 @@ public final class Regex implements RegexState { return options; } - public void setUserOptions(int options) { - this.userOptions = options; + public String dumpTree() { + return analyser == null ? null : analyser.root.toString(); } - public int getUserOptions() { - return userOptions; + public String dumpByteCode() { + compile(); + return new ByteCodePrinter(this).byteCodeListToString(); } - public void setUserObject(Object object) { - this.userObject = object; - } - - public Object getUserObject() { - return userObject; - } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Region.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Region.java index d685a249593..ee9eb16810b 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Region.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Region.java @@ -25,7 +25,6 @@ public final class Region { public final int numRegs; public final int[]beg; public final int[]end; - public CaptureTreeNode historyRoot; public Region(int num) { this.numRegs = num; @@ -33,20 +32,6 @@ public final class Region { this.end = new int[num]; } - public Region(int begin, int end) { - this.numRegs = 1; - this.beg = new int[]{begin}; - this.end = new int[]{end}; - } - - public Region clone() { - Region region = new Region(numRegs); - System.arraycopy(beg, 0, region.beg, 0, beg.length); - System.arraycopy(end, 0, region.end, 0, end.length); - if (historyRoot != null) region.historyRoot = historyRoot.cloneTree(); - return region; - } - public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Region: \n"); @@ -54,10 +39,6 @@ public final class Region { return sb.toString(); } - CaptureTreeNode getCaptureTree() { - return historyRoot; - } - void clear() { for (int i=0; i 0 && strLength >= Config.CHECK_STRING_THRESHOLD_LEN) { - int size = ((strLength + 1) * stateNum + 7) >>> 3; - offset = (offset * stateNum) >>> 3; - - if (size > 0 && offset < size && size < Config.CHECK_BUFF_MAX_SIZE) { - if (size >= STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE) { - stateCheckBuff = new byte[size]; - } else { - // same impl, reduce... - stateCheckBuff = new byte[size]; - } - Arrays.fill(stateCheckBuff, offset, (size - offset), (byte)0); - stateCheckBuffSize = size; - } else { - stateCheckBuff = null; // reduce - stateCheckBuffSize = 0; - } - } else { - stateCheckBuff = null; // reduce - stateCheckBuffSize = 0; - } - } - - protected final void stateCheckBuffClear() { - stateCheckBuff = null; - stateCheckBuffSize = 0; - } - private void push(int type, int pat, int s, int prev) { StackEntry e = ensure1(); e.type = type; e.setStatePCode(pat); e.setStatePStr(s); e.setStatePStrPrev(prev); - if (Config.USE_COMBINATION_EXPLOSION_CHECK) e.setStateCheck(0); stk++; } @@ -172,30 +112,9 @@ abstract class StackMachine extends Matcher implements StackType { StackEntry e = stack[stk]; e.type = type; e.setStatePCode(pat); - if (Config.USE_COMBINATION_EXPLOSION_CHECK) e.setStateCheck(0); stk++; } - protected final void pushAltWithStateCheck(int pat, int s, int sprev, int snum) { - StackEntry e = ensure1(); - e.type = ALT; - e.setStatePCode(pat); - e.setStatePStr(s); - e.setStatePStrPrev(sprev); - if (Config.USE_COMBINATION_EXPLOSION_CHECK) e.setStateCheck(stateCheckBuff != null ? snum : 0); - stk++; - } - - protected final void pushStateCheck(int s, int snum) { - if (stateCheckBuff != null) { - StackEntry e = ensure1(); - e.type = STATE_CHECK_MARK; - e.setStatePStr(s); - e.setStateCheck(snum); - stk++; - } - } - protected final void pushAlt(int pat, int s, int prev) { push(ALT, pat, s, prev); } @@ -294,19 +213,6 @@ abstract class StackMachine extends Matcher implements StackType { stk++; } - protected final void pushCallFrame(int pat) { - StackEntry e = ensure1(); - e.type = CALL_FRAME; - e.setCallFrameRetAddr(pat); - stk++; - } - - protected final void pushReturn() { - StackEntry e = ensure1(); - e.type = RETURN; - stk++; - } - // stack debug routines here // ... @@ -331,8 +237,6 @@ abstract class StackMachine extends Matcher implements StackType { if ((e.type & MASK_POP_USED) != 0) { return e; - } else if (Config.USE_COMBINATION_EXPLOSION_CHECK) { - if (e.type == STATE_CHECK_MARK) stateCheckMark(); } } } @@ -346,8 +250,6 @@ abstract class StackMachine extends Matcher implements StackType { } else if (e.type == MEM_START) { repeatStk[memStartStk + e.getMemNum()] = e.getMemStart(); repeatStk[memEndStk + e.getMemNum()] = e.getMemEnd(); - } else if (Config.USE_COMBINATION_EXPLOSION_CHECK) { - if (e.type == STATE_CHECK_MARK) stateCheckMark(); } } } @@ -368,8 +270,6 @@ abstract class StackMachine extends Matcher implements StackType { } else if (e.type == MEM_END) { repeatStk[memStartStk + e.getMemNum()] = e.getMemStart(); repeatStk[memEndStk + e.getMemNum()] = e.getMemEnd(); - } else if (Config.USE_COMBINATION_EXPLOSION_CHECK) { - if (e.type == STATE_CHECK_MARK) stateCheckMark(); } } } @@ -391,8 +291,6 @@ abstract class StackMachine extends Matcher implements StackType { } else if (e.type == MEM_END){ repeatStk[memStartStk + e.getMemNum()] = e.getMemStart(); repeatStk[memEndStk + e.getMemNum()] = e.getMemStart(); - } else if (Config.USE_COMBINATION_EXPLOSION_CHECK) { - if (e.type == STATE_CHECK_MARK) stateCheckMark(); } } } @@ -414,8 +312,6 @@ abstract class StackMachine extends Matcher implements StackType { } else if (e.type == MEM_END) { repeatStk[memStartStk + e.getMemNum()] = e.getMemStart(); repeatStk[memEndStk + e.getMemNum()] = e.getMemEnd(); - } else if (Config.USE_COMBINATION_EXPLOSION_CHECK) { - if (e.type == STATE_CHECK_MARK) stateCheckMark(); } } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Syntax.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Syntax.java index 07b52626eda..518a416e7fb 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Syntax.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Syntax.java @@ -609,7 +609,7 @@ public final class Syntax implements SyntaxProperties{ OP_ESC_CONTROL_CHARS | OP_ESC_C_CONTROL | OP_ESC_X_HEX2) & ~OP_ESC_LTGT_WORD_BEGIN_END ), - ( OP2_QMARK_GROUP_EFFECT | OP2_CCLASS_SET_OP | + ( OP2_QMARK_GROUP_EFFECT | OP2_ESC_V_VTAB | OP2_ESC_U_HEX4 ), ( GNU_REGEX_BV | DIFFERENT_LEN_ALT_LOOK_BEHIND ), diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/UnsetAddrList.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/UnsetAddrList.java deleted file mode 100644 index ca72e16742f..00000000000 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/UnsetAddrList.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package jdk.nashorn.internal.runtime.regexp.joni; - -import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; -import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; -import jdk.nashorn.internal.runtime.regexp.joni.exception.InternalException; - -public final class UnsetAddrList { - int num; - Node[]targets; - int[]offsets; - - public UnsetAddrList(int size) { - targets = new Node[size]; - offsets = new int[size]; - } - - public void add(int offset, Node node) { - if (num >= offsets.length) { - Node []ttmp = new Node[targets.length << 1]; - System.arraycopy(targets, 0, ttmp, 0, num); - targets = ttmp; - int[]otmp = new int[offsets.length << 1]; - System.arraycopy(offsets, 0, otmp, 0, num); - offsets = otmp; - } - targets[num] = node; - offsets[num] = offset; - - num++; - } - - public void fix(Regex regex) { - for (int i=0; i 0) { - for (int i=0; i set, WarnCallback warnings) { - if (target == null || target.parent == this) - warnings.warn(this.getAddressName() + " doesn't point to a target or the target has been stolen"); - // do not recurse here - } - - @Override - public String toString(int level) { - StringBuilder value = new StringBuilder(super.toString(level)); - value.append("\n name: " + new String(name, nameP, nameEnd - nameP)); - value.append("\n groupNum: " + groupNum); - value.append("\n target: " + pad(target.getAddressName(), level + 1)); - value.append("\n unsetAddrList: " + pad(unsetAddrList, level + 1)); - - return value.toString(); - } - -} diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/EncloseNode.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/EncloseNode.java index a60afb1d1d6..1c5bfe7d89d 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/EncloseNode.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/EncloseNode.java @@ -25,7 +25,7 @@ import jdk.nashorn.internal.runtime.regexp.joni.constants.EncloseType; public final class EncloseNode extends StateNode implements EncloseType { - public int type; // enclose type + public final int type; // enclose type public int regNum; public int option; public Node target; /* EncloseNode : ENCLOSE_MEMORY */ @@ -42,10 +42,8 @@ public final class EncloseNode extends StateNode implements EncloseType { } // node_new_enclose_memory - public EncloseNode(int option, boolean isNamed) { + public EncloseNode() { this(MEMORY); - if (isNamed) setNamedGroup(); - if (Config.USE_SUBEXP_CALL) this.option = option; } // node_new_option @@ -104,46 +102,14 @@ public final class EncloseNode extends StateNode implements EncloseType { return types.toString(); } - public void setEncloseStatus(int flag) { - state |= flag; - } - - public void clearEncloseStatus(int flag) { - state &= ~flag; - } - - public void clearMemory() { - type &= ~MEMORY; - } - - public void setMemory() { - type |= MEMORY; - } - public boolean isMemory() { return (type & MEMORY) != 0; } - public void clearOption() { - type &= ~OPTION; - } - - public void setOption() { - type |= OPTION; - } - public boolean isOption() { return (type & OPTION) != 0; } - public void clearStopBacktrack() { - type &= ~STOP_BACKTRACK; - } - - public void setStopBacktrack() { - type |= STOP_BACKTRACK; - } - public boolean isStopBacktrack() { return (type & STOP_BACKTRACK) != 0; } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/QuantifierNode.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/QuantifierNode.java index 26cde98506f..c87de29d74a 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/QuantifierNode.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/QuantifierNode.java @@ -21,9 +21,10 @@ package jdk.nashorn.internal.runtime.regexp.joni.ast; import jdk.nashorn.internal.runtime.regexp.joni.Config; import jdk.nashorn.internal.runtime.regexp.joni.ScanEnvironment; -import jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce; import jdk.nashorn.internal.runtime.regexp.joni.constants.TargetInfo; +import static jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode.ReduceType.*; + public final class QuantifierNode extends StateNode { public Node target; @@ -37,8 +38,33 @@ public final class QuantifierNode extends StateNode { public Node nextHeadExact; public boolean isRefered; /* include called node. don't eliminate even if {0} */ - // USE_COMBINATION_EXPLOSION_CHECK - public int combExpCheckNum; /* 1,2,3...: check, 0: no check */ + enum ReduceType { + ASIS, /* as is */ + DEL, /* delete parent */ + A, /* to '*' */ + AQ, /* to '*?' */ + QQ, /* to '??' */ + P_QQ, /* to '+)??' */ + PQ_Q, /* to '+?)?' */ + } + + private final static ReduceType[][] REDUCE_TABLE = { + {DEL, A, A, QQ, AQ, ASIS}, /* '?' */ + {DEL, DEL, DEL, P_QQ, P_QQ, DEL}, /* '*' */ + {A, A, DEL, ASIS, P_QQ, DEL}, /* '+' */ + {DEL, AQ, AQ, DEL, AQ, AQ}, /* '??' */ + {DEL, DEL, DEL, DEL, DEL, DEL}, /* '*?' */ + {ASIS, PQ_Q, DEL, AQ, AQ, DEL} /* '+?' */ + }; + + private final static String PopularQStr[] = new String[] { + "?", "*", "+", "??", "*?", "+?" + }; + + private final static String ReduceQStr[]= new String[] { + "", "", "*", "*?", "??", "+ and ??", "+? and ?" + }; + public QuantifierNode(int lower, int upper, boolean byNumber) { this.lower = lower; @@ -92,7 +118,6 @@ public final class QuantifierNode extends StateNode { value.append("\n headExact: " + pad(headExact, level + 1)); value.append("\n nextHeadExact: " + pad(nextHeadExact, level + 1)); value.append("\n isRefered: " + isRefered); - value.append("\n combExpCheckNum: " + combExpCheckNum); return value.toString(); } @@ -134,7 +159,6 @@ public final class QuantifierNode extends StateNode { headExact = other.headExact; nextHeadExact = other.nextHeadExact; isRefered = other.isRefered; - combExpCheckNum = other.combExpCheckNum; } public void reduceNestedQuantifier(QuantifierNode other) { @@ -143,7 +167,7 @@ public final class QuantifierNode extends StateNode { if (pnum < 0 || cnum < 0) return; - switch(Reduce.REDUCE_TABLE[cnum][pnum]) { + switch(REDUCE_TABLE[cnum][pnum]) { case DEL: // no need to set the parent here... // swap ? @@ -226,7 +250,7 @@ public final class QuantifierNode extends StateNode { if (Config.USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR) { if (!isByNumber() && !qnt.isByNumber() && env.syntax.warnReduntantNestedRepeat()) { - switch(Reduce.REDUCE_TABLE[targetQNum][nestQNum]) { + switch(REDUCE_TABLE[targetQNum][nestQNum]) { case ASIS: break; @@ -237,9 +261,9 @@ public final class QuantifierNode extends StateNode { default: env.reg.getWarnings().warn(new String(chars, p, end) + - " nested repeat operator " + Reduce.PopularQStr[targetQNum] + - " and " + Reduce.PopularQStr[nestQNum] + " was replaced with '" + - Reduce.ReduceQStr[Reduce.REDUCE_TABLE[targetQNum][nestQNum].ordinal()] + "'"); + " nested repeat operator " + PopularQStr[targetQNum] + + " and " + PopularQStr[nestQNum] + " was replaced with '" + + ReduceQStr[REDUCE_TABLE[targetQNum][nestQNum].ordinal()] + "'"); } } } // USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/StateNode.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/StateNode.java index 18101a4aed4..3f75f8630a8 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/StateNode.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ast/StateNode.java @@ -40,7 +40,6 @@ public abstract class StateNode extends Node implements NodeStatus { if (isRecursion()) states.append("RECURSION "); if (isCalled()) states.append("CALLED "); if (isAddrFixed()) states.append("ADDR_FIXED "); - if (isNamedGroup()) states.append("NAMED_GROUP "); if (isNameRef()) states.append("NAME_REF "); if (isInRepeat()) states.append("IN_REPEAT "); if (isNestLevel()) states.append("NEST_LEVEL "); @@ -57,10 +56,6 @@ public abstract class StateNode extends Node implements NodeStatus { state |= NST_MIN_FIXED; } - public void clearMinFixed() { - state &= ~NST_MIN_FIXED; - } - public boolean isMaxFixed() { return (state & NST_MAX_FIXED) != 0; } @@ -69,10 +64,6 @@ public abstract class StateNode extends Node implements NodeStatus { state |= NST_MAX_FIXED; } - public void clearMaxFixed() { - state &= ~NST_MAX_FIXED; - } - public boolean isCLenFixed() { return (state & NST_CLEN_FIXED) != 0; } @@ -81,10 +72,6 @@ public abstract class StateNode extends Node implements NodeStatus { state |= NST_CLEN_FIXED; } - public void clearCLenFixed() { - state &= ~NST_CLEN_FIXED; - } - public boolean isMark1() { return (state & NST_MARK1) != 0; } @@ -93,10 +80,6 @@ public abstract class StateNode extends Node implements NodeStatus { state |= NST_MARK1; } - public void clearMark1() { - state &= ~NST_MARK1; - } - public boolean isMark2() { return (state & NST_MARK2) != 0; } @@ -117,10 +100,6 @@ public abstract class StateNode extends Node implements NodeStatus { state |= NST_MEM_BACKREFED; } - public void clearMemBackrefed() { - state &= ~NST_MEM_BACKREFED; - } - public boolean isStopBtSimpleRepeat() { return (state & NST_STOP_BT_SIMPLE_REPEAT) != 0; } @@ -129,10 +108,6 @@ public abstract class StateNode extends Node implements NodeStatus { state |= NST_STOP_BT_SIMPLE_REPEAT; } - public void clearStopBtSimpleRepeat() { - state &= ~NST_STOP_BT_SIMPLE_REPEAT; - } - public boolean isRecursion() { return (state & NST_RECURSION) != 0; } @@ -141,10 +116,6 @@ public abstract class StateNode extends Node implements NodeStatus { state |= NST_RECURSION; } - public void clearRecursion() { - state &= ~NST_RECURSION; - } - public boolean isCalled() { return (state & NST_CALLED) != 0; } @@ -153,10 +124,6 @@ public abstract class StateNode extends Node implements NodeStatus { state |= NST_CALLED; } - public void clearCAlled() { - state &= ~NST_CALLED; - } - public boolean isAddrFixed() { return (state & NST_ADDR_FIXED) != 0; } @@ -165,22 +132,6 @@ public abstract class StateNode extends Node implements NodeStatus { state |= NST_ADDR_FIXED; } - public void clearAddrFixed() { - state &= ~NST_ADDR_FIXED; - } - - public boolean isNamedGroup() { - return (state & NST_NAMED_GROUP) != 0; - } - - public void setNamedGroup() { - state |= NST_NAMED_GROUP; - } - - public void clearNamedGroup() { - state &= ~NST_NAMED_GROUP; - } - public boolean isNameRef() { return (state & NST_NAME_REF) != 0; } @@ -189,10 +140,6 @@ public abstract class StateNode extends Node implements NodeStatus { state |= NST_NAME_REF; } - public void clearNameRef() { - state &= ~NST_NAME_REF; - } - public boolean isInRepeat() { return (state & NST_IN_REPEAT) != 0; } @@ -201,10 +148,6 @@ public abstract class StateNode extends Node implements NodeStatus { state |= NST_IN_REPEAT; } - public void clearInRepeat() { - state &= ~NST_IN_REPEAT; - } - public boolean isNestLevel() { return (state & NST_NEST_LEVEL) != 0; } @@ -213,10 +156,6 @@ public abstract class StateNode extends Node implements NodeStatus { state |= NST_NEST_LEVEL; } - public void clearNestLevel() { - state &= ~NST_NEST_LEVEL; - } - public boolean isByNumber() { return (state & NST_BY_NUMBER) != 0; } @@ -225,8 +164,4 @@ public abstract class StateNode extends Node implements NodeStatus { state |= NST_BY_NUMBER; } - public void clearByNumber() { - state &= ~NST_BY_NUMBER; - } - } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/bench/AbstractBench.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/bench/AbstractBench.java deleted file mode 100644 index 9751b51d5c0..00000000000 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/bench/AbstractBench.java +++ /dev/null @@ -1,49 +0,0 @@ -package jdk.nashorn.internal.runtime.regexp.joni.bench; - -import jdk.nashorn.internal.runtime.regexp.joni.Option; -import jdk.nashorn.internal.runtime.regexp.joni.Regex; -import jdk.nashorn.internal.runtime.regexp.joni.Syntax; - -public abstract class AbstractBench { - protected void bench(String _reg, String _str, int warmup, int times) throws Exception { - char[] reg = _reg.toCharArray(); - char[] str = _str.toCharArray(); - - Regex p = new Regex(reg,0,reg.length,Option.DEFAULT,Syntax.DEFAULT); - - System.err.println("::: /" + _reg + "/ =~ \"" + _str + "\", " + warmup + " * " + times + " times"); - - for(int j=0;j { public T p; - static final ObjPtr NULL = new ObjPtr(); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/PosixBracket.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/PosixBracket.java deleted file mode 100644 index 48978bf48ee..00000000000 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/PosixBracket.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS".toCharArray(), WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package jdk.nashorn.internal.runtime.regexp.joni.encoding; - -import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; -import jdk.nashorn.internal.runtime.regexp.joni.exception.JOniException; - -import java.util.HashMap; - -public class PosixBracket { - - public static final char[][] PBSNamesLower = { - "alnum".toCharArray(), - "alpha".toCharArray(), - "blank".toCharArray(), - "cntrl".toCharArray(), - "digit".toCharArray(), - "graph".toCharArray(), - "lower".toCharArray(), - "print".toCharArray(), - "punct".toCharArray(), - "space".toCharArray(), - "upper".toCharArray(), - "xdigit".toCharArray(), - "ascii".toCharArray(), - "word".toCharArray() - }; - - public static final int PBSValues[] = { - CharacterType.ALNUM, - CharacterType.ALPHA, - CharacterType.BLANK, - CharacterType.CNTRL, - CharacterType.DIGIT, - CharacterType.GRAPH, - CharacterType.LOWER, - CharacterType.PRINT, - CharacterType.PUNCT, - CharacterType.SPACE, - CharacterType.UPPER, - CharacterType.XDIGIT, - CharacterType.ASCII, - CharacterType.WORD, - }; - - public static int propertyNameToCType(String name) { - name = name.toLowerCase(); - if (!PBSTableUpper.containsKey(name)) { - throw new JOniException(ErrorMessages.ERR_INVALID_CHAR_PROPERTY_NAME.replaceAll("%n", name)); - } - return PBSTableUpper.get(name); - } - - private static final HashMap PBSTableUpper = new HashMap(); - - static { - for (int i=0; i" : "invalid char in group number <%n>"; - final String ERR_UNDEFINED_NAME_REFERENCE = "undefined name <%n> reference"; - final String ERR_UNDEFINED_GROUP_REFERENCE = "undefined group <%n> reference"; - final String ERR_MULTIPLEX_DEFINED_NAME = "multiplex defined name <%n>"; - final String ERR_MULTIPLEX_DEFINITION_NAME_CALL = "multiplex definition name <%n> call"; - final String ERR_NEVER_ENDING_RECURSION = "never ending recursion"; + final String ERR_INVALID_CHAR_IN_GROUP_NAME = "invalid char in group number <%n>"; final String ERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY = "group number is too big for capture history"; - final String ERR_NOT_SUPPORTED_ENCODING_COMBINATION = "not supported encoding combination"; final String ERR_INVALID_COMBINATION_OF_OPTIONS = "invalid combination of options"; - final String ERR_OVER_THREAD_PASS_LIMIT_COUNT = "over thread pass limit count"; - final String ERR_TOO_BIG_SB_CHAR_VALUE = "too big singlebyte char value"; } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ValueException.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ValueException.java index d56a35a4190..597fe221572 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ValueException.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ValueException.java @@ -30,8 +30,4 @@ public class ValueException extends SyntaxException{ super(message.replaceAll("%n", str)); } - public ValueException(String message, byte[]bytes, int p, int end) { - this(message, new String(bytes, p, end - p)); - } - } diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/JdkRegExpTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/JdkRegExpTest.java new file mode 100644 index 00000000000..c22838fb277 --- /dev/null +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/JdkRegExpTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2010, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.nashorn.internal.runtime.regexp; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import jdk.nashorn.internal.runtime.ParserException; +import org.testng.annotations.Test; + +/** + * Basic tests for the JDK based RegExp implementation. + * + * @test + * @run testng jdk.nashorn.internal.runtime.regexp.JdkRegExpTest + */ +public class JdkRegExpTest { + + /** + * Compile a regular expression using the JDK implementation + */ + @Test + public void testMatcher() { + RegExp regexp = new RegExpFactory().compile("f(o)o", ""); + RegExpMatcher matcher = regexp.match("foo"); + assertNotNull(matcher); + assertTrue(matcher.search(0)); + assertEquals(matcher.getInput(), "foo"); + assertEquals(matcher.groupCount(), 1); + assertEquals(matcher.group(), "foo"); + assertEquals(matcher.start(), 0); + assertEquals(matcher.end(), 3); + assertEquals(matcher.group(1), "o"); + assertEquals(matcher.start(1), 1); + assertEquals(matcher.end(1), 2); + } +} diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/joni/JoniTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/joni/JoniTest.java new file mode 100644 index 00000000000..a6981c8dc8c --- /dev/null +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/joni/JoniTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2010, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.nashorn.internal.runtime.regexp.joni; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import org.testng.annotations.Test; + +/** + * Joni coverage tests + * + * @test + * @run testng jdk.nashorn.internal.runtime.regexp.joni.JoniTest + */ +public class JoniTest { + + @Test + public void testDump() { + new Regex("^a{3,}(.*)[z]++\\s\\1x$").dumpTree(); + new Regex("^a{3,}(.*)[z]++\\s\\1x$").dumpByteCode(); + new Regex("(abc){4,}{2,5}").dumpTree(); + new Regex("(abc){4,}{2,5}").dumpByteCode(); + new Regex("aaa|aa|bbbb|ccc").dumpTree(); + new Regex("aaa|aa|bbbb|ccc").dumpByteCode(); + new Regex("(?:ZFVR.(\\d+\\.\\d+))|(?:(?:Sversbk|TenaCnenqvfb|Vprjrnfry).(\\d+\\.\\d+))|(?:Bcren.(\\d+\\.\\d+))|(?:NccyrJroXvg.(\\d+(?:\\.\\d+)?))").dumpTree(); + new Regex("(?:ZFVR.(\\d+\\.\\d+))|(?:(?:Sversbk|TenaCnenqvfb|Vprjrnfry).(\\d+\\.\\d+))|(?:Bcren.(\\d+\\.\\d+))|(?:NccyrJroXvg.(\\d+(?:\\.\\d+)?))").dumpByteCode(); + } +} From e0fcb74c7e43171e3425503ba4e250b2884d6b26 Mon Sep 17 00:00:00 2001 From: Konstantin Shefov Date: Fri, 17 May 2013 16:44:22 -0300 Subject: [PATCH 018/206] 8014823: Reprise - Smoke test fail: Windows JDK-8008554.js - access denied ("java.io.FilePermission" "//C/aurora/sandbox/nashorn~source/test/script/basic/NASHORN-99.js" "read") Reviewed-by: jlaskey --- nashorn/test/script/basic/JDK-8008554.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nashorn/test/script/basic/JDK-8008554.js b/nashorn/test/script/basic/JDK-8008554.js index 0cbe8b8e699..f8ec9587c34 100644 --- a/nashorn/test/script/basic/JDK-8008554.js +++ b/nashorn/test/script/basic/JDK-8008554.js @@ -32,5 +32,5 @@ var dir = __DIR__; var file = __FILE__.replace("JDK-8008554", "NASHORN-99"); load(file); -file = "file://" + __DIR__ + "NASHORN-99.js"; +file = "file:///" + __DIR__ + "NASHORN-99.js"; load(file); From f5bda14b93b9d4161af60d065f8d5a9295d05023 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 17 May 2013 13:48:41 -0700 Subject: [PATCH 019/206] 6885876: add comments to javac/util/Convert.java Reviewed-by: mduigou --- .../com/sun/tools/javac/util/Convert.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/Convert.java b/langtools/src/share/classes/com/sun/tools/javac/util/Convert.java index b2253aab2e7..c4725f3570a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/Convert.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/Convert.java @@ -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 @@ -28,6 +28,24 @@ package com.sun.tools.javac.util; /** Utility class for static conversion methods between numbers * and strings in various formats. * + *

    Note regarding UTF-8. + * The JVMS defines its own version of the UTF-8 format so that it + * contains no zero bytes (modified UTF-8). This is not actually the same + * as Charset.forName("UTF-8"). + * + *

    + * See also: + *

    + * + * The methods here support modified UTF-8. + * *

    This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. * This code and its internal interfaces are subject to change or From cc79bd12371e6df1dc416992e9ca01a5f989ae2d Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Mon, 20 May 2013 16:38:38 +0200 Subject: [PATCH 020/206] 8006069: Range analysis first iteration, runtime specializations Reviewed-by: jlaskey, sundar --- .../internal/codegen/CompilationPhase.java | 94 ++- .../nashorn/internal/codegen/Compiler.java | 7 +- .../internal/codegen/CompilerConstants.java | 2 +- .../internal/codegen/MethodEmitter.java | 9 +- .../internal/codegen/RangeAnalyzer.java | 474 ++++++++++++ .../nashorn/internal/codegen/types/Range.java | 705 ++++++++++++++++++ .../nashorn/internal/codegen/types/Type.java | 12 +- .../jdk/nashorn/internal/ir/BinaryNode.java | 17 + .../jdk/nashorn/internal/ir/FunctionNode.java | 2 +- .../nashorn/internal/ir/LexicalContext.java | 20 +- nashorn/src/jdk/nashorn/internal/ir/Node.java | 8 + .../src/jdk/nashorn/internal/ir/Symbol.java | 33 +- .../internal/runtime/CompiledFunction.java | 32 +- .../runtime/FinalScriptFunctionData.java | 4 +- .../RecompilableScriptFunctionData.java | 236 ++++-- .../internal/runtime/ScriptEnvironment.java | 6 +- .../internal/runtime/ScriptFunctionData.java | 5 +- .../runtime/resources/Options.properties | 6 + nashorn/test/script/basic/ranges_disabled.js | 32 + .../script/basic/ranges_disabled.js.EXPECTED | 4 + nashorn/test/script/basic/ranges_enabled.js | 33 + .../script/basic/ranges_enabled.js.EXPECTED | 4 + nashorn/test/script/basic/ranges_payload.js | 74 ++ 23 files changed, 1720 insertions(+), 99 deletions(-) create mode 100644 nashorn/src/jdk/nashorn/internal/codegen/RangeAnalyzer.java create mode 100644 nashorn/src/jdk/nashorn/internal/codegen/types/Range.java create mode 100644 nashorn/test/script/basic/ranges_disabled.js create mode 100644 nashorn/test/script/basic/ranges_disabled.js.EXPECTED create mode 100644 nashorn/test/script/basic/ranges_enabled.js create mode 100644 nashorn/test/script/basic/ranges_enabled.js.EXPECTED create mode 100644 nashorn/test/script/basic/ranges_payload.js diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java b/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java index bfc71cc2198..f2603393612 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java @@ -11,13 +11,21 @@ import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.SPLIT; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Deque; import java.util.EnumSet; import java.util.HashSet; +import java.util.List; import java.util.Set; + +import jdk.nashorn.internal.codegen.types.Range; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.Block; import jdk.nashorn.internal.ir.CallNode; import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.ReturnNode; +import jdk.nashorn.internal.ir.Symbol; import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.Node; @@ -174,7 +182,7 @@ enum CompilationPhase { FunctionNode transform(final Compiler compiler, final FunctionNode fn) { final TemporarySymbols ts = compiler.getTemporarySymbols(); final FunctionNode newFunctionNode = (FunctionNode)enterAttr(fn, ts).accept(new Attr(ts)); - if(compiler.getEnv()._print_mem_usage) { + if (compiler.getEnv()._print_mem_usage) { Compiler.LOG.info("Attr temporary symbol count: " + ts.getTotalSymbolCount()); } return newFunctionNode; @@ -207,6 +215,89 @@ enum CompilationPhase { } }, + /* + * Range analysis + * Conservatively prove that certain variables can be narrower than + * the most generic number type + */ + RANGE_ANALYSIS_PHASE(EnumSet.of(INITIALIZED, PARSED, CONSTANT_FOLDED, LOWERED, ATTR)) { + @Override + FunctionNode transform(final Compiler compiler, final FunctionNode fn) { + if (!compiler.getEnv()._range_analysis) { + return fn; + } + + FunctionNode newFunctionNode = (FunctionNode)fn.accept(new RangeAnalyzer()); + final List returns = new ArrayList<>(); + + newFunctionNode = (FunctionNode)newFunctionNode.accept(new NodeVisitor() { + private final Deque> returnStack = new ArrayDeque<>(); + + @Override + public boolean enterFunctionNode(final FunctionNode functionNode) { + returnStack.push(new ArrayList()); + return true; + } + + @Override + public Node leaveFunctionNode(final FunctionNode functionNode) { + Type returnType = Type.UNKNOWN; + for (final ReturnNode ret : returnStack.pop()) { + if (ret.getExpression() == null) { + returnType = Type.OBJECT; + break; + } + returnType = Type.widest(returnType, ret.getExpression().getType()); + } + return functionNode.setReturnType(getLexicalContext(), returnType); + } + + @Override + public Node leaveReturnNode(final ReturnNode returnNode) { + final ReturnNode result = (ReturnNode)leaveDefault(returnNode); + returns.add(result); + return result; + } + + @Override + public Node leaveDefault(final Node node) { + final Symbol symbol = node.getSymbol(); + if (symbol != null) { + final Range range = symbol.getRange(); + final Type symbolType = symbol.getSymbolType(); + if (!symbolType.isNumeric()) { + return node; + } + final Type rangeType = range.getType(); + if (!Type.areEquivalent(symbolType, rangeType) && Type.widest(symbolType, rangeType) == symbolType) { //we can narrow range + RangeAnalyzer.LOG.info("[", getLexicalContext().getCurrentFunction().getName(), "] ", symbol, " can be ", range.getType(), " ", symbol.getRange()); + return node.setSymbol(getLexicalContext(), symbol.setTypeOverrideShared(range.getType(), compiler.getTemporarySymbols())); + } + } + return node; + } + }); + + Type returnType = Type.UNKNOWN; + for (final ReturnNode node : returns) { + if (node.getExpression() != null) { + returnType = Type.widest(returnType, node.getExpression().getType()); + } else { + returnType = Type.OBJECT; + break; + } + } + + return newFunctionNode.setReturnType(null, returnType); + } + + @Override + public String toString() { + return "[Range Analysis]"; + } + }, + + /* * Splitter Split the AST into several compile units based on a size * heuristic Splitter needs attributed AST for weight calculations (e.g. is @@ -218,7 +309,6 @@ enum CompilationPhase { FunctionNode transform(final Compiler compiler, final FunctionNode fn) { final CompileUnit outermostCompileUnit = compiler.addCompileUnit(compiler.firstCompileUnitName()); -// assert fn.isProgram() ; final FunctionNode newFunctionNode = new Splitter(compiler, fn, outermostCompileUnit).split(fn); assert newFunctionNode.getCompileUnit() == outermostCompileUnit : "fn.compileUnit (" + newFunctionNode.getCompileUnit() + ") != " + outermostCompileUnit; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java index 81a76186ce8..faf7a3c5a09 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java @@ -99,7 +99,7 @@ public final class Compiler { private boolean strict; - private CodeInstaller installer; + private final CodeInstaller installer; private final TemporarySymbols temporarySymbols = new TemporarySymbols(); @@ -219,6 +219,7 @@ public final class Compiler { CompilationPhase.CONSTANT_FOLDING_PHASE, CompilationPhase.LOWERING_PHASE, CompilationPhase.ATTRIBUTION_PHASE, + CompilationPhase.RANGE_ANALYSIS_PHASE, CompilationPhase.SPLITTING_PHASE, CompilationPhase.TYPE_FINALIZATION_PHASE, CompilationPhase.BYTECODE_GENERATION_PHASE); @@ -384,6 +385,8 @@ public final class Compiler { if (info) { final StringBuilder sb = new StringBuilder(); sb.append("Compile job for '"). + append(newFunctionNode.getSource()). + append(':'). append(newFunctionNode.getName()). append("' finished"); @@ -487,7 +490,7 @@ public final class Compiler { } if (sb != null) { - LOG.info(sb); + LOG.fine(sb); } return rootClass; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CompilerConstants.java b/nashorn/src/jdk/nashorn/internal/codegen/CompilerConstants.java index 6912534dee6..d9c68ad8288 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CompilerConstants.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CompilerConstants.java @@ -262,7 +262,7 @@ public enum CompilerConstants { * @return the internal descriptor for this type */ public static String typeDescriptor(final Class clazz) { - return Type.getDescriptor(clazz); + return Type.typeFor(clazz).getDescriptor(); } /** diff --git a/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java b/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java index c156c865f69..4e07c4777dc 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java @@ -2081,7 +2081,9 @@ public class MethodEmitter implements Emitter { * @param args debug information to print */ private void debug(final Object... args) { - debug(30, args); + if (DEBUG) { + debug(30, args); + } } /** @@ -2091,7 +2093,9 @@ public class MethodEmitter implements Emitter { * @param args debug information to print */ private void debug_label(final Object... args) { - debug(26, args); + if (DEBUG) { + debug(22, args); + } } private void debug(final int padConstant, final Object... args) { @@ -2164,7 +2168,6 @@ public class MethodEmitter implements Emitter { new Throwable().printStackTrace(LOG.getOutputStream()); } } - } } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/RangeAnalyzer.java b/nashorn/src/jdk/nashorn/internal/codegen/RangeAnalyzer.java new file mode 100644 index 00000000000..1229caa1fea --- /dev/null +++ b/nashorn/src/jdk/nashorn/internal/codegen/RangeAnalyzer.java @@ -0,0 +1,474 @@ +/* + * Copyright (c) 2010, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.nashorn.internal.codegen; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +import jdk.nashorn.internal.codegen.types.Range; +import jdk.nashorn.internal.codegen.types.Type; +import jdk.nashorn.internal.ir.Assignment; +import jdk.nashorn.internal.ir.BinaryNode; +import jdk.nashorn.internal.ir.ForNode; +import jdk.nashorn.internal.ir.IdentNode; +import jdk.nashorn.internal.ir.LiteralNode; +import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; +import jdk.nashorn.internal.ir.LoopNode; +import jdk.nashorn.internal.ir.Node; +import jdk.nashorn.internal.ir.RuntimeNode; +import jdk.nashorn.internal.ir.Symbol; +import jdk.nashorn.internal.ir.UnaryNode; +import jdk.nashorn.internal.ir.VarNode; +import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor; +import jdk.nashorn.internal.ir.visitor.NodeVisitor; +import jdk.nashorn.internal.parser.TokenType; +import jdk.nashorn.internal.runtime.DebugLogger; + +/** + * Range analysis and narrowing of type where it can be proven + * that there is no spillover, e.g. + * + * function func(c) { + * var v = c & 0xfff; + * var w = c & 0xeee; + * var x = v * w; + * return x; + * } + * + * Proves that the multiplication never exceeds 24 bits and can thus be an int + */ +final class RangeAnalyzer extends NodeOperatorVisitor { + static final DebugLogger LOG = new DebugLogger("ranges"); + + private static final Range.Functionality RANGE = new Range.Functionality(LOG); + + private final Map loopCounters = new HashMap<>(); + + RangeAnalyzer() { + } + + @Override + public boolean enterForNode(final ForNode forNode) { + //conservatively attempt to identify the loop counter. Null means that it wasn't + //properly identified and that no optimizations can be made with it - its range is + //simply unknown in that case, if it is assigned in the loop + final Symbol counter = findLoopCounter(forNode); + LOG.fine("Entering forNode " + forNode + " counter = " + counter); + if (counter != null && !assignedInLoop(forNode, counter)) { + loopCounters.put(forNode, counter); + } + return true; + } + + //destination visited + private Symbol setRange(final Node dest, final Range range) { + if (range.isUnknown()) { + return null; + } + + final Symbol symbol = dest.getSymbol(); + assert symbol != null : dest + " " + dest.getClass() + " has no symbol"; + assert symbol.getRange() != null : symbol + " has no range"; + final Range symRange = RANGE.join(symbol.getRange(), range); + + //anything assigned in the loop, not being the safe loop counter(s) invalidates its entire range + if (getLexicalContext().inLoop() && !isLoopCounter(getLexicalContext().getCurrentLoop(), symbol)) { + symbol.setRange(Range.createGenericRange()); + return symbol; + } + + if (!symRange.equals(symbol.getRange())) { + LOG.fine("Modify range for " + dest + " " + symbol + " from " + symbol.getRange() + " to " + symRange + " (in node = " + dest + ")" ); + symbol.setRange(symRange); + } + + return null; + } + + @Override + public Node leaveADD(final BinaryNode node) { + setRange(node, RANGE.add(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + return node; + } + + @Override + public Node leaveSUB(final BinaryNode node) { + setRange(node, RANGE.sub(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + return node; + } + + @Override + public Node leaveMUL(final BinaryNode node) { + setRange(node, RANGE.mul(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + return node; + } + + @Override + public Node leaveDIV(final BinaryNode node) { + setRange(node, RANGE.div(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + return node; + } + + @Override + public Node leaveMOD(final BinaryNode node) { + setRange(node, RANGE.mod(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + return node; + } + + @Override + public Node leaveBIT_AND(final BinaryNode node) { + setRange(node, RANGE.and(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + return node; + } + + @Override + public Node leaveBIT_OR(final BinaryNode node) { + setRange(node, RANGE.or(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + return node; + } + + @Override + public Node leaveBIT_XOR(final BinaryNode node) { + setRange(node, RANGE.xor(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + return node; + } + + @Override + public Node leaveSAR(final BinaryNode node) { + setRange(node, RANGE.sar(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + return node; + } + + @Override + public Node leaveSHL(final BinaryNode node) { + setRange(node, RANGE.shl(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + return node; + } + + @Override + public Node leaveSHR(final BinaryNode node) { + setRange(node, RANGE.shr(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + return node; + } + + private Node leaveCmp(final BinaryNode node) { + setRange(node, Range.createTypeRange(Type.BOOLEAN)); + return node; + } + + @Override + public Node leaveEQ(final BinaryNode node) { + return leaveCmp(node); + } + + @Override + public Node leaveEQ_STRICT(final BinaryNode node) { + return leaveCmp(node); + } + + @Override + public Node leaveNE(final BinaryNode node) { + return leaveCmp(node); + } + + @Override + public Node leaveNE_STRICT(final BinaryNode node) { + return leaveCmp(node); + } + + @Override + public Node leaveLT(final BinaryNode node) { + return leaveCmp(node); + } + + @Override + public Node leaveLE(final BinaryNode node) { + return leaveCmp(node); + } + + @Override + public Node leaveGT(final BinaryNode node) { + return leaveCmp(node); + } + + @Override + public Node leaveGE(final BinaryNode node) { + return leaveCmp(node); + } + + @Override + public Node leaveASSIGN(final BinaryNode node) { + Range range = node.rhs().getSymbol().getRange(); + if (range.isUnknown()) { + range = Range.createGenericRange(); + } + + setRange(node.lhs(), range); + setRange(node, range); + + return node; + } + + private Node leaveSelfModifyingAssign(final BinaryNode node, final Range range) { + setRange(node.lhs(), range); + setRange(node, range); + return node; + } + + private Node leaveSelfModifyingAssign(final UnaryNode node, final Range range) { + setRange(node.rhs(), range); + setRange(node, range); + return node; + } + + @Override + public Node leaveASSIGN_ADD(final BinaryNode node) { + return leaveSelfModifyingAssign(node, RANGE.add(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + } + + @Override + public Node leaveASSIGN_SUB(final BinaryNode node) { + return leaveSelfModifyingAssign(node, RANGE.sub(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + } + + @Override + public Node leaveASSIGN_MUL(final BinaryNode node) { + return leaveSelfModifyingAssign(node, RANGE.mul(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + } + + @Override + public Node leaveASSIGN_DIV(final BinaryNode node) { + return leaveSelfModifyingAssign(node, Range.createTypeRange(Type.NUMBER)); + } + + @Override + public Node leaveASSIGN_MOD(final BinaryNode node) { + return leaveSelfModifyingAssign(node, Range.createTypeRange(Type.NUMBER)); + } + + @Override + public Node leaveASSIGN_BIT_AND(final BinaryNode node) { + return leaveSelfModifyingAssign(node, RANGE.and(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + } + + @Override + public Node leaveASSIGN_BIT_OR(final BinaryNode node) { + return leaveSelfModifyingAssign(node, RANGE.or(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + } + + @Override + public Node leaveASSIGN_BIT_XOR(final BinaryNode node) { + return leaveSelfModifyingAssign(node, RANGE.xor(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + } + + @Override + public Node leaveASSIGN_SAR(final BinaryNode node) { + return leaveSelfModifyingAssign(node, RANGE.sar(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + } + + @Override + public Node leaveASSIGN_SHR(final BinaryNode node) { + return leaveSelfModifyingAssign(node, RANGE.shr(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + } + + @Override + public Node leaveASSIGN_SHL(final BinaryNode node) { + return leaveSelfModifyingAssign(node, RANGE.shl(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); + } + + @Override + public Node leaveDECINC(final UnaryNode node) { + switch (node.tokenType()) { + case DECPREFIX: + case DECPOSTFIX: + return leaveSelfModifyingAssign(node, RANGE.sub(node.rhs().getSymbol().getRange(), Range.createRange(1))); + case INCPREFIX: + case INCPOSTFIX: + return leaveSelfModifyingAssign(node, RANGE.add(node.rhs().getSymbol().getRange(), Range.createRange(1))); + default: + assert false; + return node; + } + } + + @Override + public Node leaveADD(final UnaryNode node) { + Range range = node.rhs().getSymbol().getRange(); + if (!range.getType().isNumeric()) { + range = Range.createTypeRange(Type.NUMBER); + } + setRange(node, range); + return node; + } + + @Override + public Node leaveBIT_NOT(final UnaryNode node) { + setRange(node, Range.createTypeRange(Type.INT)); + return node; + } + + @Override + public Node leaveNOT(final UnaryNode node) { + setRange(node, Range.createTypeRange(Type.BOOLEAN)); + return node; + } + + @Override + public Node leaveSUB(final UnaryNode node) { + setRange(node, RANGE.neg(node.rhs().getSymbol().getRange())); + return node; + } + + @Override + public Node leaveVarNode(final VarNode node) { + if (node.isAssignment()) { + Range range = node.getInit().getSymbol().getRange(); + range = range.isUnknown() ? Range.createGenericRange() : range; + + setRange(node.getName(), range); + setRange(node, range); + } + + return node; + } + + @SuppressWarnings("rawtypes") + @Override + public boolean enterLiteralNode(final LiteralNode node) { + // ignore array literals + return !(node instanceof ArrayLiteralNode); + } + + @Override + public Node leaveLiteralNode(@SuppressWarnings("rawtypes") final LiteralNode node) { + if (node.getType().isInteger()) { + setRange(node, Range.createRange(node.getInt32())); + } else if (node.getType().isNumber()) { + setRange(node, Range.createRange(node.getNumber())); + } else if (node.getType().isLong()) { + setRange(node, Range.createRange(node.getLong())); + } else if (node.getType().isBoolean()) { + setRange(node, Range.createTypeRange(Type.BOOLEAN)); + } else { + setRange(node, Range.createGenericRange()); + } + return node; + } + + @Override + public boolean enterRuntimeNode(final RuntimeNode node) { + // a runtime node that cannot be specialized is no point entering + return node.getRequest().canSpecialize(); + } + + /** + * Check whether a symbol is unsafely assigned in a loop - i.e. repeteadly assigned and + * not being identified as the loop counter. That means we don't really know anything + * about its range. + * @param loopNode loop node + * @param symbol symbol + * @return true if assigned in loop + */ + // TODO - this currently checks for nodes only - needs to be augmented for while nodes + // assignment analysis is also very conservative + private static boolean assignedInLoop(final LoopNode loopNode, final Symbol symbol) { + final HashSet skip = new HashSet<>(); + final HashSet assignmentsInLoop = new HashSet<>(); + + loopNode.accept(new NodeVisitor() { + private boolean assigns(final Node node, final Symbol s) { + return node.isAssignment() && ((Assignment)node).getAssignmentDest().getSymbol() == s; + } + + @Override + public boolean enterForNode(final ForNode forNode) { + if (forNode.getInit() != null) { + skip.add(forNode.getInit()); + } + if (forNode.getModify() != null) { + skip.add(forNode.getModify()); + } + return true; + } + + @Override + public Node leaveDefault(final Node node) { + //if this is an assignment to symbol + if (!skip.contains(node) && assigns(node, symbol)) { + assignmentsInLoop.add(node); + } + return node; + } + }); + + return !assignmentsInLoop.isEmpty(); + } + + /** + * Check for a loop counter. This is currently quite conservative, in that it only handles + * x <= counter and x < counter. + * + * @param node loop node to check + * @return + */ + private static Symbol findLoopCounter(final LoopNode node) { + final Node test = node.getTest(); + + if (test != null && test.isComparison()) { + final BinaryNode binaryNode = (BinaryNode)test; + final Node lhs = binaryNode.lhs(); + final Node rhs = binaryNode.rhs(); + + //detect ident cmp int_literal + if (lhs instanceof IdentNode && rhs instanceof LiteralNode && ((LiteralNode)rhs).getType().isInteger()) { + final Symbol symbol = lhs.getSymbol(); + final int margin = ((LiteralNode)rhs).getInt32(); + final TokenType op = test.tokenType(); + + switch (op) { + case LT: + case LE: + symbol.setRange(RANGE.join(symbol.getRange(), Range.createRange(op == TokenType.LT ? margin - 1 : margin))); + return symbol; + case GT: + case GE: + //setRange(lhs, Range.createRange(op == TokenType.GT ? margin + 1 : margin)); + //return symbol; + default: + break; + } + } + } + + return null; + } + + private boolean isLoopCounter(final LoopNode loopNode, final Symbol symbol) { + //this only works if loop nodes aren't replaced by other ones during this transform, but they are not + return loopCounters.get(loopNode) == symbol; + } +} diff --git a/nashorn/src/jdk/nashorn/internal/codegen/types/Range.java b/nashorn/src/jdk/nashorn/internal/codegen/types/Range.java new file mode 100644 index 00000000000..2845d90240e --- /dev/null +++ b/nashorn/src/jdk/nashorn/internal/codegen/types/Range.java @@ -0,0 +1,705 @@ +/* + * Copyright (c) 2010, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.nashorn.internal.codegen.types; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import jdk.nashorn.internal.runtime.DebugLogger; +import jdk.nashorn.internal.runtime.JSType; + +/** + * Represents the value range of a symbol. + */ +public abstract class Range { + + private static final Range GENERIC_RANGE = new Range() { + @Override + public Type getType() { + return Type.OBJECT; + } + }; + + private static final Range NUMBER_RANGE = new Range() { + @Override + public Type getType() { + return Type.NUMBER; + } + }; + + private static final Range UNKNOWN_RANGE = new Range() { + @Override + public Type getType() { + return Type.UNKNOWN; + } + + @Override + public boolean isUnknown() { + return true; + } + }; + + private static class IntegerRange extends Range { + private final long min; + private final long max; + private final Type type; + + private IntegerRange(final long min, final long max) { + assert min <= max; + this.min = min; + this.max = max; + this.type = typeFromRange(min, max); + } + + private static Type typeFromRange(final long from, final long to) { + if (from >= Integer.MIN_VALUE && to <= Integer.MAX_VALUE) { + return Type.INT; + } + return Type.LONG; + } + + @Override + public Type getType() { + return type; + } + + public long getMin() { + return min; + } + + public long getMax() { + return max; + } + + @Override + public boolean isIntegerConst() { + return getMin() == getMax(); + } + + private long getBitMask() { + if (min == max) { + return min; + } + + if (min < 0) { + return ~0L; + } + + long mask = 1; + while (mask < max) { + mask = (mask << 1) | 1; + } + return mask; + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof IntegerRange) { + final IntegerRange other = (IntegerRange)obj; + return this.type == other.type && this.min == other.min && this.max == other.max; + } + return false; + } + + @Override + public int hashCode() { + return Long.hashCode(min) ^ Long.hashCode(max); + } + + @Override + public String toString() { + return super.toString() + "[" + min +", " + max + "]"; + } + } + + /** + * Get narrowest type for this range + * @return type + */ + public abstract Type getType(); + + /** + * Is this range unknown + * @return true if unknown + */ + public boolean isUnknown() { + return false; + } + + /** + * Check if an integer is enough to span this range + * @return true if integer is enough + */ + public boolean isIntegerType() { + return this instanceof IntegerRange; + } + + /** + * Check if an integer is enough to span this range + * @return true if integer is enough + */ + public boolean isIntegerConst() { + return false; + } + + /** + * Create an unknown range - this is most likely a singleton object + * and it represents "we have no known range information" + * @return the range + */ + public static Range createUnknownRange() { + return UNKNOWN_RANGE; + } + + /** + * Create a constant range: [value, value] + * @param value value + * @return the range + */ + public static Range createRange(final int value) { + return createIntegerRange(value, value); + } + + /** + * Create a constant range: [value, value] + * @param value value + * @return the range + */ + public static Range createRange(final long value) { + return createIntegerRange(value, value); + } + + /** + * Create a constant range: [value, value] + * @param value value + * @return the range + */ + public static Range createRange(final double value) { + if (isRepresentableAsLong(value)) { + return createIntegerRange((long) value, (long) value); + } + return createNumberRange(); + } + + /** + * Create a constant range: [value, value] + * @param value value + * @return the range + */ + public static Range createRange(final Object value) { + if (value instanceof Integer) { + return createRange((int)value); + } else if (value instanceof Long) { + return createRange((long)value); + } else if (value instanceof Double) { + return createRange((double)value); + } + + return createGenericRange(); + } + + /** + * Create a generic range - object symbol that carries no range + * information + * @return the range + */ + public static Range createGenericRange() { + return GENERIC_RANGE; + } + + /** + * Create a number range - number symbol that carries no range + * information + * @return the range + */ + public static Range createNumberRange() { + return NUMBER_RANGE; + } + + /** + * Create an integer range [min, max] + * @param min minimum value, inclusive + * @param max maximum value, inclusive + * @return the range + */ + public static IntegerRange createIntegerRange(final long min, final long max) { + return new IntegerRange(min, max); + } + + /** + * Create an integer range of maximum type width for the given type + * @param type the type + * @return the range + */ + public static IntegerRange createIntegerRange(final Type type) { + assert type.isNumeric() && !type.isNumber(); + final long min; + final long max; + if (type.isInteger()) { + min = Integer.MIN_VALUE; + max = Integer.MAX_VALUE; + } else if (type.isLong()) { + min = Long.MIN_VALUE; + max = Long.MAX_VALUE; + } else { + throw new AssertionError(); //type incompatible with integer range + } + return new IntegerRange(min, max); + } + + /** + * Create an range of maximum type width for the given type + * @param type the type + * @return the range + */ + public static Range createTypeRange(final Type type) { + if (type.isNumber()) { + return createNumberRange(); + } else if (type.isNumeric()) { + return createIntegerRange(type); + } else { + return createGenericRange(); + } + } + + // check that add doesn't overflow + private static boolean checkAdd(final long a, final long b) { + final long result = a + b; + return ((a ^ result) & (b ^ result)) >= 0; + } + + // check that sub doesn't overflow + private static boolean checkSub(final long a, final long b) { + final long result = a - b; + return ((a ^ result) & (b ^ result)) >= 0; + } + + private static boolean checkMul(final long a, final long b) { + // TODO correct overflow check + return a >= Integer.MIN_VALUE && a <= Integer.MAX_VALUE && b >= Integer.MIN_VALUE && b <= Integer.MAX_VALUE; + } + + /** + * The range functionality class responsible for merging ranges and drawing + * range conclusions from operations executed + */ + public static class Functionality { + /** logger */ + protected final DebugLogger log; + + /** + * Constructor + * @param log logger + */ + public Functionality(final DebugLogger log) { + this.log = log; + } + + /** + * Join two ranges + * @param a first range + * @param b second range + * @return the joined range + */ + public Range join(final Range a, final Range b) { + if (a.equals(b)) { + return a; + } + + Type joinedType = a.getType(); + if (a.getType() != b.getType()) { + if (a.isUnknown()) { + return b; + } + if (b.isUnknown()) { + return a; + } + + joinedType = Type.widest(a.getType(), b.getType()); + } + + if (joinedType.isInteger() || joinedType.isLong()) { + return createIntegerRange( + Math.min(((IntegerRange) a).getMin(), ((IntegerRange) b).getMin()), + Math.max(((IntegerRange) a).getMax(), ((IntegerRange) b).getMax())); + } + + return createTypeRange(joinedType); + } + + /** + * Add operation + * @param a range of first symbol to be added + * @param b range of second symbol to be added + * @return resulting range representing the value range after add + */ + public Range add(final Range a, final Range b) { + if (a.isIntegerType() && b.isIntegerType()) { + final IntegerRange lhs = (IntegerRange)a; + final IntegerRange rhs = (IntegerRange)b; + if (checkAdd(lhs.getMin(), rhs.getMin()) && checkAdd(lhs.getMax(), rhs.getMax())) { + return createIntegerRange(lhs.getMin() + rhs.getMin(), lhs.getMax() + rhs.getMax()); + } + } + + if (a.getType().isNumeric() && b.getType().isNumeric()) { + return createNumberRange(); + } + + return createGenericRange(); + } + + /** + * Sub operation + * @param a range of first symbol to be subtracted + * @param b range of second symbol to be subtracted + * @return resulting range representing the value range after subtraction + */ + public Range sub(final Range a, final Range b) { + if (a.isIntegerType() && b.isIntegerType()) { + final IntegerRange lhs = (IntegerRange)a; + final IntegerRange rhs = (IntegerRange)b; + if (checkSub(lhs.getMin(), rhs.getMax()) && checkSub(lhs.getMax(), rhs.getMin())) { + return createIntegerRange(lhs.getMin() - rhs.getMax(), lhs.getMax() - rhs.getMin()); + } + } + + if (a.getType().isNumeric() && b.getType().isNumeric()) { + return createNumberRange(); + } + + return createGenericRange(); + } + + /** + * Mul operation + * @param a range of first symbol to be multiplied + * @param b range of second symbol to be multiplied + * @return resulting range representing the value range after multiplication + */ + public Range mul(final Range a, final Range b) { + if (a.isIntegerType() && b.isIntegerType()) { + final IntegerRange lhs = (IntegerRange)a; + final IntegerRange rhs = (IntegerRange)b; + + //ensure that nothing ever overflows or underflows + if (checkMul(lhs.getMin(), rhs.getMin()) && + checkMul(lhs.getMax(), rhs.getMax()) && + checkMul(lhs.getMin(), rhs.getMax()) && + checkMul(lhs.getMax(), rhs.getMin())) { + + final List results = + Arrays.asList( + lhs.getMin() * rhs.getMin(), + lhs.getMin() * rhs.getMax(), + lhs.getMax() * rhs.getMin(), + lhs.getMax() * rhs.getMax()); + return createIntegerRange(Collections.min(results), Collections.max(results)); + } + } + + if (a.getType().isNumeric() && b.getType().isNumeric()) { + return createNumberRange(); + } + + return createGenericRange(); + } + + /** + * Neg operation + * @param a range of value symbol to be negated + * @return resulting range representing the value range after neg + */ + public Range neg(final Range a) { + if (a.isIntegerType()) { + final IntegerRange rhs = (IntegerRange)a; + if (rhs.getMin() != Long.MIN_VALUE && rhs.getMax() != Long.MIN_VALUE) { + return createIntegerRange(-rhs.getMax(), -rhs.getMin()); + } + } + + if (a.getType().isNumeric()) { + return createNumberRange(); + } + + return createGenericRange(); + } + + /** + * Bitwise and operation + * @param a range of first symbol to be and:ed + * @param b range of second symbol to be and:ed + * @return resulting range representing the value range after and + */ + public Range and(final Range a, final Range b) { + if (a.isIntegerType() && b.isIntegerType()) { + final int resultMask = (int) (((IntegerRange)a).getBitMask() & ((IntegerRange)b).getBitMask()); + if (resultMask >= 0) { + return createIntegerRange(0, resultMask); + } + } else if (a.isUnknown() && b.isIntegerType()) { + final long operandMask = ((IntegerRange)b).getBitMask(); + if (operandMask >= 0) { + return createIntegerRange(0, operandMask); + } + } else if (a.isIntegerType() && b.isUnknown()) { + final long operandMask = ((IntegerRange)a).getBitMask(); + if (operandMask >= 0) { + return createIntegerRange(0, operandMask); + } + } + + return createTypeRange(Type.INT); + } + + /** + * Bitwise or operation + * @param a range of first symbol to be or:ed + * @param b range of second symbol to be or:ed + * @return resulting range representing the value range after or + */ + public Range or(final Range a, final Range b) { + if (a.isIntegerType() && b.isIntegerType()) { + final int resultMask = (int)(((IntegerRange)a).getBitMask() | ((IntegerRange)b).getBitMask()); + if (resultMask >= 0) { + return createIntegerRange(0, resultMask); + } + } + + return createTypeRange(Type.INT); + } + + /** + * Bitwise xor operation + * @param a range of first symbol to be xor:ed + * @param b range of second symbol to be xor:ed + * @return resulting range representing the value range after and + */ + public Range xor(final Range a, final Range b) { + if (a.isIntegerConst() && b.isIntegerConst()) { + return createRange(((IntegerRange)a).getMin() ^ ((IntegerRange)b).getMin()); + } + + if (a.isIntegerType() && b.isIntegerType()) { + final int resultMask = (int)(((IntegerRange)a).getBitMask() | ((IntegerRange)b).getBitMask()); + if (resultMask >= 0) { + return createIntegerRange(0, createIntegerRange(0, resultMask).getBitMask()); + } + } + return createTypeRange(Type.INT); + } + + /** + * Bitwise shl operation + * @param a range of first symbol to be shl:ed + * @param b range of second symbol to be shl:ed + * @return resulting range representing the value range after shl + */ + public Range shl(final Range a, final Range b) { + if (b.isIntegerType() && b.isIntegerConst()) { + final IntegerRange left = (IntegerRange)(a.isIntegerType() ? a : createTypeRange(Type.INT)); + final int shift = (int)((IntegerRange) b).getMin() & 0x1f; + final int min = (int)left.getMin() << shift; + final int max = (int)left.getMax() << shift; + if (min >> shift == left.getMin() && max >> shift == left.getMax()) { + return createIntegerRange(min, max); + } + } + + return createTypeRange(Type.INT); + } + + /** + * Bitwise shr operation + * @param a range of first symbol to be shr:ed + * @param b range of second symbol to be shr:ed + * @return resulting range representing the value range after shr + */ + public Range shr(final Range a, final Range b) { + if (b.isIntegerType() && b.isIntegerConst()) { + final long shift = ((IntegerRange) b).getMin() & 0x1f; + final IntegerRange left = (IntegerRange)(a.isIntegerType() ? a : createTypeRange(Type.INT)); + if (left.getMin() >= 0) { + long min = left.getMin() >>> shift; + long max = left.getMax() >>> shift; + return createIntegerRange(min, max); + } else if (shift >= 1) { + return createIntegerRange(0, JSType.MAX_UINT >>> shift); + } + } + + return createTypeRange(Type.INT); + } + + /** + * Bitwise sar operation + * @param a range of first symbol to be sar:ed + * @param b range of second symbol to be sar:ed + * @return resulting range representing the value range after sar + */ + public Range sar(final Range a, final Range b) { + if (b.isIntegerType() && b.isIntegerConst()) { + final IntegerRange left = (IntegerRange)(a.isIntegerType() ? a : createTypeRange(Type.INT)); + final long shift = ((IntegerRange) b).getMin() & 0x1f; + final long min = left.getMin() >> shift; + final long max = left.getMax() >> shift; + return createIntegerRange(min, max); + } + + return createTypeRange(Type.INT); + } + + /** + * Modulo operation + * @param a range of first symbol to the mod operation + * @param b range of second symbol to be mod operation + * @return resulting range representing the value range after mod + */ + public Range mod(final Range a, final Range b) { + if (a.isIntegerType() && b.isIntegerType()) { + final IntegerRange rhs = (IntegerRange) b; + if (rhs.getMin() > 0 || rhs.getMax() < 0) { // divisor range must not include 0 + final long absmax = Math.max(Math.abs(rhs.getMin()), Math.abs(rhs.getMax())) - 1; + return createIntegerRange(rhs.getMin() > 0 ? 0 : -absmax, rhs.getMax() < 0 ? 0 : +absmax); + } + } + return createTypeRange(Type.NUMBER); + } + + /** + * Division operation + * @param a range of first symbol to the division + * @param b range of second symbol to be division + * @return resulting range representing the value range after division + */ + public Range div(final Range a, final Range b) { + // TODO + return createTypeRange(Type.NUMBER); + } + } + + /** + * Simple trace functionality that will log range creation + */ + public static class TraceFunctionality extends Functionality { + TraceFunctionality(final DebugLogger log) { + super(log); + } + + private Range trace(final Range result, final String operation, final Range... operands) { + log.fine("range::" + operation + Arrays.toString(operands) + " => " + result); + return result; + } + + @Override + public Range join(final Range a, final Range b) { + final Range result = super.join(a, b); + if (!a.equals(b)) { + trace(result, "join", a, b); + } + return result; + } + + @Override + public Range add(final Range a, final Range b) { + return trace(super.add(a, b), "add", a, b); + } + + @Override + public Range sub(final Range a, final Range b) { + return trace(super.sub(a, b), "sub", a, b); + } + + @Override + public Range mul(final Range a, final Range b) { + return trace(super.mul(a, b), "mul", a, b); + } + + @Override + public Range neg(final Range a) { + return trace(super.neg(a), "neg", a); + } + + @Override + public Range and(final Range a, final Range b) { + return trace(super.and(a, b), "and", a, b); + } + + @Override + public Range or(final Range a, final Range b) { + return trace(super.or(a, b), "or", a, b); + } + + @Override + public Range xor(final Range a, final Range b) { + return trace(super.xor(a, b), "xor", a, b); + } + + @Override + public Range shl(final Range a, final Range b) { + return trace(super.shl(a, b), "shl", a, b); + } + + @Override + public Range shr(final Range a, final Range b) { + return trace(super.shr(a, b), "shr", a, b); + } + + @Override + public Range sar(final Range a, final Range b) { + return trace(super.sar(a, b), "sar", a, b); + } + + @Override + public Range mod(final Range a, final Range b) { + return trace(super.mod(a, b), "mod", a, b); + } + + @Override + public Range div(final Range a, final Range b) { + return trace(super.div(a, b), "div", a, b); + } + } + + @Override + public String toString() { + return String.valueOf(getType()); + } + + @SuppressWarnings("unused") + private static boolean isRepresentableAsInt(final double number) { + return (int)number == number && !isNegativeZero(number); + } + + private static boolean isRepresentableAsLong(final double number) { + return (long)number == number && !isNegativeZero(number); + } + + private static boolean isNegativeZero(final double number) { + return Double.doubleToLongBits(number) == Double.doubleToLongBits(-0.0); + } +} diff --git a/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java b/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java index 747793e8d5c..57b0212a59b 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java @@ -106,22 +106,12 @@ public abstract class Type implements Comparable, BytecodeOps { Type(final String name, final Class clazz, final int weight, final int slots) { this.name = name; this.clazz = clazz; - this.descriptor = Type.getDescriptor(clazz); + this.descriptor = jdk.internal.org.objectweb.asm.Type.getDescriptor(clazz); this.weight = weight; assert weight >= MIN_WEIGHT && weight <= MAX_WEIGHT : "illegal type weight: " + weight; this.slots = slots; } - /** - * Return an internal descriptor for a type - * - * @param type the type - * @return descriptor string - */ - public static String getDescriptor(final Class type) { - return jdk.internal.org.objectweb.asm.Type.getDescriptor(type); - } - /** * Get the weight of this type - use this e.g. for sorting method descriptors * @return the weight diff --git a/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java b/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java index 61454fef0a1..51a0664688d 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java @@ -59,6 +59,23 @@ public final class BinaryNode extends Node implements Assignment { this.rhs = rhs; } + @Override + public boolean isComparison() { + switch (tokenType()) { + case EQ: + case EQ_STRICT: + case NE: + case NE_STRICT: + case LE: + case LT: + case GE: + case GT: + return true; + default: + return false; + } + } + /** * Return the widest possible type for this operation. This is used for compile time * static type inference diff --git a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java index 715d4507ac3..d271985cc8b 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java @@ -340,7 +340,7 @@ public final class FunctionNode extends LexicalContextNode implements Flags iter = new NodeIterator<>(LoopNode.class, getCurrentFunction()); + return iter.hasNext() ? iter.next() : null; + } + /** * Find the breakable node corresponding to this label. * @param label label to search for, if null the closest breakable node will be returned unconditionally, e.g. a while loop with no label @@ -461,8 +478,7 @@ public class LexicalContext { } private LoopNode getContinueTo() { - final Iterator iter = new NodeIterator<>(LoopNode.class, getCurrentFunction()); - return iter.hasNext() ? iter.next() : null; + return getCurrentLoop(); } /** diff --git a/nashorn/src/jdk/nashorn/internal/ir/Node.java b/nashorn/src/jdk/nashorn/internal/ir/Node.java index 0fb95cc3852..99e543e6110 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Node.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Node.java @@ -152,6 +152,14 @@ public abstract class Node implements Cloneable { return Type.OBJECT; } + /** + * Returns true if this node represents a comparison operator + * @return true if comparison + */ + public boolean isComparison() { + return false; + } + /** * For reference copies - ensure that labels in the copy node are unique * using an appropriate copy constructor diff --git a/nashorn/src/jdk/nashorn/internal/ir/Symbol.java b/nashorn/src/jdk/nashorn/internal/ir/Symbol.java index 05495152709..d26fe561627 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Symbol.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Symbol.java @@ -29,6 +29,8 @@ import java.io.PrintWriter; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; + +import jdk.nashorn.internal.codegen.types.Range; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.Debug; @@ -89,6 +91,9 @@ public final class Symbol implements Comparable { /** Number of times this symbol is used in code */ private int useCount; + /** Range for symbol */ + private Range range; + /** Debugging option - dump info and stack trace when symbols with given names are manipulated */ private static final Set TRACE_SYMBOLS; private static final Set TRACE_SYMBOLS_STACKTRACE; @@ -131,6 +136,7 @@ public final class Symbol implements Comparable { this.type = type; this.slot = slot; this.fieldIndex = -1; + this.range = Range.createUnknownRange(); trace("CREATE SYMBOL"); } @@ -157,12 +163,13 @@ public final class Symbol implements Comparable { private Symbol(final Symbol base, final String name, final int flags) { this.flags = flags; - this.name = name; + this.name = name; this.fieldIndex = base.fieldIndex; - this.slot = base.slot; - this.type = base.type; - this.useCount = base.useCount; + this.slot = base.slot; + this.type = base.type; + this.useCount = base.useCount; + this.range = base.range; } private static String align(final String string, final int max) { @@ -276,7 +283,7 @@ public final class Symbol implements Comparable { @Override public String toString() { - final StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(name). append(' '). @@ -409,6 +416,22 @@ public final class Symbol implements Comparable { return (flags & KINDMASK) == IS_PARAM; } + /** + * Get the range for this symbol + * @return range for symbol + */ + public Range getRange() { + return range; + } + + /** + * Set the range for this symbol + * @param range range + */ + public void setRange(final Range range) { + this.range = range; + } + /** * Check if this symbol is a function parameter of known * narrowest type diff --git a/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunction.java b/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunction.java index d36f216c2b0..afa3657c1b5 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunction.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunction.java @@ -35,21 +35,27 @@ import jdk.nashorn.internal.codegen.types.Type; */ final class CompiledFunction implements Comparable { + /** The method type may be more specific than the invoker, if. e.g. + * the invoker is guarded, and a guard with a generic object only + * fallback, while the target is more specific, we still need the + * more specific type for sorting */ + private final MethodType type; private final MethodHandle invoker; private MethodHandle constructor; - CompiledFunction(final MethodHandle invoker) { - this(invoker, null); + CompiledFunction(final MethodType type, final MethodHandle invoker) { + this(type, invoker, null); } - CompiledFunction(final MethodHandle invoker, final MethodHandle constructor) { - this.invoker = invoker; - this.constructor = constructor; //isConstructor + CompiledFunction(final MethodType type, final MethodHandle invoker, final MethodHandle constructor) { + this.type = type; + this.invoker = invoker; + this.constructor = constructor; } @Override public String toString() { - return ""; + return ""; } MethodHandle getInvoker() { @@ -69,7 +75,7 @@ final class CompiledFunction implements Comparable { } MethodType type() { - return invoker.type(); + return type; } @Override @@ -103,8 +109,8 @@ final class CompiledFunction implements Comparable { return weight() > o.weight(); } - boolean moreGenericThan(final MethodType type) { - return weight() > weight(type); + boolean moreGenericThan(final MethodType mt) { + return weight() > weight(mt); } /** @@ -112,15 +118,15 @@ final class CompiledFunction implements Comparable { * It is compatible if the types are narrower than the invocation type so that * a semantically equivalent linkage can be performed. * - * @param typesc + * @param mt type to check against * @return */ - boolean typeCompatible(final MethodType type) { - final Class[] wantedParams = type.parameterArray(); + boolean typeCompatible(final MethodType mt) { + final Class[] wantedParams = mt.parameterArray(); final Class[] existingParams = type().parameterArray(); //if we are not examining a varargs type, the number of parameters must be the same - if (wantedParams.length != existingParams.length && !isVarArgsType(type)) { + if (wantedParams.length != existingParams.length && !isVarArgsType(mt)) { return false; } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java b/nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java index ed54b2e92a3..469245f113a 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java @@ -78,9 +78,9 @@ public final class FinalScriptFunctionData extends ScriptFunctionData { //only nasgen constructors: (boolean, self, args) are subject to binding a boolean newObj. isConstructor //is too conservative a check. However, isConstructor(mh) always implies isConstructor param assert isConstructor(); - code.add(new CompiledFunction(MH.insertArguments(mh, 0, false), composeConstructor(MH.insertArguments(mh, 0, true), needsCallee))); //make sure callee state can be determined when we reach constructor + code.add(new CompiledFunction(mh.type(), MH.insertArguments(mh, 0, false), composeConstructor(MH.insertArguments(mh, 0, true), needsCallee))); //make sure callee state can be determined when we reach constructor } else { - code.add(new CompiledFunction(mh)); + code.add(new CompiledFunction(mh.type(), mh)); } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java index 03a25dab1b7..226d83d1b76 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java @@ -30,6 +30,8 @@ import static jdk.nashorn.internal.lookup.Lookup.MH; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; +import java.util.ArrayList; +import java.util.Arrays; import java.util.LinkedList; import jdk.nashorn.internal.codegen.Compiler; @@ -49,9 +51,16 @@ import jdk.nashorn.internal.parser.TokenType; */ public final class RecompilableScriptFunctionData extends ScriptFunctionData { + /** FunctionNode with the code for this ScriptFunction */ private FunctionNode functionNode; - private final PropertyMap allocatorMap; + + /** Allocator map from makeMap() */ + private final PropertyMap allocatorMap; + + /** Code installer used for all further recompilation/specialization of this ScriptFunction */ private final CodeInstaller installer; + + /** Name of class where allocator function resides */ private final String allocatorClassName; /** lazily generated allocator */ @@ -59,6 +68,23 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData { private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); + /** + * Used for specialization based on runtime arguments. Whenever we specialize on + * callsite parameter types at runtime, we need to use a parameter type guard to + * ensure that the specialized version of the script function continues to be + * applicable for a particular callsite * + */ + private static final MethodHandle PARAM_TYPE_GUARD = findOwnMH("paramTypeGuard", boolean.class, Type[].class, Object[].class); + + /** + * It is usually a good gamble whever we detect a runtime callsite with a double + * (or java.lang.Number instance) to specialize the parameter to an integer, if the + * parameter in question can be represented as one. The double typically only exists + * because the compiler doesn't know any better than "a number type" and conservatively + * picks doubles when it can't prove that an integer addition wouldn't overflow + */ + private static final MethodHandle ENSURE_INT = findOwnMH("ensureInt", int.class, Object.class); + /** * Constructor - public as scripts use it * @@ -141,14 +167,6 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData { return; // nothing to do, we have code, at least some. } - // check if function node is lazy, need to compile it. - // note that currently function cloning is not working completely, which - // means that the compiler will mutate the function node it has been given - // once it has been compiled, it cannot be recompiled. This means that - // lazy compilation works (not compiled yet) but e.g. specializations won't - // until the copy-on-write changes for IR are in, making cloning meaningless. - // therefore, currently method specialization is disabled. TODO - if (functionNode.isLazy()) { Compiler.LOG.info("Trampoline hit: need to do lazy compilation of '", functionNode.getName(), "'"); final Compiler compiler = new Compiler(installer); @@ -156,38 +174,55 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData { assert !functionNode.isLazy(); compiler.install(functionNode); - // we don't need to update any flags - varArgs and needsCallee are instrincic - // in the function world we need to get a destination node from the compile instead - // and replace it with our function node. TODO + /* + * We don't need to update any flags - varArgs and needsCallee are instrincic + * in the function world we need to get a destination node from the compile instead + * and replace it with our function node. TODO + */ } - // we can't get here unless we have bytecode, either from eager compilation or from - // running a lazy compile on the lines above + /* + * We can't get to this program point unless we have bytecode, either from + * eager compilation or from running a lazy compile on the lines above + */ assert functionNode.hasState(CompilationState.EMITTED) : functionNode.getName() + " " + functionNode.getState() + " " + Debug.id(functionNode); // code exists - look it up and add it into the automatically sorted invoker list - addCode(functionNode, null, null); + addCode(functionNode); } - private MethodHandle addCode(final FunctionNode fn, final MethodHandle guard, final MethodHandle fallback) { - final MethodHandle target = + private MethodHandle addCode(final FunctionNode fn) { + return addCode(fn, null, null, null); + } + + private MethodHandle addCode(final FunctionNode fn, final MethodType runtimeType, final MethodHandle guard, final MethodHandle fallback) { + final MethodType targetType = new FunctionSignature(fn).getMethodType(); + MethodHandle target = MH.findStatic( LOOKUP, fn.getCompileUnit().getCode(), fn.getName(), - new FunctionSignature(fn). - getMethodType()); - MethodHandle mh = target; - if (guard != null) { - try { - mh = MH.guardWithTest(MH.asCollector(guard, Object[].class, target.type().parameterCount()), MH.asType(target, fallback.type()), fallback); - } catch (Throwable e) { - e.printStackTrace(); + targetType); + + /* + * For any integer argument. a double that is representable as an integer is OK. + * otherwise the guard would have failed. in that case introduce a filter that + * casts the double to an integer, which we know will preserve all precision. + */ + for (int i = 0; i < targetType.parameterCount(); i++) { + if (targetType.parameterType(i) == int.class) { + //representable as int + target = MH.filterArguments(target, i, ENSURE_INT); } } - final CompiledFunction cf = new CompiledFunction(mh); + MethodHandle mh = target; + if (guard != null) { + mh = MH.guardWithTest(MH.asCollector(guard, Object[].class, target.type().parameterCount()), MH.asType(target, fallback.type()), fallback); + } + + final CompiledFunction cf = new CompiledFunction(runtimeType == null ? targetType : runtimeType, mh); code.add(cf); return cf.getInvoker(); @@ -212,69 +247,162 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData { return Type.OBJECT; } - @SuppressWarnings("unused") - private static boolean paramTypeGuard(final Type[] compileTimeTypes, final Type[] runtimeTypes, Object... args) { - //System.err.println("Param type guard " + Arrays.asList(args)); + private static boolean canCoerce(final Object arg, final Type type) { + Type argType = runtimeType(arg); + if (Type.widest(argType, type) == type || arg == ScriptRuntime.UNDEFINED) { + return true; + } + System.err.println(arg + " does not fit in "+ argType + " " + type + " " + arg.getClass()); + new Throwable().printStackTrace(); return false; } - private static final MethodHandle PARAM_TYPE_GUARD = findOwnMH("paramTypeGuard", boolean.class, Type[].class, Type[].class, Object[].class); + @SuppressWarnings("unused") + private static boolean paramTypeGuard(final Type[] paramTypes, final Object... args) { + final int length = args.length; + assert args.length >= paramTypes.length; + + //i==start, skip the this, callee params etc + int start = args.length - paramTypes.length; + for (int i = start; i < args.length; i++) { + final Object arg = args[i]; + if (!canCoerce(arg, paramTypes[i - start])) { + return false; + } + } + return true; + } + + @SuppressWarnings("unused") + private static int ensureInt(final Object arg) { + if (arg instanceof Number) { + return ((Number)arg).intValue(); + } else if (arg instanceof Undefined) { + return 0; + } + throw new AssertionError(arg); + } + + /** + * Given the runtime callsite args, compute a method type that is equivalent to what + * was passed - this is typically a lot more specific that what the compiler has been + * able to deduce + * @param callSiteType callsite type for the compiled callsite target + * @param args runtime arguments to the compiled callsite target + * @return adjusted method type, narrowed as to conform to runtime callsite type instead + */ + private static MethodType runtimeType(final MethodType callSiteType, final Object[] args) { + if (args == null) { + //for example bound, or otherwise runtime arguments to callsite unavailable, then + //do not change the type + return callSiteType; + } + final Class[] paramTypes = new Class[callSiteType.parameterCount()]; + final int start = args.length - callSiteType.parameterCount(); + for (int i = start; i < args.length; i++) { + paramTypes[i - start] = runtimeType(args[i]).getTypeClass(); + } + return MH.type(callSiteType.returnType(), paramTypes); + } + + private static ArrayList runtimeType(final MethodType mt) { + final ArrayList type = new ArrayList<>(); + for (int i = 0; i < mt.parameterCount(); i++) { + type.add(Type.typeFor(mt.parameterType(i))); + } + return type; + } @Override MethodHandle getBestInvoker(final MethodType callSiteType, final Object[] args) { - final MethodHandle mh = super.getBestInvoker(callSiteType, args); + final MethodType runtimeType = runtimeType(callSiteType, args); + assert runtimeType.parameterCount() == callSiteType.parameterCount(); - if (!functionNode.canSpecialize() || !code.isLessSpecificThan(callSiteType)) { + final MethodHandle mh = super.getBestInvoker(runtimeType, args); + + /* + * Not all functions can be specialized, for example, if we deemed memory + * footprint too large to store a parse snapshot, or if it is meaningless + * to do so, such as e.g. for runScript + */ + if (!functionNode.canSpecialize()) { return mh; } - final FunctionNode snapshot = functionNode.getSnapshot(); - if (snapshot == null) { + /* + * Check if best invoker is equally specific or more specific than runtime + * type. In that case, we don't need further specialization, but can use + * whatever we have already. We know that it will match callSiteType, or it + * would not have been returned from getBestInvoker + */ + if (!code.isLessSpecificThan(runtimeType)) { return mh; } int i; + final FunctionNode snapshot = functionNode.getSnapshot(); + assert snapshot != null; - //classes known at runtime - final LinkedList runtimeArgs = new LinkedList<>(); - for (i = args.length - 1; i >= args.length - snapshot.getParameters().size(); i--) { - runtimeArgs.addLast(runtimeType(args[i])); - } - - //classes known at compile time + /* + * Create a list of the arg types that the compiler knows about + * typically, the runtime args are a lot more specific, and we should aggressively + * try to use those whenever possible + * We WILL try to make an aggressive guess as possible, and add guards if needed. + * For example, if the compiler can deduce that we have a number type, but the runtime + * passes and int, we might still want to keep it an int, and the gamble to + * check that whatever is passed is int representable usually pays off + * If the compiler only knows that a parameter is an "Object", it is still worth + * it to try to specialize it by looking at the runtime arg. + */ final LinkedList compileTimeArgs = new LinkedList<>(); for (i = callSiteType.parameterCount() - 1; i >= 0 && compileTimeArgs.size() < snapshot.getParameters().size(); i--) { - compileTimeArgs.addLast(Type.typeFor(callSiteType.parameterType(i))); + compileTimeArgs.addFirst(Type.typeFor(callSiteType.parameterType(i))); } - //the classes known at compile time are a safe to generate as primitives without parameter guards - //the classes known at runtime are safe to generate as primitives IFF there are parameter guards + /* + * The classes known at compile time are a safe to generate as primitives without parameter guards + * But the classes known at runtime (if more specific than compile time types) are safe to generate as primitives + * IFF there are parameter guards + */ MethodHandle guard = null; + final ArrayList runtimeParamTypes = runtimeType(runtimeType); + while (runtimeParamTypes.size() > functionNode.getParameters().size()) { + runtimeParamTypes.remove(0); + } for (i = 0; i < compileTimeArgs.size(); i++) { - final Type runtimeType = runtimeArgs.get(i); - final Type compileType = compileTimeArgs.get(i); + final Type rparam = Type.typeFor(runtimeType.parameterType(i)); + final Type cparam = compileTimeArgs.get(i); - if (compileType.isObject() && !runtimeType.isObject()) { + if (cparam.isObject() && !rparam.isObject()) { + //check that the runtime object is still coercible to the runtime type, because compiler can't prove it's always primitive if (guard == null) { - guard = PARAM_TYPE_GUARD; - guard = MH.insertArguments(guard, 0, compileTimeArgs.toArray(new Type[compileTimeArgs.size()]), runtimeArgs.toArray(new Type[runtimeArgs.size()])); + guard = MH.insertArguments(PARAM_TYPE_GUARD, 0, (Object)runtimeParamTypes.toArray(new Type[runtimeParamTypes.size()])); } } } - //System.err.println("Specialized " + name + " " + runtimeArgs + " known=" + compileTimeArgs); + Compiler.LOG.info("Callsite specialized ", name, " runtimeType=", runtimeType, " parameters=", snapshot.getParameters(), " args=", Arrays.asList(args)); assert snapshot != null; assert snapshot != functionNode; final Compiler compiler = new Compiler(installer); - final FunctionNode compiledSnapshot = compiler.compile(snapshot.setHints(null, new Compiler.Hints(compileTimeArgs.toArray(new Type[compileTimeArgs.size()])))); + final FunctionNode compiledSnapshot = compiler.compile( + snapshot.setHints( + null, + new Compiler.Hints(runtimeParamTypes.toArray(new Type[runtimeParamTypes.size()])))); + + /* + * No matter how narrow your types were, they can never be narrower than Attr during recompile made them. I.e. you + * can put an int into the function here, if you see it as a runtime type, but if the function uses a multiplication + * on it, it will still need to be a double. At least until we have overflow checks. Similarly, if an int is + * passed but it is used as a string, it makes no sense to make the parameter narrower than Object. At least until + * the "different types for one symbol in difference places" work is done + */ compiler.install(compiledSnapshot); - final MethodHandle nmh = addCode(compiledSnapshot, guard, mh); - - return nmh; + return addCode(compiledSnapshot, runtimeType, guard, mh); } private static MethodHandle findOwnMH(final String name, final Class rtype, final Class... types) { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java index 0a556f9d51c..3bcf9d4f5a3 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java @@ -54,7 +54,7 @@ public final class ScriptEnvironment { private final Namespace namespace; /** Current Options object. */ - private Options options; + private final Options options; /** Always allow functions as statements */ public final boolean _anon_functions; @@ -155,6 +155,9 @@ public final class ScriptEnvironment { /** print symbols and their contents for the script */ public final boolean _print_symbols; + /** range analysis for known types */ + public final boolean _range_analysis; + /** is this environment in scripting mode? */ public final boolean _scripting; @@ -219,6 +222,7 @@ public final class ScriptEnvironment { _print_parse = options.getBoolean("print.parse"); _print_lower_parse = options.getBoolean("print.lower.parse"); _print_symbols = options.getBoolean("print.symbols"); + _range_analysis = options.getBoolean("range.analysis"); _scripting = options.getBoolean("scripting"); _strict = options.getBoolean("strict"); _version = options.getBoolean("version"); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java index 1e899be5805..f98817c8ee6 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java @@ -91,12 +91,13 @@ public abstract class ScriptFunctionData { CompiledFunction bind(final CompiledFunction originalInv, final ScriptFunction fn, final Object self, final Object[] args) { final MethodHandle boundInvoker = bindInvokeHandle(originalInv.getInvoker(), fn, self, args); + //TODO the boundinvoker.type() could actually be more specific here if (isConstructor()) { ensureConstructor(originalInv); - return new CompiledFunction(boundInvoker, bindConstructHandle(originalInv.getConstructor(), fn, args)); + return new CompiledFunction(boundInvoker.type(), boundInvoker, bindConstructHandle(originalInv.getConstructor(), fn, args)); } - return new CompiledFunction(boundInvoker); + return new CompiledFunction(boundInvoker.type(), boundInvoker); } /** diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties b/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties index 4717319710f..59e971917eb 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties @@ -277,6 +277,12 @@ nashorn.option.print.symbols = { \ desc="Print the symbol table." \ } +nashorn.option.range.analysis = { \ + name="--range-analysis", \ + is_undocumented=true, \ + desc="Do range analysis using known compile time types, and try to narrow number types" \ +} + nashorn.option.D = { \ name="-D", \ desc="-Dname=value. Set a system property. This option can be repeated.", \ diff --git a/nashorn/test/script/basic/ranges_disabled.js b/nashorn/test/script/basic/ranges_disabled.js new file mode 100644 index 00000000000..5bc8846ee54 --- /dev/null +++ b/nashorn/test/script/basic/ranges_disabled.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * range analysis test. check that computation return values are correct + * both with and without range analysis + * + * @test + * @run + */ + +load(__DIR__ + "ranges_payload.js"); diff --git a/nashorn/test/script/basic/ranges_disabled.js.EXPECTED b/nashorn/test/script/basic/ranges_disabled.js.EXPECTED new file mode 100644 index 00000000000..1a99c91b7e6 --- /dev/null +++ b/nashorn/test/script/basic/ranges_disabled.js.EXPECTED @@ -0,0 +1,4 @@ +289 +11094405 +4294967293 +-4722 diff --git a/nashorn/test/script/basic/ranges_enabled.js b/nashorn/test/script/basic/ranges_enabled.js new file mode 100644 index 00000000000..45d9efb08d9 --- /dev/null +++ b/nashorn/test/script/basic/ranges_enabled.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * range analysis test. check that computation return values are correct + * both with and without range analysis + * + * @test + * @option --range-analysis + * @run + */ + +load(__DIR__ + "ranges_payload.js"); diff --git a/nashorn/test/script/basic/ranges_enabled.js.EXPECTED b/nashorn/test/script/basic/ranges_enabled.js.EXPECTED new file mode 100644 index 00000000000..1a99c91b7e6 --- /dev/null +++ b/nashorn/test/script/basic/ranges_enabled.js.EXPECTED @@ -0,0 +1,4 @@ +289 +11094405 +4294967293 +-4722 diff --git a/nashorn/test/script/basic/ranges_payload.js b/nashorn/test/script/basic/ranges_payload.js new file mode 100644 index 00000000000..f10a4a28b1f --- /dev/null +++ b/nashorn/test/script/basic/ranges_payload.js @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * range analysis test. check that computation return values are correct + * both with and without range analysis + * + * @subtest + */ + +function f(c) { + var v = c & 0xffff; + var w = v & 0xfff; + var x = v * w; + return x; +} + +function g() { + var sum = 0; + for (var x = 0; x < 4711; x++) { + sum += x; + } + return sum; +} + +function g2() { + var sum = 0; + //make sure we overflow + var displacement = 0x7ffffffe; + for (var x = displacement; x < (displacement + 2); x++) { + sum += x; + } + return sum; +} + +//mostly provide code coverage for all the range operations +function h() { + var sum = 0; + sum += 4711; + sum &= 0xffff; + sum /= 2; + sum *= 2; + sum -= 4; + sum |= 2; + sum ^= 17; + sum = sum % 10000; + sum = -sum; + return sum +} + +print(f(17)); +print(g()); +print(g2()); +print(h()); From 32261c12b2f6a3983665dafa276f6d6c17601a50 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Mon, 20 May 2013 23:04:01 +0530 Subject: [PATCH 021/206] 8014909: ant test compilation error with JoniTest.java Reviewed-by: jlaskey --- nashorn/make/build.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index c647ba4b922..7c05e789fe9 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -212,7 +212,9 @@ target="${javac.target}" debug="${javac.debug}" encoding="${javac.encoding}" - includeantruntime="false"/> + includeantruntime="false"> + + From 34bc5ff07fc75ef6adc513fe8b2818ebf1c93a0b Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Mon, 20 May 2013 21:25:14 +0200 Subject: [PATCH 022/206] 8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively Reviewed-by: jlaskey, sundar --- .../docs/JavaScriptingProgrammersGuide.html | 10 ++-- nashorn/docs/source/javaarray.js | 4 +- .../nashorn/api/scripting/resources/engine.js | 2 +- .../nashorn/internal/objects/NativeJava.java | 51 ++++++++++++------- .../runtime/resources/Messages.properties | 1 + nashorn/test/script/basic/NASHORN-556.js | 24 ++++----- .../test/script/basic/javaarrayconversion.js | 16 +++--- .../script/currently-failing/logcoverage.js | 3 +- nashorn/test/script/trusted/NASHORN-638.js | 3 +- nashorn/test/script/trusted/NASHORN-653.js | 3 +- 10 files changed, 64 insertions(+), 53 deletions(-) diff --git a/nashorn/docs/JavaScriptingProgrammersGuide.html b/nashorn/docs/JavaScriptingProgrammersGuide.html index a9af9612271..a9803f7fd81 100644 --- a/nashorn/docs/JavaScriptingProgrammersGuide.html +++ b/nashorn/docs/JavaScriptingProgrammersGuide.html @@ -616,26 +616,26 @@ print(a[0]);

    It is also possible to convert between JavaScript and Java arrays. -Given a JavaScript array and a Java type, Java.toJavaArray returns a Java array with the same initial contents, and with the specified component type. +Given a JavaScript array and a Java type, Java.to returns a Java array with the same initial contents, and with the specified array type.

    
      var anArray = [1, "13", false]
    - var javaIntArray = Java.toJavaArray(anArray, "int")
    + var javaIntArray = Java.to(anArray, "int[]")
      print(javaIntArray[0]) // prints 1
      print(javaIntArray[1]) // prints 13, as string "13" was converted to number 13 as per ECMAScript ToNumber conversion
      print(javaIntArray[2]) // prints 0, as boolean false was converted to number 0 as per ECMAScript ToNumber conversion
     

    -You can use either a string or a type object returned from Java.type() to specify the component type of the array. +You can use either a string or a type object returned from Java.type() to specify the type of the array. You can also omit the array type, in which case a Object[] will be created.

    -Given a Java array or Collection, Java.toJavaScriptArray returns a JavaScript array with a shallow copy of its contents. Note that in most cases, you can use Java arrays and lists natively in Nashorn; in cases where for some reason you need to have an actual JavaScript native array (e.g. to work with the array comprehensions functions), you will want to use this method. +Given a Java array or Collection, Java.from returns a JavaScript array with a shallow copy of its contents. Note that in most cases, you can use Java arrays and lists natively in Nashorn; in cases where for some reason you need to have an actual JavaScript native array (e.g. to work with the array comprehensions functions), you will want to use this method.

    
     var File = Java.type("java.io.File");
     var listCurDir = new File(".").listFiles();
    -var jsList = Java.toJavaScriptArray(listCurDir);
    +var jsList = Java.from(listCurDir);
     print(jsList);
     

    diff --git a/nashorn/docs/source/javaarray.js b/nashorn/docs/source/javaarray.js index a02aa3ca9f6..d0de9124684 100644 --- a/nashorn/docs/source/javaarray.js +++ b/nashorn/docs/source/javaarray.js @@ -40,7 +40,7 @@ print(a[0]); // convert a script array to Java array var anArray = [1, "13", false]; -var javaIntArray = Java.toJavaArray(anArray, "int"); +var javaIntArray = Java.to(anArray, "int[]"); print(javaIntArray[0]);// prints 1 print(javaIntArray[1]); // prints 13, as string "13" was converted to number 13 as per ECMAScript ToNumber conversion print(javaIntArray[2]);// prints 0, as boolean false was converted to number 0 as per ECMAScript ToNumber conversion @@ -48,5 +48,5 @@ print(javaIntArray[2]);// prints 0, as boolean false was converted to number 0 a // convert a Java array to a JavaScript array var File = Java.type("java.io.File"); var listCurDir = new File(".").listFiles(); -var jsList = Java.toJavaScriptArray(listCurDir); +var jsList = Java.from(listCurDir); print(jsList); diff --git a/nashorn/src/jdk/nashorn/api/scripting/resources/engine.js b/nashorn/src/jdk/nashorn/api/scripting/resources/engine.js index e95607287d4..62d6735ee3f 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/resources/engine.js +++ b/nashorn/src/jdk/nashorn/api/scripting/resources/engine.js @@ -88,7 +88,7 @@ Object.defineProperty(this, "sprintf", { } } - array = Java.toJavaArray(array); + array = Java.to(array); return Packages.jdk.nashorn.api.scripting.ScriptUtils.format(format, array); } }); diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java b/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java index 5faec5ea98b..800b224f10d 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java @@ -240,39 +240,52 @@ public final class NativeJava { } /** - * Given a JavaScript array and a Java type, returns a Java array with the same initial contents, and with the - * specified component type. Example: + * Given a script object and a Java type, converts the script object into the desired Java type. Currently it only + * performs shallow creation of Java arrays, but might be extended for other types in the future. Example: *
          * var anArray = [1, "13", false]
    -     * var javaIntArray = Java.toJavaArray(anArray, "int")
    +     * var javaIntArray = Java.to(anArray, "int[]")
          * print(javaIntArray[0]) // prints 1
          * print(javaIntArray[1]) // prints 13, as string "13" was converted to number 13 as per ECMAScript ToNumber conversion
          * print(javaIntArray[2]) // prints 0, as boolean false was converted to number 0 as per ECMAScript ToNumber conversion
          * 
    * @param self not used - * @param objArray the JavaScript array. Can be null. - * @param objType either a {@link #type(Object, Object) type object} or a String describing the component type of - * the Java array to create. Can not be null. If undefined, Object is assumed (allowing the argument to be omitted). - * @return a Java array with the copy of JavaScript array's contents, converted to the appropriate Java component - * type. Returns null if objArray is null. + * @param objArray the script object. Can be null. + * @param objType either a {@link #type(Object, Object) type object} or a String describing the type of the Java + * object to create. Can not be null. If undefined, a "default" conversion is presumed (allowing the argument to be + * omitted). + * @return a Java object whose value corresponds to the original script object's value. Specifically, for array + * target types, returns a Java array of the same type with contents converted to the array's component type. Does + * not recursively convert for multidimensional arrays. + * type. Returns null if scriptObject is null. * @throws ClassNotFoundException if the class described by objType is not found */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object toJavaArray(final Object self, final Object objArray, final Object objType) throws ClassNotFoundException { - final StaticClass componentType = - objType instanceof StaticClass ? - (StaticClass)objType : - objType == UNDEFINED ? - StaticClass.forClass(Object.class) : - type(objType); - + public static Object to(final Object self, final Object objArray, final Object objType) throws ClassNotFoundException { if (objArray == null) { return null; } + final Class componentType; + if(objType == UNDEFINED) { + componentType = Object.class; + } else { + final StaticClass arrayType; + if(objType instanceof StaticClass) { + arrayType = (StaticClass)objType; + } else { + arrayType = type(objType); + } + final Class arrayClass = arrayType.getRepresentedClass(); + if(!arrayClass.isArray()) { + throw typeError("to.expects.array.type", arrayClass.getName()); + } + componentType = arrayClass.getComponentType(); + } + Global.checkObject(objArray); - return ((ScriptObject)objArray).getArray().asArrayOfType(componentType.getRepresentedClass()); + return ((ScriptObject)objArray).getArray().asArrayOfType(componentType); } /** @@ -283,7 +296,7 @@ public final class NativeJava { *
          * var File = Java.type("java.io.File")
          * var listHomeDir = new File("~").listFiles()
    -     * var jsListHome = Java.toJavaScriptArray(listHomeDir)
    +     * var jsListHome = Java.from(listHomeDir)
          * var jpegModifiedDates = jsListHome
          *     .filter(function(val) { return val.getName().endsWith(".jpg") })
          *     .map(function(val) { return val.lastModified() })
    @@ -294,7 +307,7 @@ public final class NativeJava {
          * null.
          */
         @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
    -    public static Object toJavaScriptArray(final Object self, final Object objArray) {
    +    public static Object from(final Object self, final Object objArray) {
             if (objArray == null) {
                 return null;
             } else if (objArray instanceof Collection) {
    diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties
    index 9f327521bcc..4f435ea2e96 100644
    --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties
    +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties
    @@ -125,6 +125,7 @@ type.error.no.constructor.matches.args=Can not construct {0} with the passed arg
     type.error.no.method.matches.args=Can not invoke method {0} with the passed arguments; they do not match any of its method signatures.
     type.error.method.not.constructor=Java method {0} can't be used as a constructor.
     type.error.env.not.object=$ENV must be an Object.
    +type.error.to.expects.array.type=Java.to() expects an array target type. {0} is not an array type.
     range.error.inappropriate.array.length=inappropriate array length: {0}
     range.error.invalid.fraction.digits=fractionDigits argument to {0} must be in [0, 20]
     range.error.invalid.precision=precision argument toPrecision() must be in [1, 21]
    diff --git a/nashorn/test/script/basic/NASHORN-556.js b/nashorn/test/script/basic/NASHORN-556.js
    index 5cb164a0cf3..1332d02bef8 100644
    --- a/nashorn/test/script/basic/NASHORN-556.js
    +++ b/nashorn/test/script/basic/NASHORN-556.js
    @@ -47,7 +47,7 @@ function f1() {
       // (NoTypeArrayData)
       var empty = {};
       empty.length = 10;
    -  Java.toJavaArray(empty);
    +  Java.to(empty);
       delete empty[0];
       Array.prototype.slice.call(empty, 0, 1);
       Array.prototype.pop.call(empty);
    @@ -63,7 +63,7 @@ function f1() {
     function f2() {
       // DeletedArrayFilter
       var deleted = [,1,,2,,3,,4,,];
    -  assertEq(2, Java.toJavaArray(deleted)[3]);
    +  assertEq(2, Java.to(deleted)[3]);
       assertEq(undefined, deleted.pop());
       assertEq(4, deleted.pop());
       deleted.unshift(5);
    @@ -78,7 +78,7 @@ function f2() {
     function f3() {
       // DeletedRangeArrayFilter
       var delrange = [1,2,3,,,,,,,,,,];
    -  Java.toJavaArray(delrange);
    +  Java.to(delrange);
       delrange.unshift(4);
       p.apply(null, delrange);
       print(delrange.slice(1,3), delrange.slice(2,6));
    @@ -88,7 +88,7 @@ function f3() {
     function f4() {
       // NumberArrayData
       var num = [1.1,2.2,3.3,4.4,5.5];
    -  Java.toJavaArray(num);
    +  Java.to(num);
       assertEq(2, num[3] >>> 1);
       assertEq(5, num[4] | 0);
       assertEq(5.5, num.pop());
    @@ -104,7 +104,7 @@ function f4() {
     function f5() {
       // ObjectArrayData
       var obj = [2,"two",3.14,"pi",14,"fourteen"];
    -  Java.toJavaArray(obj);
    +  Java.to(obj);
       assertEq(-12.86, obj[2] - 16);
       assertEq(7, obj[4] >>> 1);
       obj.unshift("one");
    @@ -131,14 +131,14 @@ function f6() {
       sparse.length = 1024*1024;
       sparse.push(sparse.length);
       delete sparse[sparse.length-1];
    -  //print(Java.toJavaArray(sparse).length);
    +  //print(Java.to(sparse).length);
       (function(){}).apply(null, sparse);
     }
     
     function f7() {
       // UndefinedArrayFilter
       var undef = [1,2,3,4,5,undefined,7,8,9,19];
    -  Java.toJavaArray(undef);
    +  Java.to(undef);
       assertEq(4, undef[8] >>> 1);
       var tmp = undef[9] >>> 1;
       undef[8] = tmp;
    @@ -154,8 +154,8 @@ function f7() {
     
     function f8() {
       // LongArrayData
    -  var j = Java.toJavaScriptArray(Java.toJavaArray([23,37,42,86,47], "long"));
    -  Java.toJavaArray(j);
    +  var j = Java.from(Java.to([23,37,42,86,47], "long[]"));
    +  Java.to(j);
       p.apply(null, j);
       assertEq(43, j[3] >>> 1);
       assertEq(36, j[4] - 11);
    @@ -164,12 +164,12 @@ function f8() {
       assertEq(7, j.shift());
       assertEq(47, j.pop());
       j.push("asdf");
    -  j = Java.toJavaScriptArray(Java.toJavaArray([23,37,42,86,47], "long"));
    +  j = Java.from(Java.to([23,37,42,86,47], "long[]"));
       j.length = 3;
       j[0] = 13;
    -  j = Java.toJavaScriptArray(Java.toJavaArray([23,37,42,86,47], "long"));
    +  j = Java.from(Java.to([23,37,42,86,47], "long[]"));
       delete j[0];
    -  j = Java.toJavaScriptArray(Java.toJavaArray([23,37,42,86,47], "long"));
    +  j = Java.from(Java.to([23,37,42,86,47], "long[]"));
       j.length = 20;
       j[0] = 13.37;
     }
    diff --git a/nashorn/test/script/basic/javaarrayconversion.js b/nashorn/test/script/basic/javaarrayconversion.js
    index 34e2f95fb12..96ebe904668 100644
    --- a/nashorn/test/script/basic/javaarrayconversion.js
    +++ b/nashorn/test/script/basic/javaarrayconversion.js
    @@ -34,7 +34,7 @@ var x; // used for undefined
     var testCount = 0;
     
     function testF(inputValue, type, testFn) {
    -  var x = Java.toJavaArray([inputValue], type)[0];
    +  var x = Java.to([inputValue], type + "[]")[0];
       if(!testFn(x)) {
         throw ("unexpected value: " + x)
       }
    @@ -130,7 +130,7 @@ test({ valueOf: function() { return "42"; },  toString: function() { return "43"
     
     function assertCantConvert(sourceType, targetType) {
       try {
    -    Java.toJavaArray([new Java.type(sourceType)()], targetType)
    +    Java.to([new Java.type(sourceType)()], targetType + "[]")
         throw "no TypeError encountered"
       } catch(e) {
           if(!(e instanceof TypeError)) {
    @@ -164,7 +164,7 @@ var intArray = new (Java.type("int[]"))(3)
     intArray[0] = 1234;
     intArray[1] = 42;
     intArray[2] = 5;
    -var jsIntArray = Java.toJavaScriptArray(intArray)
    +var jsIntArray = Java.from(intArray)
     assert(jsIntArray instanceof Array);
     assert(jsIntArray[0] === 1234);
     assert(jsIntArray[1] === 42);
    @@ -179,7 +179,7 @@ assert(intArray[2] === 6);
     var byteArray = new (Java.type("byte[]"))(2)
     byteArray[0] = -128;
     byteArray[1] = 127;
    -var jsByteArray = Java.toJavaScriptArray(byteArray)
    +var jsByteArray = Java.from(byteArray)
     assert(jsByteArray instanceof Array);
     assert(jsByteArray[0] === -128);
     assert(jsByteArray[1] === 127);
    @@ -187,7 +187,7 @@ assert(jsByteArray[1] === 127);
     var shortArray = new (Java.type("short[]"))(2)
     shortArray[0] = -32768;
     shortArray[1] = 32767;
    -var jsShortArray = Java.toJavaScriptArray(shortArray)
    +var jsShortArray = Java.from(shortArray)
     assert(jsShortArray instanceof Array);
     assert(jsShortArray[0] === -32768);
     assert(jsShortArray[1] === 32767);
    @@ -195,7 +195,7 @@ assert(jsShortArray[1] === 32767);
     var floatArray = new (Java.type("float[]"))(2)
     floatArray[0] = java.lang.Float.MIN_VALUE;
     floatArray[1] = java.lang.Float.MAX_VALUE;
    -var jsFloatArray = Java.toJavaScriptArray(floatArray)
    +var jsFloatArray = Java.from(floatArray)
     assert(jsFloatArray instanceof Array);
     assert(jsFloatArray[0] == java.lang.Float.MIN_VALUE);
     assert(jsFloatArray[1] == java.lang.Float.MAX_VALUE);
    @@ -204,7 +204,7 @@ var charArray = new (Java.type("char[]"))(3)
     charArray[0] = "a";
     charArray[1] = "b";
     charArray[2] = "1";
    -var jsCharArray = Java.toJavaScriptArray(charArray)
    +var jsCharArray = Java.from(charArray)
     assert(jsCharArray instanceof Array);
     assert(jsCharArray[0] === 97);
     assert(jsCharArray[1] === 98);
    @@ -213,7 +213,7 @@ assert(jsCharArray[2] === 49);
     var booleanArray = new (Java.type("boolean[]"))(2)
     booleanArray[0] = true;
     booleanArray[1] = false;
    -var jsBooleanArray = Java.toJavaScriptArray(booleanArray)
    +var jsBooleanArray = Java.from(booleanArray)
     assert(jsBooleanArray instanceof Array);
     assert(jsBooleanArray[0] === true);
     assert(jsBooleanArray[1] === false);
    diff --git a/nashorn/test/script/currently-failing/logcoverage.js b/nashorn/test/script/currently-failing/logcoverage.js
    index 18b16aa1e00..2d8d410a881 100644
    --- a/nashorn/test/script/currently-failing/logcoverage.js
    +++ b/nashorn/test/script/currently-failing/logcoverage.js
    @@ -53,8 +53,7 @@ function runScriptEngine(opts, name) {
                 // set new standard err
                 System.setErr(newErr);
                 System.setOut(newOut);
    -            var strType = Java.type("java.lang.String");
    -            var engine = fac.getScriptEngine(Java.toJavaArray(opts, strType));
    +            var engine = fac.getScriptEngine(Java.to(opts, "java.lang.String[]"));
     	    var reader = new java.io.FileReader(name);
                 engine.eval(reader);
                 newErr.flush();
    diff --git a/nashorn/test/script/trusted/NASHORN-638.js b/nashorn/test/script/trusted/NASHORN-638.js
    index 9cb6d694c55..1ff789a919b 100644
    --- a/nashorn/test/script/trusted/NASHORN-638.js
    +++ b/nashorn/test/script/trusted/NASHORN-638.js
    @@ -47,8 +47,7 @@ function runScriptEngine(opts, code) {
             try {
                 // set new standard err
                 System.setErr(newErr);
    -            var strType = Java.type("java.lang.String");
    -            var engine = fac.getScriptEngine(Java.toJavaArray(opts, strType));
    +            var engine = fac.getScriptEngine(Java.to(opts, "java.lang.String[]"));
                 engine.eval(code);
                 newErr.flush();
                 return new java.lang.String(baos.toByteArray());
    diff --git a/nashorn/test/script/trusted/NASHORN-653.js b/nashorn/test/script/trusted/NASHORN-653.js
    index 2084bf70aeb..14a2cbc4c1c 100644
    --- a/nashorn/test/script/trusted/NASHORN-653.js
    +++ b/nashorn/test/script/trusted/NASHORN-653.js
    @@ -85,8 +85,7 @@ function runScriptEngine(opts, code) {
             try {
                 // set new standard err
                 System.setErr(newErr);
    -            var strType = Java.type("java.lang.String");
    -            var engine = fac.getScriptEngine(Java.toJavaArray(opts, strType));
    +            var engine = fac.getScriptEngine(Java.to(opts, "java.lang.String[]"));
                 engine.eval(code);
                 newErr.flush();
                 return new java.lang.String(baos.toByteArray());
    
    From 80041e51d1d0dbd291ca55056f8ad1a40d67cc2b Mon Sep 17 00:00:00 2001
    From: Joe Wang 
    Date: Mon, 20 May 2013 16:11:49 -0700
    Subject: [PATCH 023/206] 8014891: Redundant setting of external access
     properties in setFeatures
    
    Reviewed-by: lancea
    ---
     .../org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java  | 4 ----
     .../sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java    | 4 ----
     2 files changed, 8 deletions(-)
    
    diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java
    index 39112a61f64..520bc87ea6a 100644
    --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java
    +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java
    @@ -236,10 +236,6 @@ public class DocumentBuilderImpl extends DocumentBuilder
                     String feature = (String) entry.getKey();
                     boolean value = ((Boolean) entry.getValue()).booleanValue();
                     domParser.setFeature(feature, value);
    -                if (feature.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
    -                    domParser.setProperty(ACCESS_EXTERNAL_DTD, "");
    -                    domParser.setProperty(ACCESS_EXTERNAL_SCHEMA, "");
    -                }
                 }
             }
         }
    diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java
    index bbb609e9e28..a57c1543d84 100644
    --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java
    +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java
    @@ -242,10 +242,6 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
                     String feature = (String) entry.getKey();
                     boolean value = ((Boolean) entry.getValue()).booleanValue();
                     xmlReader.setFeature0(feature, value);
    -                if (feature.equals(XMLConstants.FEATURE_SECURE_PROCESSING) && value) {
    -                    xmlReader.setProperty0(ACCESS_EXTERNAL_DTD, "");
    -                    xmlReader.setProperty0(ACCESS_EXTERNAL_SCHEMA, "");
    -                }
                 }
             }
         }
    
    From ed440d1096ba1a1b1c6b49b3e5da2a43eee0992b Mon Sep 17 00:00:00 2001
    From: Joe Wang 
    Date: Mon, 20 May 2013 23:46:51 -0700
    Subject: [PATCH 024/206] 8012683: Remove unused, obsolete ObjectFactory
     classes
    
    Reviewed-by: lancea
    ---
     .../internal/xinclude/ObjectFactory.java      | 553 ------------------
     .../xml/internal/serialize/ObjectFactory.java | 553 ------------------
     2 files changed, 1106 deletions(-)
     delete mode 100644 jaxp/src/com/sun/org/apache/xerces/internal/xinclude/ObjectFactory.java
     delete mode 100644 jaxp/src/com/sun/org/apache/xml/internal/serialize/ObjectFactory.java
    
    diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/ObjectFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/ObjectFactory.java
    deleted file mode 100644
    index 9c6ad1300cd..00000000000
    --- a/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/ObjectFactory.java
    +++ /dev/null
    @@ -1,553 +0,0 @@
    -/*
    - * reserved comment block
    - * DO NOT REMOVE OR ALTER!
    - */
    -/*
    - * Copyright 2001-2005 The Apache Software Foundation.
    - *
    - * Licensed under the Apache License, Version 2.0 (the "License");
    - * you may not use this file except in compliance with the License.
    - * You may obtain a copy of the License at
    - *
    - *      http://www.apache.org/licenses/LICENSE-2.0
    - *
    - * Unless required by applicable law or agreed to in writing, software
    - * distributed under the License is distributed on an "AS IS" BASIS,
    - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    - * See the License for the specific language governing permissions and
    - * limitations under the License.
    - */
    -
    -package com.sun.org.apache.xerces.internal.xinclude;
    -
    -import java.io.InputStream;
    -import java.io.IOException;
    -import java.io.File;
    -import java.io.FileInputStream;
    -
    -import java.util.Properties;
    -import java.io.BufferedReader;
    -import java.io.InputStreamReader;
    -
    -/**
    - * This class is duplicated for each JAXP subpackage so keep it in sync.
    - * It is package private and therefore is not exposed as part of the JAXP
    - * API.
    - * 

    - * This code is designed to implement the JAXP 1.1 spec pluggability - * feature and is designed to run on JDK version 1.1 and - * later, and to compile on JDK 1.2 and onward. - * The code also runs both as part of an unbundled jar file and - * when bundled as part of the JDK. - *

    - * - */ -final class ObjectFactory { - - // - // Constants - // - - // name of default properties file to look for in JDK's jre/lib directory - private static final String DEFAULT_PROPERTIES_FILENAME = "xerces.properties"; - - /** Set to true for debugging */ - private static final boolean DEBUG = false; - - /** - * Default columns per line. - */ - private static final int DEFAULT_LINE_LENGTH = 80; - - /** cache the contents of the xerces.properties file. - * Until an attempt has been made to read this file, this will - * be null; if the file does not exist or we encounter some other error - * during the read, this will be empty. - */ - private static Properties fXercesProperties = null; - - /*** - * Cache the time stamp of the xerces.properties file so - * that we know if it's been modified and can invalidate - * the cache when necessary. - */ - private static long fLastModified = -1; - - // - // static methods - // - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - *

      - *
    1. query the system property using System.getProperty - *
    2. read META-INF/services/factoryId file - *
    3. use fallback classname - *
    - * - * @return Class object of factory, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - static Object createObject(String factoryId, String fallbackClassName) - throws ConfigurationError { - return createObject(factoryId, null, fallbackClassName); - } // createObject(String,String):Object - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - *
      - *
    1. query the system property using System.getProperty - *
    2. read $java.home/lib/propertiesFilename file - *
    3. read META-INF/services/factoryId file - *
    4. use fallback classname - *
    - * - * @return Class object of factory, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param propertiesFilename The filename in the $java.home/lib directory - * of the properties file. If none specified, - * ${java.home}/lib/xerces.properties will be used. - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - static Object createObject(String factoryId, - String propertiesFilename, - String fallbackClassName) - throws ConfigurationError - { - if (DEBUG) debugPrintln("debug is on"); - - SecuritySupport ss = SecuritySupport.getInstance(); - ClassLoader cl = findClassLoader(); - - // Use the system property first - try { - String systemProp = ss.getSystemProperty(factoryId); - if (systemProp != null) { - if (DEBUG) debugPrintln("found system property, value=" + systemProp); - return newInstance(systemProp, cl, true); - } - } catch (SecurityException se) { - // Ignore and continue w/ next location - } - - // JAXP specific change - // always use fallback class to avoid the expense of constantly - // "stat"ing a non-existent "xerces.properties" and jar SPI entry - // see CR 6400863: Expensive creating of SAX parser in Mustang - if (true) { - if (fallbackClassName == null) { - throw new ConfigurationError( - "Provider for " + factoryId + " cannot be found", null); - } - - if (DEBUG) debugPrintln("using fallback, value=" + fallbackClassName); - return newInstance(fallbackClassName, cl, true); - } - - // Try to read from propertiesFilename, or $java.home/lib/xerces.properties - String factoryClassName = null; - // no properties file name specified; use $JAVA_HOME/lib/xerces.properties: - if (propertiesFilename == null) { - File propertiesFile = null; - boolean propertiesFileExists = false; - try { - String javah = ss.getSystemProperty("java.home"); - propertiesFilename = javah + File.separator + - "lib" + File.separator + DEFAULT_PROPERTIES_FILENAME; - propertiesFile = new File(propertiesFilename); - propertiesFileExists = ss.getFileExists(propertiesFile); - } catch (SecurityException e) { - // try again... - fLastModified = -1; - fXercesProperties = null; - } - - synchronized (ObjectFactory.class) { - boolean loadProperties = false; - FileInputStream fis = null; - try { - // file existed last time - if(fLastModified >= 0) { - if(propertiesFileExists && - (fLastModified < (fLastModified = ss.getLastModified(propertiesFile)))) { - loadProperties = true; - } else { - // file has stopped existing... - if(!propertiesFileExists) { - fLastModified = -1; - fXercesProperties = null; - } // else, file wasn't modified! - } - } else { - // file has started to exist: - if(propertiesFileExists) { - loadProperties = true; - fLastModified = ss.getLastModified(propertiesFile); - } // else, nothing's changed - } - if(loadProperties) { - // must never have attempted to read xerces.properties before (or it's outdeated) - fXercesProperties = new Properties(); - fis = ss.getFileInputStream(propertiesFile); - fXercesProperties.load(fis); - } - } catch (Exception x) { - fXercesProperties = null; - fLastModified = -1; - // assert(x instanceof FileNotFoundException - // || x instanceof SecurityException) - // In both cases, ignore and continue w/ next location - } - finally { - // try to close the input stream if one was opened. - if (fis != null) { - try { - fis.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - } - } - if(fXercesProperties != null) { - factoryClassName = fXercesProperties.getProperty(factoryId); - } - } else { - FileInputStream fis = null; - try { - fis = ss.getFileInputStream(new File(propertiesFilename)); - Properties props = new Properties(); - props.load(fis); - factoryClassName = props.getProperty(factoryId); - } catch (Exception x) { - // assert(x instanceof FileNotFoundException - // || x instanceof SecurityException) - // In both cases, ignore and continue w/ next location - } - finally { - // try to close the input stream if one was opened. - if (fis != null) { - try { - fis.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - } - } - if (factoryClassName != null) { - if (DEBUG) debugPrintln("found in " + propertiesFilename + ", value=" + factoryClassName); - return newInstance(factoryClassName, cl, true); - } - - // Try Jar Service Provider Mechanism - Object provider = findJarServiceProvider(factoryId); - if (provider != null) { - return provider; - } - - if (fallbackClassName == null) { - throw new ConfigurationError( - "Provider for " + factoryId + " cannot be found", null); - } - - if (DEBUG) debugPrintln("using fallback, value=" + fallbackClassName); - return newInstance(fallbackClassName, cl, true); - } // createObject(String,String,String):Object - - // - // Private static methods - // - - /** Prints a message to standard error if debugging is enabled. */ - private static void debugPrintln(String msg) { - if (DEBUG) { - System.err.println("JAXP: " + msg); - } - } // debugPrintln(String) - - /** - * Figure out which ClassLoader to use. For JDK 1.2 and later use - * the context ClassLoader. - */ - static ClassLoader findClassLoader() - throws ConfigurationError - { - SecuritySupport ss = SecuritySupport.getInstance(); - - // Figure out which ClassLoader to use for loading the provider - // class. If there is a Context ClassLoader then use it. - ClassLoader context = ss.getContextClassLoader(); - ClassLoader system = ss.getSystemClassLoader(); - - ClassLoader chain = system; - while (true) { - if (context == chain) { - // Assert: we are on JDK 1.1 or we have no Context ClassLoader - // or any Context ClassLoader in chain of system classloader - // (including extension ClassLoader) so extend to widest - // ClassLoader (always look in system ClassLoader if Xerces - // is in boot/extension/system classpath and in current - // ClassLoader otherwise); normal classloaders delegate - // back to system ClassLoader first so this widening doesn't - // change the fact that context ClassLoader will be consulted - ClassLoader current = ObjectFactory.class.getClassLoader(); - - chain = system; - while (true) { - if (current == chain) { - // Assert: Current ClassLoader in chain of - // boot/extension/system ClassLoaders - return system; - } - if (chain == null) { - break; - } - chain = ss.getParentClassLoader(chain); - } - - // Assert: Current ClassLoader not in chain of - // boot/extension/system ClassLoaders - return current; - } - - if (chain == null) { - // boot ClassLoader reached - break; - } - - // Check for any extension ClassLoaders in chain up to - // boot ClassLoader - chain = ss.getParentClassLoader(chain); - }; - - // Assert: Context ClassLoader not in chain of - // boot/extension/system ClassLoaders - return context; - } // findClassLoader():ClassLoader - - /** - * Create an instance of a class using the specified ClassLoader - */ - static Object newInstance(String className, ClassLoader cl, - boolean doFallback) - throws ConfigurationError - { - // assert(className != null); - try{ - Class providerClass = findProviderClass(className, cl, doFallback); - Object instance = providerClass.newInstance(); - if (DEBUG) debugPrintln("created new instance of " + providerClass + - " using ClassLoader: " + cl); - return instance; - } catch (ClassNotFoundException x) { - throw new ConfigurationError( - "Provider " + className + " not found", x); - } catch (Exception x) { - throw new ConfigurationError( - "Provider " + className + " could not be instantiated: " + x, - x); - } - } - - /** - * Find a Class using the specified ClassLoader - */ - static Class findProviderClass(String className, ClassLoader cl, - boolean doFallback) - throws ClassNotFoundException, ConfigurationError - { - //throw security exception if the calling thread is not allowed to access the package - //restrict the access to package as speicified in java.security policy - SecurityManager security = System.getSecurityManager(); - if (security != null) { - final int lastDot = className.lastIndexOf("."); - String packageName = className; - if (lastDot != -1) packageName = className.substring(0, lastDot); - security.checkPackageAccess(packageName); - } - Class providerClass; - if (cl == null) { - // XXX Use the bootstrap ClassLoader. There is no way to - // load a class using the bootstrap ClassLoader that works - // in both JDK 1.1 and Java 2. However, this should still - // work b/c the following should be true: - // - // (cl == null) iff current ClassLoader == null - // - // Thus Class.forName(String) will use the current - // ClassLoader which will be the bootstrap ClassLoader. - providerClass = Class.forName(className); - } else { - try { - providerClass = cl.loadClass(className); - } catch (ClassNotFoundException x) { - if (doFallback) { - // Fall back to current classloader - ClassLoader current = ObjectFactory.class.getClassLoader(); - if (current == null) { - providerClass = Class.forName(className); - } else if (cl != current) { - cl = current; - providerClass = cl.loadClass(className); - } else { - throw x; - } - } else { - throw x; - } - } - } - - return providerClass; - } - - /* - * Try to find provider using Jar Service Provider Mechanism - * - * @return instance of provider class if found or null - */ - private static Object findJarServiceProvider(String factoryId) - throws ConfigurationError - { - SecuritySupport ss = SecuritySupport.getInstance(); - String serviceId = "META-INF/services/" + factoryId; - InputStream is = null; - - // First try the Context ClassLoader - ClassLoader cl = findClassLoader(); - - is = ss.getResourceAsStream(cl, serviceId); - - // If no provider found then try the current ClassLoader - if (is == null) { - ClassLoader current = ObjectFactory.class.getClassLoader(); - if (cl != current) { - cl = current; - is = ss.getResourceAsStream(cl, serviceId); - } - } - - if (is == null) { - // No provider found - return null; - } - - if (DEBUG) debugPrintln("found jar resource=" + serviceId + - " using ClassLoader: " + cl); - - // Read the service provider name in UTF-8 as specified in - // the jar spec. Unfortunately this fails in Microsoft - // VJ++, which does not implement the UTF-8 - // encoding. Theoretically, we should simply let it fail in - // that case, since the JVM is obviously broken if it - // doesn't support such a basic standard. But since there - // are still some users attempting to use VJ++ for - // development, we have dropped in a fallback which makes a - // second attempt using the platform's default encoding. In - // VJ++ this is apparently ASCII, which is a subset of - // UTF-8... and since the strings we'll be reading here are - // also primarily limited to the 7-bit ASCII range (at - // least, in English versions), this should work well - // enough to keep us on the air until we're ready to - // officially decommit from VJ++. [Edited comment from - // jkesselm] - BufferedReader rd; - try { - rd = new BufferedReader(new InputStreamReader(is, "UTF-8"), DEFAULT_LINE_LENGTH); - } catch (java.io.UnsupportedEncodingException e) { - rd = new BufferedReader(new InputStreamReader(is), DEFAULT_LINE_LENGTH); - } - - String factoryClassName = null; - try { - // XXX Does not handle all possible input as specified by the - // Jar Service Provider specification - factoryClassName = rd.readLine(); - } catch (IOException x) { - // No provider found - return null; - } - finally { - try { - // try to close the reader. - rd.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - - if (factoryClassName != null && - ! "".equals(factoryClassName)) { - if (DEBUG) debugPrintln("found in resource, value=" - + factoryClassName); - - // Note: here we do not want to fall back to the current - // ClassLoader because we want to avoid the case where the - // resource file was found using one ClassLoader and the - // provider class was instantiated using a different one. - return newInstance(factoryClassName, cl, false); - } - - // No provider found - return null; - } - - // - // Classes - // - - /** - * A configuration error. - */ - static final class ConfigurationError - extends Error { - - /** Serialization version. */ - static final long serialVersionUID = 5061904944269807898L; - - // - // Data - // - - /** Exception. */ - private Exception exception; - - // - // Constructors - // - - /** - * Construct a new instance with the specified detail string and - * exception. - */ - ConfigurationError(String msg, Exception x) { - super(msg); - this.exception = x; - } // (String,Exception) - - // - // methods - // - - /** Returns the exception associated to this error. */ - Exception getException() { - return exception; - } // getException():Exception - - } // class ConfigurationError - -} // class ObjectFactory diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/ObjectFactory.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/ObjectFactory.java deleted file mode 100644 index de2d7aaca25..00000000000 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/ObjectFactory.java +++ /dev/null @@ -1,553 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.serialize; - -import java.io.InputStream; -import java.io.IOException; -import java.io.File; -import java.io.FileInputStream; - -import java.util.Properties; -import java.io.BufferedReader; -import java.io.InputStreamReader; - -/** - * This class is duplicated for each JAXP subpackage so keep it in sync. - * It is package private and therefore is not exposed as part of the JAXP - * API. - *

    - * This code is designed to implement the JAXP 1.1 spec pluggability - * feature and is designed to run on JDK version 1.1 and - * later, and to compile on JDK 1.2 and onward. - * The code also runs both as part of an unbundled jar file and - * when bundled as part of the JDK. - *

    - * - */ -final class ObjectFactory { - - // - // Constants - // - - // name of default properties file to look for in JDK's jre/lib directory - private static final String DEFAULT_PROPERTIES_FILENAME = "xerces.properties"; - - /** Set to true for debugging */ - private static final boolean DEBUG = false; - - /** - * Default columns per line. - */ - private static final int DEFAULT_LINE_LENGTH = 80; - - /** cache the contents of the xerces.properties file. - * Until an attempt has been made to read this file, this will - * be null; if the file does not exist or we encounter some other error - * during the read, this will be empty. - */ - private static Properties fXercesProperties = null; - - /*** - * Cache the time stamp of the xerces.properties file so - * that we know if it's been modified and can invalidate - * the cache when necessary. - */ - private static long fLastModified = -1; - - // - // static methods - // - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - *

      - *
    1. query the system property using System.getProperty - *
    2. read META-INF/services/factoryId file - *
    3. use fallback classname - *
    - * - * @return Class object of factory, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - static Object createObject(String factoryId, String fallbackClassName) - throws ConfigurationError { - return createObject(factoryId, null, fallbackClassName); - } // createObject(String,String):Object - - /** - * Finds the implementation Class object in the specified order. The - * specified order is the following: - *
      - *
    1. query the system property using System.getProperty - *
    2. read $java.home/lib/propertiesFilename file - *
    3. read META-INF/services/factoryId file - *
    4. use fallback classname - *
    - * - * @return Class object of factory, never null - * - * @param factoryId Name of the factory to find, same as - * a property name - * @param propertiesFilename The filename in the $java.home/lib directory - * of the properties file. If none specified, - * ${java.home}/lib/xerces.properties will be used. - * @param fallbackClassName Implementation class name, if nothing else - * is found. Use null to mean no fallback. - * - * @exception ObjectFactory.ConfigurationError - */ - static Object createObject(String factoryId, - String propertiesFilename, - String fallbackClassName) - throws ConfigurationError - { - if (DEBUG) debugPrintln("debug is on"); - - SecuritySupport ss = SecuritySupport.getInstance(); - ClassLoader cl = findClassLoader(); - - // Use the system property first - try { - String systemProp = ss.getSystemProperty(factoryId); - if (systemProp != null) { - if (DEBUG) debugPrintln("found system property, value=" + systemProp); - return newInstance(systemProp, cl, true); - } - } catch (SecurityException se) { - // Ignore and continue w/ next location - } - - // JAXP specific change - // always use fallback class to avoid the expense of constantly - // "stat"ing a non-existent "xerces.properties" and jar SPI entry - // see CR 6400863: Expensive creating of SAX parser in Mustang - if (true) { - if (fallbackClassName == null) { - throw new ConfigurationError( - "Provider for " + factoryId + " cannot be found", null); - } - - if (DEBUG) debugPrintln("using fallback, value=" + fallbackClassName); - return newInstance(fallbackClassName, cl, true); - } - - // Try to read from propertiesFilename, or $java.home/lib/xerces.properties - String factoryClassName = null; - // no properties file name specified; use $JAVA_HOME/lib/xerces.properties: - if (propertiesFilename == null) { - File propertiesFile = null; - boolean propertiesFileExists = false; - try { - String javah = ss.getSystemProperty("java.home"); - propertiesFilename = javah + File.separator + - "lib" + File.separator + DEFAULT_PROPERTIES_FILENAME; - propertiesFile = new File(propertiesFilename); - propertiesFileExists = ss.getFileExists(propertiesFile); - } catch (SecurityException e) { - // try again... - fLastModified = -1; - fXercesProperties = null; - } - - synchronized (ObjectFactory.class) { - boolean loadProperties = false; - FileInputStream fis = null; - try { - // file existed last time - if(fLastModified >= 0) { - if(propertiesFileExists && - (fLastModified < (fLastModified = ss.getLastModified(propertiesFile)))) { - loadProperties = true; - } else { - // file has stopped existing... - if(!propertiesFileExists) { - fLastModified = -1; - fXercesProperties = null; - } // else, file wasn't modified! - } - } else { - // file has started to exist: - if(propertiesFileExists) { - loadProperties = true; - fLastModified = ss.getLastModified(propertiesFile); - } // else, nothing's changed - } - if(loadProperties) { - // must never have attempted to read xerces.properties before (or it's outdeated) - fXercesProperties = new Properties(); - fis = ss.getFileInputStream(propertiesFile); - fXercesProperties.load(fis); - } - } catch (Exception x) { - fXercesProperties = null; - fLastModified = -1; - // assert(x instanceof FileNotFoundException - // || x instanceof SecurityException) - // In both cases, ignore and continue w/ next location - } - finally { - // try to close the input stream if one was opened. - if (fis != null) { - try { - fis.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - } - } - if(fXercesProperties != null) { - factoryClassName = fXercesProperties.getProperty(factoryId); - } - } else { - FileInputStream fis = null; - try { - fis = ss.getFileInputStream(new File(propertiesFilename)); - Properties props = new Properties(); - props.load(fis); - factoryClassName = props.getProperty(factoryId); - } catch (Exception x) { - // assert(x instanceof FileNotFoundException - // || x instanceof SecurityException) - // In both cases, ignore and continue w/ next location - } - finally { - // try to close the input stream if one was opened. - if (fis != null) { - try { - fis.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - } - } - if (factoryClassName != null) { - if (DEBUG) debugPrintln("found in " + propertiesFilename + ", value=" + factoryClassName); - return newInstance(factoryClassName, cl, true); - } - - // Try Jar Service Provider Mechanism - Object provider = findJarServiceProvider(factoryId); - if (provider != null) { - return provider; - } - - if (fallbackClassName == null) { - throw new ConfigurationError( - "Provider for " + factoryId + " cannot be found", null); - } - - if (DEBUG) debugPrintln("using fallback, value=" + fallbackClassName); - return newInstance(fallbackClassName, cl, true); - } // createObject(String,String,String):Object - - // - // Private static methods - // - - /** Prints a message to standard error if debugging is enabled. */ - private static void debugPrintln(String msg) { - if (DEBUG) { - System.err.println("JAXP: " + msg); - } - } // debugPrintln(String) - - /** - * Figure out which ClassLoader to use. For JDK 1.2 and later use - * the context ClassLoader. - */ - static ClassLoader findClassLoader() - throws ConfigurationError - { - SecuritySupport ss = SecuritySupport.getInstance(); - - // Figure out which ClassLoader to use for loading the provider - // class. If there is a Context ClassLoader then use it. - ClassLoader context = ss.getContextClassLoader(); - ClassLoader system = ss.getSystemClassLoader(); - - ClassLoader chain = system; - while (true) { - if (context == chain) { - // Assert: we are on JDK 1.1 or we have no Context ClassLoader - // or any Context ClassLoader in chain of system classloader - // (including extension ClassLoader) so extend to widest - // ClassLoader (always look in system ClassLoader if Xerces - // is in boot/extension/system classpath and in current - // ClassLoader otherwise); normal classloaders delegate - // back to system ClassLoader first so this widening doesn't - // change the fact that context ClassLoader will be consulted - ClassLoader current = ObjectFactory.class.getClassLoader(); - - chain = system; - while (true) { - if (current == chain) { - // Assert: Current ClassLoader in chain of - // boot/extension/system ClassLoaders - return system; - } - if (chain == null) { - break; - } - chain = ss.getParentClassLoader(chain); - } - - // Assert: Current ClassLoader not in chain of - // boot/extension/system ClassLoaders - return current; - } - - if (chain == null) { - // boot ClassLoader reached - break; - } - - // Check for any extension ClassLoaders in chain up to - // boot ClassLoader - chain = ss.getParentClassLoader(chain); - }; - - // Assert: Context ClassLoader not in chain of - // boot/extension/system ClassLoaders - return context; - } // findClassLoader():ClassLoader - - /** - * Create an instance of a class using the specified ClassLoader - */ - static Object newInstance(String className, ClassLoader cl, - boolean doFallback) - throws ConfigurationError - { - // assert(className != null); - try{ - Class providerClass = findProviderClass(className, cl, doFallback); - Object instance = providerClass.newInstance(); - if (DEBUG) debugPrintln("created new instance of " + providerClass + - " using ClassLoader: " + cl); - return instance; - } catch (ClassNotFoundException x) { - throw new ConfigurationError( - "Provider " + className + " not found", x); - } catch (Exception x) { - throw new ConfigurationError( - "Provider " + className + " could not be instantiated: " + x, - x); - } - } - - /** - * Find a Class using the specified ClassLoader - */ - static Class findProviderClass(String className, ClassLoader cl, - boolean doFallback) - throws ClassNotFoundException, ConfigurationError - { - //throw security exception if the calling thread is not allowed to access the package - //restrict the access to package as speicified in java.security policy - SecurityManager security = System.getSecurityManager(); - if (security != null) { - final int lastDot = className.lastIndexOf("."); - String packageName = className; - if (lastDot != -1) packageName = className.substring(0, lastDot); - security.checkPackageAccess(packageName); - } - Class providerClass; - if (cl == null) { - // XXX Use the bootstrap ClassLoader. There is no way to - // load a class using the bootstrap ClassLoader that works - // in both JDK 1.1 and Java 2. However, this should still - // work b/c the following should be true: - // - // (cl == null) iff current ClassLoader == null - // - // Thus Class.forName(String) will use the current - // ClassLoader which will be the bootstrap ClassLoader. - providerClass = Class.forName(className); - } else { - try { - providerClass = cl.loadClass(className); - } catch (ClassNotFoundException x) { - if (doFallback) { - // Fall back to current classloader - ClassLoader current = ObjectFactory.class.getClassLoader(); - if (current == null) { - providerClass = Class.forName(className); - } else if (cl != current) { - cl = current; - providerClass = cl.loadClass(className); - } else { - throw x; - } - } else { - throw x; - } - } - } - - return providerClass; - } - - /* - * Try to find provider using Jar Service Provider Mechanism - * - * @return instance of provider class if found or null - */ - private static Object findJarServiceProvider(String factoryId) - throws ConfigurationError - { - SecuritySupport ss = SecuritySupport.getInstance(); - String serviceId = "META-INF/services/" + factoryId; - InputStream is = null; - - // First try the Context ClassLoader - ClassLoader cl = findClassLoader(); - - is = ss.getResourceAsStream(cl, serviceId); - - // If no provider found then try the current ClassLoader - if (is == null) { - ClassLoader current = ObjectFactory.class.getClassLoader(); - if (cl != current) { - cl = current; - is = ss.getResourceAsStream(cl, serviceId); - } - } - - if (is == null) { - // No provider found - return null; - } - - if (DEBUG) debugPrintln("found jar resource=" + serviceId + - " using ClassLoader: " + cl); - - // Read the service provider name in UTF-8 as specified in - // the jar spec. Unfortunately this fails in Microsoft - // VJ++, which does not implement the UTF-8 - // encoding. Theoretically, we should simply let it fail in - // that case, since the JVM is obviously broken if it - // doesn't support such a basic standard. But since there - // are still some users attempting to use VJ++ for - // development, we have dropped in a fallback which makes a - // second attempt using the platform's default encoding. In - // VJ++ this is apparently ASCII, which is a subset of - // UTF-8... and since the strings we'll be reading here are - // also primarily limited to the 7-bit ASCII range (at - // least, in English versions), this should work well - // enough to keep us on the air until we're ready to - // officially decommit from VJ++. [Edited comment from - // jkesselm] - BufferedReader rd; - try { - rd = new BufferedReader(new InputStreamReader(is, "UTF-8"), DEFAULT_LINE_LENGTH); - } catch (java.io.UnsupportedEncodingException e) { - rd = new BufferedReader(new InputStreamReader(is), DEFAULT_LINE_LENGTH); - } - - String factoryClassName = null; - try { - // XXX Does not handle all possible input as specified by the - // Jar Service Provider specification - factoryClassName = rd.readLine(); - } catch (IOException x) { - // No provider found - return null; - } - finally { - try { - // try to close the reader. - rd.close(); - } - // Ignore the exception. - catch (IOException exc) {} - } - - if (factoryClassName != null && - ! "".equals(factoryClassName)) { - if (DEBUG) debugPrintln("found in resource, value=" - + factoryClassName); - - // Note: here we do not want to fall back to the current - // ClassLoader because we want to avoid the case where the - // resource file was found using one ClassLoader and the - // provider class was instantiated using a different one. - return newInstance(factoryClassName, cl, false); - } - - // No provider found - return null; - } - - // - // Classes - // - - /** - * A configuration error. - */ - static final class ConfigurationError - extends Error { - - /** Serialization version. */ - static final long serialVersionUID = 937647395548533254L; - - // - // Data - // - - /** Exception. */ - private Exception exception; - - // - // Constructors - // - - /** - * Construct a new instance with the specified detail string and - * exception. - */ - ConfigurationError(String msg, Exception x) { - super(msg); - this.exception = x; - } // (String,Exception) - - // - // methods - // - - /** Returns the exception associated to this error. */ - Exception getException() { - return exception; - } // getException():Exception - - } // class ConfigurationError - -} // class ObjectFactory From 4a4457b2374081f3f29878512f5b64133971961e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Borggr=C3=A9n-Franck?= Date: Tue, 21 May 2013 12:00:29 +0200 Subject: [PATCH 025/206] 8013180: Qualified type reference with annotations in throws list crashes compiler Reviewed-by: jjg --- .../8013180/QualifiedName.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 langtools/test/tools/javac/annotations/typeAnnotations/8013180/QualifiedName.java diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/8013180/QualifiedName.java b/langtools/test/tools/javac/annotations/typeAnnotations/8013180/QualifiedName.java new file mode 100644 index 00000000000..5661e837240 --- /dev/null +++ b/langtools/test/tools/javac/annotations/typeAnnotations/8013180/QualifiedName.java @@ -0,0 +1,39 @@ +/* + * 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.lang.annotation.ElementType; +import java.lang.annotation.Target; + +/* + * @test + * @bug 8013180 + * @summary Qualified type annotation name used to crash javac + * @compile QualifiedName.java + */ + +public class QualifiedName { + @Target(ElementType.TYPE_USE) @interface TA { } + class E extends Exception { } + + void m() throws @TA QualifiedName.@TA E { } +} From a95cb95e1f436900cc3f3a5cdd2dc9e6e244d36d Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Tue, 21 May 2013 11:41:21 +0100 Subject: [PATCH 026/206] 7177168: Redundant array copy in UnsharedNameTable Reviewed-by: mcimadamore --- .../classes/com/sun/tools/javac/util/UnsharedNameTable.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/UnsharedNameTable.java b/langtools/src/share/classes/com/sun/tools/javac/util/UnsharedNameTable.java index fe88c122805..ab4c0b881e6 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/UnsharedNameTable.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/UnsharedNameTable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, 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 @@ -125,8 +125,6 @@ public class UnsharedNameTable extends Name.Table { System.arraycopy(cs, start, bytes, 0, len); n = new NameImpl(this, bytes, index++); - System.arraycopy(cs, start, n.bytes, 0, len); - HashEntry newEntry = new HashEntry(n); if (previousNonNullTableEntry == null) { // We are not the first name with that hashCode. From a24da777522a45f415856047e8a4bc6185b7a757 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Tue, 21 May 2013 12:17:18 +0100 Subject: [PATCH 027/206] 7060779: test/tools/javac/diags/Example.java leaves directories in tempdir Reviewed-by: mcimadamore --- langtools/test/tools/javac/diags/Example.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/langtools/test/tools/javac/diags/Example.java b/langtools/test/tools/javac/diags/Example.java index 61007440203..b53b1aa2673 100644 --- a/langtools/test/tools/javac/diags/Example.java +++ b/langtools/test/tools/javac/diags/Example.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -296,7 +296,10 @@ class Example implements Comparable { private Set actualKeys; private Set declaredKeys; - static File tempDir = new File(System.getProperty("java.io.tmpdir")); + static File tempDir = (System.getProperty("test.src") != null) ? + new File(System.getProperty("user.dir")): + new File(System.getProperty("java.io.tmpdir")); + static void setTempDir(File tempDir) { Example.tempDir = tempDir; } From 1a3b9278eb287f71508fa1ac2ecf77b1266d283a Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Tue, 21 May 2013 13:40:12 +0200 Subject: [PATCH 028/206] 8014953: Have NativeJavaPackage throw a ClassNotFoundException when invoked Reviewed-by: jlaskey, sundar --- .../internal/runtime/NativeJavaPackage.java | 37 +++++++++++++++ nashorn/test/script/basic/JDK-8014953.js | 45 +++++++++++++++++++ .../test/script/basic/JDK-8014953.js.EXPECTED | 6 +++ 3 files changed, 88 insertions(+) create mode 100644 nashorn/test/script/basic/JDK-8014953.js create mode 100644 nashorn/test/script/basic/JDK-8014953.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java b/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java index b10b72df0ac..883ff85cf1f 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java @@ -25,10 +25,16 @@ package jdk.nashorn.internal.runtime; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.beans.StaticClass; import jdk.internal.dynalink.linker.GuardedInvocation; import jdk.internal.dynalink.linker.LinkRequest; +import jdk.internal.dynalink.support.Guards; +import jdk.nashorn.internal.lookup.MethodHandleFactory; +import jdk.nashorn.internal.lookup.MethodHandleFunctionality; import jdk.nashorn.internal.objects.NativeJava; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Function; @@ -65,6 +71,10 @@ import jdk.nashorn.internal.objects.annotations.Function; *
    */ public final class NativeJavaPackage extends ScriptObject { + private static final MethodHandleFunctionality MH = MethodHandleFactory.getFunctionality(); + private static final MethodHandle CLASS_NOT_FOUND = findOwnMH("classNotFound", Void.TYPE, NativeJavaPackage.class); + private static final MethodHandle TYPE_GUARD = Guards.getClassGuard(NativeJavaPackage.class); + /** Full name of package (includes path.) */ private final String name; @@ -123,6 +133,30 @@ public final class NativeJavaPackage extends ScriptObject { return super.getDefaultValue(hint); } + @Override + protected GuardedInvocation findNewMethod(CallSiteDescriptor desc) { + return createClassNotFoundInvocation(desc); + } + + @Override + protected GuardedInvocation findCallMethod(CallSiteDescriptor desc, LinkRequest request) { + return createClassNotFoundInvocation(desc); + } + + private static GuardedInvocation createClassNotFoundInvocation(final CallSiteDescriptor desc) { + // If NativeJavaPackage is invoked either as a constructor or as a function, throw a ClassNotFoundException as + // we can assume the user attempted to instantiate a non-existent class. + final MethodType type = desc.getMethodType(); + return new GuardedInvocation( + MH.dropArguments(CLASS_NOT_FOUND, 1, type.parameterList().subList(1, type.parameterCount())), + type.parameterType(0) == NativeJavaPackage.class ? null : TYPE_GUARD); + } + + @SuppressWarnings("unused") + private static void classNotFound(final NativeJavaPackage pkg) throws ClassNotFoundException { + throw new ClassNotFoundException(pkg.name); + } + /** * "No such property" call placeholder. * @@ -188,4 +222,7 @@ public final class NativeJavaPackage extends ScriptObject { return noSuchProperty(desc, request); } + private static MethodHandle findOwnMH(final String name, final Class rtype, final Class... types) { + return MH.findStatic(MethodHandles.lookup(), NativeJavaPackage.class, name, MH.type(rtype, types)); + } } diff --git a/nashorn/test/script/basic/JDK-8014953.js b/nashorn/test/script/basic/JDK-8014953.js new file mode 100644 index 00000000000..ba7cef0f9ef --- /dev/null +++ b/nashorn/test/script/basic/JDK-8014953.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8014953: Have NativeJavaPackage throw a ClassNotFoundException when invoked with "new" + * + * @test + * @run + */ + +try { + new java.util.ArrrayList(16) +} catch(e) { + print("Invoked as constructor"); + print("e.class=" + e.class) + print("e.message=" + e.message); +} + +try { + java.util.ArrrayList(16) +} catch(e) { + print("Invoked as method"); + print("e.class=" + e.class) + print("e.message=" + e.message); +} diff --git a/nashorn/test/script/basic/JDK-8014953.js.EXPECTED b/nashorn/test/script/basic/JDK-8014953.js.EXPECTED new file mode 100644 index 00000000000..d371112156b --- /dev/null +++ b/nashorn/test/script/basic/JDK-8014953.js.EXPECTED @@ -0,0 +1,6 @@ +Invoked as constructor +e.class=class java.lang.ClassNotFoundException +e.message=java.util.ArrrayList +Invoked as method +e.class=class java.lang.ClassNotFoundException +e.message=java.util.ArrrayList From 6a02cd46e05d40a54a0a23d6bdd4b6883b974003 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Tue, 21 May 2013 13:50:56 +0100 Subject: [PATCH 029/206] 8005207: test has 2 @bug tags Reviewed-by: mcimadamore --- langtools/test/tools/doclint/RunTest.java | 14 +-- langtools/test/tools/javac/5045412/Bar.java | 8 +- langtools/test/tools/javac/5045412/Foo.java | 7 +- .../lambda/MethodReferenceParserTest.java | 3 +- .../tools/javac/lambda/TestInvokeDynamic.java | 23 +++-- .../mandatoryWarnings/deprecated/Test.java | 92 +------------------ .../mandatoryWarnings/unchecked/Test.java | 80 +--------------- .../test/tools/javac/policy/test3/Test.java | 46 +--------- 8 files changed, 22 insertions(+), 251 deletions(-) diff --git a/langtools/test/tools/doclint/RunTest.java b/langtools/test/tools/doclint/RunTest.java index d42b02364f1..99662e7bac7 100644 --- a/langtools/test/tools/doclint/RunTest.java +++ b/langtools/test/tools/doclint/RunTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -22,20 +22,13 @@ */ /* @test - * @bug 8004832 + * @bug 8004832 8000103 * @summary Add new doclint package - * @bug 8000103 * @summary Create doclint utility */ -import com.sun.tools.doclint.DocLint; -import com.sun.tools.doclint.DocLint.BadArgs; -import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FilterOutputStream; import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.annotation.Annotation; @@ -44,6 +37,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import com.sun.tools.doclint.DocLint; +import com.sun.tools.doclint.DocLint.BadArgs; + /** javadoc error on toplevel: a & b. */ public class RunTest { /** javadoc error on member: a < b */ diff --git a/langtools/test/tools/javac/5045412/Bar.java b/langtools/test/tools/javac/5045412/Bar.java index 9225d54f1fb..867a313a538 100644 --- a/langtools/test/tools/javac/5045412/Bar.java +++ b/langtools/test/tools/javac/5045412/Bar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -21,12 +21,6 @@ * questions. */ -/** - * @test - * @bug 5045412 6627366 - * @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Bar.java - */ - /** * @test * @bug 5045412 6627366 diff --git a/langtools/test/tools/javac/5045412/Foo.java b/langtools/test/tools/javac/5045412/Foo.java index a797566e783..dbbc6184f3f 100644 --- a/langtools/test/tools/javac/5045412/Foo.java +++ b/langtools/test/tools/javac/5045412/Foo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -25,11 +25,6 @@ * @test * @bug 5045412 6627366 * @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Foo.java - */ - -/** - * @test - * @bug 5045412 6627366 * @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Foo.java Bar.java */ diff --git a/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java b/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java index 3366f902644..513f1e37765 100644 --- a/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java +++ b/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java @@ -23,8 +23,7 @@ /* * @test - * @bug 7115052 - * @bug 8003280 8006694 + * @bug 7115052 8003280 8006694 * @summary Add lambda tests * Add parser support for method references * temporarily workaround combo tests are causing time out in several platforms diff --git a/langtools/test/tools/javac/lambda/TestInvokeDynamic.java b/langtools/test/tools/javac/lambda/TestInvokeDynamic.java index a804d04fb38..3a3a03f2816 100644 --- a/langtools/test/tools/javac/lambda/TestInvokeDynamic.java +++ b/langtools/test/tools/javac/lambda/TestInvokeDynamic.java @@ -23,8 +23,7 @@ /* * @test - * @bug 7194586 - * @bug 8003280 8006694 8010404 + * @bug 7194586 8003280 8006694 8010404 * @summary Add lambda tests * Add back-end support for invokedynamic * temporarily workaround combo tests are causing time out in several platforms @@ -36,6 +35,16 @@ // use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047) // see JDK-8006746 +import java.io.File; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Locale; + +import javax.tools.Diagnostic; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; + import com.sun.source.tree.MethodInvocationTree; import com.sun.source.tree.MethodTree; import com.sun.source.util.TaskEvent; @@ -63,16 +72,6 @@ import com.sun.tools.javac.tree.JCTree.JCIdent; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Names; -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Locale; - -import javax.tools.Diagnostic; -import javax.tools.JavaFileObject; -import javax.tools.SimpleJavaFileObject; - import static com.sun.tools.javac.jvm.ClassFile.*; public class TestInvokeDynamic diff --git a/langtools/test/tools/javac/mandatoryWarnings/deprecated/Test.java b/langtools/test/tools/javac/mandatoryWarnings/deprecated/Test.java index 28e3e2f222b..edaae6e5f27 100644 --- a/langtools/test/tools/javac/mandatoryWarnings/deprecated/Test.java +++ b/langtools/test/tools/javac/mandatoryWarnings/deprecated/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -29,109 +29,19 @@ * @bug 5047307 * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test1.out -XDrawDiagnostics A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test1.out -XDrawDiagnostics -nowarn A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test1.out -XDrawDiagnostics -Xmaxwarns 1 A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test2.out -XDrawDiagnostics A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test2.out -XDrawDiagnostics -nowarn A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test2.out -XDrawDiagnostics -Xmaxwarns 1 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test3.out -XDrawDiagnostics -Xlint:deprecation A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test3.out -XDrawDiagnostics -nowarn -Xlint:deprecation A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test3b.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 1 A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4.out -XDrawDiagnostics -Xlint:deprecation A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4.out -XDrawDiagnostics -nowarn -Xlint:deprecation A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4b.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 1 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4c.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 2 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4d.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 3 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test5.out -XDrawDiagnostics -Xlint:deprecation P.java Q.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test5b.out -XDrawDiagnostics -Xlint:deprecation -Xmaxwarns 2 P.java Q.java */ diff --git a/langtools/test/tools/javac/mandatoryWarnings/unchecked/Test.java b/langtools/test/tools/javac/mandatoryWarnings/unchecked/Test.java index 6bce09f55fd..434889cb8ec 100644 --- a/langtools/test/tools/javac/mandatoryWarnings/unchecked/Test.java +++ b/langtools/test/tools/javac/mandatoryWarnings/unchecked/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -29,95 +29,17 @@ * @bug 5047307 * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test1.out -XDrawDiagnostics A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test1.out -XDrawDiagnostics -nowarn A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test1.out -XDrawDiagnostics -Xmaxwarns 1 A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test2.out -XDrawDiagnostics A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test2.out -XDrawDiagnostics -nowarn A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test2.out -XDrawDiagnostics -Xmaxwarns 1 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test3.out -XDrawDiagnostics -Xlint:unchecked A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test3.out -XDrawDiagnostics -nowarn -Xlint:unchecked A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test3b.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 1 A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4.out -XDrawDiagnostics -Xlint:unchecked A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4.out -XDrawDiagnostics -nowarn -Xlint:unchecked A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4b.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 1 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4c.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 2 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4d.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 3 A.java B.java */ diff --git a/langtools/test/tools/javac/policy/test3/Test.java b/langtools/test/tools/javac/policy/test3/Test.java index d26ef8e22f6..fafc872c38a 100644 --- a/langtools/test/tools/javac/policy/test3/Test.java +++ b/langtools/test/tools/javac/policy/test3/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -123,47 +123,3 @@ public class Test { int errors; } - - - - - - - - - - - - -// These tests test the ability of the compiler to continue in the face of -// errors, accordining to the shouldStopPolicy - -/* @ test /nodynamiccopyright/ - * @bug 6813059 - * @summary - * @compile/fail/ref=flow.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=FLOW Test.java - - * @compile/fail/ref=default.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy Test.java - * @compile/fail/ref=enter.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=ENTER Test.java - * @compile/fail/ref=attr.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=ATTR Test.java - * @compile/fail/ref=transtypes.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=TRANSTYPES Test.java - * @compile/fail/ref=lower.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=LOWER Test.java - * @compile/fail/ref=generate.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=GENERATE Test.java - */ - -/* -class Test { - void m1() { - System.err.println("hello"); - 0 // syntax error - System.err.println("world"); - } - - void m2() { - } -} - -class Test2 { -} -*/ - From 9e9c04939b7e647a72b0f55ccfdb19f91317c328 Mon Sep 17 00:00:00 2001 From: James Laskey Date: Tue, 21 May 2013 10:17:09 -0300 Subject: [PATCH 030/206] 8014827: readLine should accept a prompt as an argument Reviewed-by: sundar, hannesw --- .../nashorn/internal/runtime/ScriptingFunctions.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java index 596ec1bf955..1d046ca96c8 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java @@ -46,7 +46,7 @@ import java.util.StringTokenizer; public final class ScriptingFunctions { /** Handle to implementation of {@link ScriptingFunctions#readLine} - Nashorn extension */ - public static final MethodHandle READLINE = findOwnMH("readLine", Object.class, Object.class); + public static final MethodHandle READLINE = findOwnMH("readLine", Object.class, Object.class, Object.class); /** Handle to implementation of {@link ScriptingFunctions#readFully} - Nashorn extension */ public static final MethodHandle READFULLY = findOwnMH("readFully", Object.class, Object.class, Object.class); @@ -78,13 +78,17 @@ public final class ScriptingFunctions { * Nashorn extension: global.readLine (scripting-mode-only) * Read one line of input from the standard input. * - * @param self self reference + * @param self self reference + * @param prompt String used as input prompt * * @return line that was read * * @throws IOException if an exception occurs */ - public static Object readLine(final Object self) throws IOException { + public static Object readLine(final Object self, final Object prompt) throws IOException { + if (prompt != UNDEFINED) { + System.out.print(JSType.toString(prompt)); + } final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); return reader.readLine(); } From 5b545ba465d87772b9c3f1999d1ff24e479a7ffb Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Tue, 21 May 2013 14:33:09 +0100 Subject: [PATCH 031/206] 7164114: Two jtreg tests are not run due to no file extension on the test files Reviewed-by: mcimadamore --- .../tools/javac/HiddenAbstractMethod/{Test => Test.java} | 2 +- .../tools/javac/NonAmbiguousField/{Test => Test.java} | 4 ++-- .../test/tools/javac/NonAmbiguousField/two/Child2.java | 8 +++----- 3 files changed, 6 insertions(+), 8 deletions(-) rename langtools/test/tools/javac/HiddenAbstractMethod/{Test => Test.java} (87%) rename langtools/test/tools/javac/NonAmbiguousField/{Test => Test.java} (60%) diff --git a/langtools/test/tools/javac/HiddenAbstractMethod/Test b/langtools/test/tools/javac/HiddenAbstractMethod/Test.java similarity index 87% rename from langtools/test/tools/javac/HiddenAbstractMethod/Test rename to langtools/test/tools/javac/HiddenAbstractMethod/Test.java index d511864c42e..775eb1b8509 100644 --- a/langtools/test/tools/javac/HiddenAbstractMethod/Test +++ b/langtools/test/tools/javac/HiddenAbstractMethod/Test.java @@ -8,5 +8,5 @@ * the method has the same name, it does not override. * @author turnidge * - * @compile/fail -nowrite one/Parent.java two/Child.java + * @compile/fail one/Parent.java two/Child.java */ diff --git a/langtools/test/tools/javac/NonAmbiguousField/Test b/langtools/test/tools/javac/NonAmbiguousField/Test.java similarity index 60% rename from langtools/test/tools/javac/NonAmbiguousField/Test rename to langtools/test/tools/javac/NonAmbiguousField/Test.java index fb4cfd79a85..131bc8705c1 100644 --- a/langtools/test/tools/javac/NonAmbiguousField/Test +++ b/langtools/test/tools/javac/NonAmbiguousField/Test.java @@ -5,6 +5,6 @@ * compiler as ambigous. * @author turnidge * - * @compile -nowrite one/Parent.java two/Child.java - * @compile -nowrite one/Parent2.java two/Child2.java + * @compile one/Parent.java two/Child.java + * @compile/fail one/Parent2.java two/Child2.java */ diff --git a/langtools/test/tools/javac/NonAmbiguousField/two/Child2.java b/langtools/test/tools/javac/NonAmbiguousField/two/Child2.java index 64fcc52dc4c..13ce68f937a 100644 --- a/langtools/test/tools/javac/NonAmbiguousField/two/Child2.java +++ b/langtools/test/tools/javac/NonAmbiguousField/two/Child2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -28,9 +28,7 @@ interface I { } public class Child2 extends one.Parent2 implements I { - class inner { - void method() { - System.out.println(i); - } + void method() { + System.out.println(i); } } From de93893f4e5583fbebf688351f7fc606d6e8eac1 Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Tue, 21 May 2013 09:43:23 -0700 Subject: [PATCH 032/206] 8013726: runtime/memory/ReserveMemory.java fails due to 'assert(bytes % os::vm_allocation_granularity() == 0) failed: reserve block size' Fix regression test to work on all platforms Reviewed-by: ctornqvi, dholmes --- hotspot/src/share/vm/prims/whitebox.cpp | 17 ++++++++++++--- .../test/runtime/memory/ReserveMemory.java | 21 +++++++------------ .../whitebox/sun/hotspot/WhiteBox.java | 2 +- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index 7742c036114..92f2349bb7c 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -37,6 +37,7 @@ #include "runtime/os.hpp" #include "utilities/debug.hpp" #include "utilities/macros.hpp" +#include "utilities/exceptions.hpp" #if INCLUDE_ALL_GCS #include "gc_implementation/g1/concurrentMark.hpp" @@ -330,8 +331,18 @@ WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o)) WB_END -WB_ENTRY(jlong, WB_ReserveMemory(JNIEnv* env, jobject o, jlong size)) - return (jlong)os::reserve_memory(size, NULL, 0); +WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o)) + // static+volatile in order to force the read to happen + // (not be eliminated by the compiler) + static char c; + static volatile char* p; + + p = os::reserve_memory(os::vm_allocation_granularity(), NULL, 0); + if (p == NULL) { + THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), "Failed to reserve memory"); + } + + c = *p; WB_END //Some convenience methods to deal with objects from java @@ -437,7 +448,7 @@ static JNINativeMethod methods[] = { {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, {CC"fullGC", CC"()V", (void*)&WB_FullGC }, - {CC"reserveMemory", CC"(J)J", (void*)&WB_ReserveMemory }, + {CC"readReservedMemory", CC"()V", (void*)&WB_ReadReservedMemory }, }; #undef CC diff --git a/hotspot/test/runtime/memory/ReserveMemory.java b/hotspot/test/runtime/memory/ReserveMemory.java index fbf1a413371..4d234d34d80 100644 --- a/hotspot/test/runtime/memory/ReserveMemory.java +++ b/hotspot/test/runtime/memory/ReserveMemory.java @@ -34,29 +34,20 @@ import com.oracle.java.testlibrary.*; -import java.lang.reflect.Field; import sun.hotspot.WhiteBox; -import sun.misc.Unsafe; public class ReserveMemory { - private static Unsafe getUnsafe() throws Exception { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - return (Unsafe)f.get(null); - } - private static boolean isWindows() { return System.getProperty("os.name").toLowerCase().startsWith("win"); } + private static boolean isOsx() { + return System.getProperty("os.name").toLowerCase().startsWith("mac"); + } + public static void main(String args[]) throws Exception { if (args.length > 0) { - long address = WhiteBox.getWhiteBox().reserveMemory(4096); - - System.out.println("Reserved memory at address: 0x" + Long.toHexString(address)); - System.out.println("Will now read from the address, expecting a crash!"); - - int x = getUnsafe().getInt(address); + WhiteBox.getWhiteBox().readReservedMemory(); throw new Exception("Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!"); } @@ -71,6 +62,8 @@ public class ReserveMemory { OutputAnalyzer output = new OutputAnalyzer(pb.start()); if (isWindows()) { output.shouldContain("EXCEPTION_ACCESS_VIOLATION"); + } else if (isOsx()) { + output.shouldContain("SIGBUS"); } else { output.shouldContain("SIGSEGV"); } diff --git a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java index cd3f576d986..3e451213311 100644 --- a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java +++ b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java @@ -115,7 +115,7 @@ public class WhiteBox { public native boolean isInStringTable(String str); // Memory - public native long reserveMemory(long size); + public native void readReservedMemory(); // force Full GC public native void fullGC(); From 19da55568fd2ac858fb02edf91f2589b173e4213 Mon Sep 17 00:00:00 2001 From: Bharadwaj Yadavalli Date: Tue, 21 May 2013 16:17:51 -0700 Subject: [PATCH 033/206] 8014059: JSR292: Failed to reject invalid class cplmhl00201m28n Restrict reference of interface methods by invokestatic and invokespecial to classfile version 52 or later. Reviewed-by: kvn, hseigel --- hotspot/src/share/vm/classfile/classFileParser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 6b2ddd140c6..f7676c0def4 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -444,8 +444,8 @@ constantPoolHandle ClassFileParser::parse_constant_pool(TRAPS) { break; case JVM_REF_invokeStatic: case JVM_REF_invokeSpecial: - check_property( - tag.is_method() || tag.is_interface_method(), + check_property(tag.is_method() || + ((_major_version >= JAVA_8_VERSION) && tag.is_interface_method()), "Invalid constant pool index %u in class file %s (not a method)", ref_index, CHECK_(nullHandle)); break; From a50a5688af6213dd9b171223d5c95ec3fbc0d1e7 Mon Sep 17 00:00:00 2001 From: Tao Mao Date: Tue, 21 May 2013 16:43:41 -0700 Subject: [PATCH 034/206] 8015007: Incorrect print format in error message for VM cannot allocate the requested heap Correct the wrong print format in error message for VM cannot allocate the requested heap; and clean up the error message call in check_alignment() Reviewed-by: brutisso, tschatzl --- hotspot/src/share/vm/memory/universe.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 77fc4b846c8..22af6d6906c 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -228,11 +228,8 @@ void Universe::serialize(SerializeClosure* f, bool do_all) { void Universe::check_alignment(uintx size, uintx alignment, const char* name) { if (size < alignment || size % alignment != 0) { - ResourceMark rm; - stringStream st; - st.print("Size of %s (" UINTX_FORMAT " bytes) must be aligned to " UINTX_FORMAT " bytes", name, size, alignment); - char* error = st.as_string(); - vm_exit_during_initialization(error); + vm_exit_during_initialization( + err_msg("Size of %s (" UINTX_FORMAT " bytes) must be aligned to " UINTX_FORMAT " bytes", name, size, alignment)); } } @@ -916,7 +913,7 @@ ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) { } if (!total_rs.is_reserved()) { - vm_exit_during_initialization(err_msg("Could not reserve enough space for object heap %d bytes", total_reserved)); + vm_exit_during_initialization(err_msg("Could not reserve enough space for " SIZE_FORMAT "KB object heap", total_reserved/K)); return total_rs; } From 41974c2e0729200c33cec32161143878662e7c46 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 22 May 2013 16:39:48 +0530 Subject: [PATCH 035/206] 8008947: ScriptEnvironment ctor should be public Reviewed-by: lagergren, attila --- nashorn/.hgignore | 1 + nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/nashorn/.hgignore b/nashorn/.hgignore index 56e01bae4c0..6d68c1d476d 100644 --- a/nashorn/.hgignore +++ b/nashorn/.hgignore @@ -24,3 +24,4 @@ jcov2/* .idea/* test/lib/testng.jar test/script/external/* +.project diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java index 3bcf9d4f5a3..c1c25b3eecc 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java @@ -186,7 +186,7 @@ public final class ScriptEnvironment { * @param out output print writer * @param err error print writer */ - ScriptEnvironment(final Options options, final PrintWriter out, final PrintWriter err) { + public ScriptEnvironment(final Options options, final PrintWriter out, final PrintWriter err) { this.out = out; this.err = err; this.namespace = new Namespace(); From 2cd9f2dde4ea0d3a831c16d9fc54a274d48da084 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 22 May 2013 19:33:08 +0530 Subject: [PATCH 036/206] 8014735: Typed Array, BYTES_PER_ELEMENT should be a class property Reviewed-by: lagergren, jlaskey --- .../internal/objects/ArrayBufferView.java | 6 +-- .../internal/objects/NativeFloat32Array.java | 6 ++- .../internal/objects/NativeFloat64Array.java | 6 ++- .../internal/objects/NativeInt16Array.java | 6 ++- .../internal/objects/NativeInt32Array.java | 6 ++- .../internal/objects/NativeInt8Array.java | 6 ++- .../internal/objects/NativeUint16Array.java | 6 ++- .../internal/objects/NativeUint32Array.java | 6 ++- .../internal/objects/NativeUint8Array.java | 6 ++- .../objects/NativeUint8ClampedArray.java | 6 ++- nashorn/test/script/basic/JDK-8014735.js | 43 +++++++++++++++++++ .../test/script/basic/JDK-8014735.js.EXPECTED | 9 ++++ nashorn/test/script/basic/NASHORN-377.js | 4 +- 13 files changed, 100 insertions(+), 16 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8014735.js create mode 100644 nashorn/test/script/basic/JDK-8014735.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java b/nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java index a442a3876c7..ebab47b65f0 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java +++ b/nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java @@ -28,6 +28,7 @@ package jdk.nashorn.internal.objects; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Getter; import jdk.nashorn.internal.objects.annotations.ScriptClass; +import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptRuntime; @@ -58,11 +59,6 @@ abstract class ArrayBufferView extends ScriptObject { return factory().bytesPerElement; } - @Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE) - public static Object BYTES_PER_ELEMENT(final Object self) { - return ((ArrayBufferView)self).bytesPerElement(); - } - @Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE) public static Object buffer(final Object self) { return ((ArrayDataImpl)((ArrayBufferView)self).getArray()).buffer; diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java index 98db34ba046..33d2d9ecc5d 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java @@ -28,7 +28,9 @@ package jdk.nashorn.internal.objects; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; import jdk.nashorn.internal.objects.annotations.Function; +import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.ScriptClass; +import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.arrays.ArrayData; @@ -38,7 +40,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Float32Array") public final class NativeFloat32Array extends ArrayBufferView { - private static final int BYTES_PER_ELEMENT = 4; + @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) + public static final int BYTES_PER_ELEMENT = 4; + private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { @Override public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java index e2ce624753f..ba6bffe8c38 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java @@ -28,7 +28,9 @@ package jdk.nashorn.internal.objects; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; import jdk.nashorn.internal.objects.annotations.Function; +import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.ScriptClass; +import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.arrays.ArrayData; @@ -38,7 +40,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Float64Array") public final class NativeFloat64Array extends ArrayBufferView { - private static final int BYTES_PER_ELEMENT = 8; + @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) + public static final int BYTES_PER_ELEMENT = 8; + private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { @Override public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java index c5951d91760..9afaf3a7ea0 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java @@ -28,7 +28,9 @@ package jdk.nashorn.internal.objects; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; import jdk.nashorn.internal.objects.annotations.Function; +import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.ScriptClass; +import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.arrays.ArrayData; @@ -37,7 +39,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Int16Array") public final class NativeInt16Array extends ArrayBufferView { - private static final int BYTES_PER_ELEMENT = 2; + @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) + public static final int BYTES_PER_ELEMENT = 2; + private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { @Override public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java index 486e7a61fd5..199d223d25d 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java @@ -28,7 +28,9 @@ package jdk.nashorn.internal.objects; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; import jdk.nashorn.internal.objects.annotations.Function; +import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.ScriptClass; +import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.arrays.ArrayData; @@ -37,7 +39,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Int32Array") public final class NativeInt32Array extends ArrayBufferView { - private static final int BYTES_PER_ELEMENT = 4; + @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) + public static final int BYTES_PER_ELEMENT = 4; + private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { @Override public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java index 9ad7d24c280..25e86c23d35 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java @@ -28,7 +28,9 @@ package jdk.nashorn.internal.objects; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; import jdk.nashorn.internal.objects.annotations.Function; +import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.ScriptClass; +import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.arrays.ArrayData; @@ -37,7 +39,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Int8Array") public final class NativeInt8Array extends ArrayBufferView { - private static final int BYTES_PER_ELEMENT = 1; + @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) + public static final int BYTES_PER_ELEMENT = 1; + private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { @Override public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java index 740bb394511..ec5e99d3718 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java @@ -28,7 +28,9 @@ package jdk.nashorn.internal.objects; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; import jdk.nashorn.internal.objects.annotations.Function; +import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.ScriptClass; +import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.arrays.ArrayData; @@ -37,7 +39,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Uint16Array") public final class NativeUint16Array extends ArrayBufferView { - private static final int BYTES_PER_ELEMENT = 2; + @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) + public static final int BYTES_PER_ELEMENT = 2; + private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { @Override public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java index 9be0131202c..d8a3f5240f4 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java @@ -28,7 +28,9 @@ package jdk.nashorn.internal.objects; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; import jdk.nashorn.internal.objects.annotations.Function; +import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.ScriptClass; +import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.arrays.ArrayData; @@ -38,7 +40,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Uint32Array") public final class NativeUint32Array extends ArrayBufferView { - private static final int BYTES_PER_ELEMENT = 4; + @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) + public static final int BYTES_PER_ELEMENT = 4; + private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { @Override public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteBegin, final int length) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java index 7d506c1d6b9..d62818a912b 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java @@ -28,7 +28,9 @@ package jdk.nashorn.internal.objects; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; import jdk.nashorn.internal.objects.annotations.Function; +import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.ScriptClass; +import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.arrays.ArrayData; @@ -37,7 +39,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Uint8Array") public final class NativeUint8Array extends ArrayBufferView { - private static final int BYTES_PER_ELEMENT = 1; + @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) + public static final int BYTES_PER_ELEMENT = 1; + private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { @Override public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java index e3bacc2b9db..7eb3e650714 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java @@ -28,7 +28,9 @@ package jdk.nashorn.internal.objects; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; import jdk.nashorn.internal.objects.annotations.Function; +import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.ScriptClass; +import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.arrays.ArrayData; @@ -38,7 +40,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Uint8ClampedArray") public final class NativeUint8ClampedArray extends ArrayBufferView { - private static final int BYTES_PER_ELEMENT = 1; + @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) + public static final int BYTES_PER_ELEMENT = 1; + private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { @Override public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { diff --git a/nashorn/test/script/basic/JDK-8014735.js b/nashorn/test/script/basic/JDK-8014735.js new file mode 100644 index 00000000000..0fc367c0e96 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8014735.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8014735: Typed Array, BYTES_PER_ELEMENT should be a class property + * + * @test + * @run + */ + +function bytesPerElement(func) { + print(func.name + ".BYTES_PER_ELEMENT = " + func.BYTES_PER_ELEMENT); +} + +bytesPerElement(Int8Array); +bytesPerElement(Int16Array); +bytesPerElement(Int32Array); +bytesPerElement(Uint8Array); +bytesPerElement(Uint8ClampedArray); +bytesPerElement(Uint16Array); +bytesPerElement(Uint32Array); +bytesPerElement(Float32Array); +bytesPerElement(Float64Array); diff --git a/nashorn/test/script/basic/JDK-8014735.js.EXPECTED b/nashorn/test/script/basic/JDK-8014735.js.EXPECTED new file mode 100644 index 00000000000..bae22d618fb --- /dev/null +++ b/nashorn/test/script/basic/JDK-8014735.js.EXPECTED @@ -0,0 +1,9 @@ +Int8Array.BYTES_PER_ELEMENT = 1 +Int16Array.BYTES_PER_ELEMENT = 2 +Int32Array.BYTES_PER_ELEMENT = 4 +Uint8Array.BYTES_PER_ELEMENT = 1 +Uint8ClampedArray.BYTES_PER_ELEMENT = 1 +Uint16Array.BYTES_PER_ELEMENT = 2 +Uint32Array.BYTES_PER_ELEMENT = 4 +Float32Array.BYTES_PER_ELEMENT = 4 +Float64Array.BYTES_PER_ELEMENT = 8 diff --git a/nashorn/test/script/basic/NASHORN-377.js b/nashorn/test/script/basic/NASHORN-377.js index e77be2bf0e9..31d4df4941b 100644 --- a/nashorn/test/script/basic/NASHORN-377.js +++ b/nashorn/test/script/basic/NASHORN-377.js @@ -43,7 +43,7 @@ function tohex(d, w) { function arrstr(a, n, w) { var s = ""; if (typeof n == "undefined") n = a.length; - if (typeof w == "undefined") w = a.BYTES_PER_ELEMENT * 2; + if (typeof w == "undefined") w = a.constructor.BYTES_PER_ELEMENT * 2; for (var i = 0; i < n; i++) { s += tohex(a[i], w); } @@ -96,7 +96,7 @@ function fillArray(a, start) { var b = new ArrayBuffer(8); for (var i in types) { var x = new types[i](b); - print(x.byteOffset, x.byteLength, x.length, x.BYTES_PER_ELEMENT); + print(x.byteOffset, x.byteLength, x.length, x.constructor.BYTES_PER_ELEMENT); assertTrue(function(){ return x.constructor === types[i] }); } })(); From aab1e4573c6fc749058190b8dd12b3c129149ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Wed, 22 May 2013 16:43:48 +0200 Subject: [PATCH 037/206] 8010804: Review long and integer usage conventions Reviewed-by: jlaskey, sundar --- .../internal/codegen/FoldConstants.java | 4 +- .../nashorn/internal/objects/NativeArray.java | 39 ++------- .../nashorn/internal/objects/NativeDate.java | 2 +- .../jdk/nashorn/internal/runtime/JSType.java | 14 ++- nashorn/test/script/basic/JDK-8010804.js | 86 +++++++++++++++++++ .../test/script/basic/JDK-8010804.js.EXPECTED | 42 +++++++++ 6 files changed, 148 insertions(+), 39 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8010804.js create mode 100644 nashorn/test/script/basic/JDK-8010804.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java index 686c9836da6..2e87631c5b6 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java @@ -279,9 +279,9 @@ final class FoldConstants extends NodeVisitor { isLong &= value != 0.0 && JSType.isRepresentableAsLong(value); if (isInteger) { - return LiteralNode.newInstance(token, finish, JSType.toInt32(value)); + return LiteralNode.newInstance(token, finish, (int)value); } else if (isLong) { - return LiteralNode.newInstance(token, finish, JSType.toLong(value)); + return LiteralNode.newInstance(token, finish, (long)value); } return LiteralNode.newInstance(token, finish, value); diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java b/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java index c9a71b57a92..6f9fbcec889 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java @@ -754,25 +754,11 @@ public final class NativeArray extends ScriptObject { final Object obj = Global.toObject(self); final ScriptObject sobj = (ScriptObject)obj; final long len = JSType.toUint32(sobj.getLength()); - final double startNum = JSType.toNumber(start); - final long relativeStartUint32 = JSType.toUint32(startNum); - final long relativeStart = JSType.toInteger(startNum); + final long relativeStart = JSType.toLong(start); + final long relativeEnd = (end == ScriptRuntime.UNDEFINED) ? len : JSType.toLong(end); - long k = relativeStart < 0 ? - Math.max(len + relativeStart, 0) : - Math.min( - Math.max(relativeStartUint32, relativeStart), - len); - - final double endNum = (end == ScriptRuntime.UNDEFINED)? Double.NaN : JSType.toNumber(end); - final long relativeEndUint32 = (end == ScriptRuntime.UNDEFINED)? len : JSType.toUint32(endNum); - final long relativeEnd = (end == ScriptRuntime.UNDEFINED)? len : JSType.toInteger(endNum); - - final long finale = relativeEnd < 0 ? - Math.max(len + relativeEnd, 0) : - Math.min( - Math.max(relativeEndUint32, relativeEnd), - len); + long k = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len); + final long finale = relativeEnd < 0 ? Math.max(len + relativeEnd, 0) : Math.min(relativeEnd, len); if (k >= finale) { return new NativeArray(0); @@ -909,21 +895,10 @@ public final class NativeArray extends ScriptObject { final ScriptObject sobj = (ScriptObject)obj; final boolean strict = Global.isStrict(); final long len = JSType.toUint32(sobj.getLength()); - final double startNum = JSType.toNumber(start); - final long relativeStartUint32 = JSType.toUint32(startNum); - final long relativeStart = JSType.toInteger(startNum); + final long relativeStart = JSType.toLong(start); - //TODO: workaround overflow of relativeStart for start > Integer.MAX_VALUE - final long actualStart = relativeStart < 0 ? - Math.max(len + relativeStart, 0) : - Math.min( - Math.max(relativeStartUint32, relativeStart), - len); - - final long actualDeleteCount = - Math.min( - Math.max(JSType.toInteger(deleteCount), 0), - len - actualStart); + final long actualStart = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len); + final long actualDeleteCount = Math.min(Math.max(JSType.toLong(deleteCount), 0), len - actualStart); final NativeArray array = new NativeArray(actualDeleteCount); diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java b/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java index c97514a3131..fa2c9d17a81 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java @@ -770,7 +770,7 @@ public final class NativeDate extends ScriptObject { nd.setTime(NaN); return nd.getTime(); } - int yearInt = JSType.toInteger(yearNum); + int yearInt = (int)yearNum; if (0 <= yearInt && yearInt <= 99) { yearInt += 1900; } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/JSType.java b/nashorn/src/jdk/nashorn/internal/runtime/JSType.java index e972a99ef63..58669144111 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/JSType.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/JSType.java @@ -565,8 +565,11 @@ public enum JSType { } /** - * JavaScript compliant Object to integer conversion - * See ECMA 9.4 ToInteger + * JavaScript compliant Object to integer conversion. See ECMA 9.4 ToInteger + * + *

    Note that this returns {@link java.lang.Integer#MAX_VALUE} or {@link java.lang.Integer#MIN_VALUE} + * for double values that exceed the int range, including positive and negative Infinity. It is the + * caller's responsibility to handle such values correctly.

    * * @param obj an object * @return an integer @@ -576,8 +579,11 @@ public enum JSType { } /** - * JavaScript compliant Object to long conversion - * See ECMA 9.4 ToInteger + * JavaScript compliant Object to long conversion. See ECMA 9.4 ToInteger + * + *

    Note that this returns {@link java.lang.Long#MAX_VALUE} or {@link java.lang.Long#MIN_VALUE} + * for double values that exceed the long range, including positive and negative Infinity. It is the + * caller's responsibility to handle such values correctly.

    * * @param obj an object * @return a long diff --git a/nashorn/test/script/basic/JDK-8010804.js b/nashorn/test/script/basic/JDK-8010804.js new file mode 100644 index 00000000000..04e216ade24 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8010804.js @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8010804: Review long and integer usage conventions + * + * @test + * @run + */ + +var x = []; +print(x.length); +x[4294967294] = 1; +print(x.length); +x[4294967295] = 1; +print(x.length); +print(x.slice(4294967293).length); +print(x.slice(4294967294).length); +print(x.slice(4294967295).length); +print(x.slice(4294967296).length); + +print(x.slice(-4294967293).length); +print(x.slice(-4294967294).length); +print(x.slice(-4294967295).length); +print(x.slice(-4294967296).length); + +print(x.slice(0, 4294967293).length); +print(x.slice(0, 4294967294).length); +print(x.slice(0, 4294967295).length); +print(x.slice(0, 4294967296).length); + +print(x.slice(0, -4294967293).length); +print(x.slice(0, -4294967294).length); +print(x.slice(0, -4294967295).length); +print(x.slice(0, -4294967296).length); + +print(x.slice(9223371036854775807).length); +print(x.slice(9223372036854775807).length); +print(x.slice(9223373036854775807).length); +print(x.slice(9223374036854775807).length); + +print(x.slice(-9223371036854775807).length); +print(x.slice(-9223372036854775807).length); +print(x.slice(-9223373036854775807).length); +print(x.slice(-9223374036854775807).length); + +print(x.slice(-9223371036854775807, 1).length); +print(x.slice(-9223372036854775807, 1).length); +print(x.slice(-9223373036854775807, 1).length); +print(x.slice(-9223374036854775807, 1).length); + +print(x.slice(-9223371036854775807, -1).length); +print(x.slice(-9223372036854775807, -1).length); +print(x.slice(-9223373036854775807, -1).length); +print(x.slice(-9223374036854775807, -1).length); + +print(x.slice(Infinity).length); +print(x.slice(Infinity, Infinity).length); +print(x.slice(Infinity, -Infinity).length); +print(x.slice(-Infinity).length); +print(x.slice(-Infinity, Infinity).length); +print(x.slice(-Infinity, -Infinity).length); + +var d = new Date(); +d.setYear(Infinity); +print(d); \ No newline at end of file diff --git a/nashorn/test/script/basic/JDK-8010804.js.EXPECTED b/nashorn/test/script/basic/JDK-8010804.js.EXPECTED new file mode 100644 index 00000000000..1f73ec043f2 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8010804.js.EXPECTED @@ -0,0 +1,42 @@ +0 +4294967295 +4294967295 +2 +1 +0 +0 +4294967293 +4294967294 +4294967295 +4294967295 +4294967293 +4294967294 +4294967295 +4294967295 +2 +1 +0 +0 +0 +0 +0 +0 +4294967295 +4294967295 +4294967295 +4294967295 +1 +1 +1 +1 +4294967294 +4294967294 +4294967294 +4294967294 +0 +0 +0 +4294967295 +4294967295 +0 +Invalid Date From 1e80919f4cb97ccd12698f91975afa46d526c05b Mon Sep 17 00:00:00 2001 From: Tao Mao Date: Wed, 22 May 2013 11:11:47 -0700 Subject: [PATCH 038/206] 8007762: Rename a bunch of methods in size policy across collectors Rename: compute_generations_free_space() = compute_eden_space_size() + compute_old_gen_free_space(); update related logging messages Reviewed-by: jmasa, johnc, tschatzl, brutisso --- .../concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp | 10 +++++----- .../concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp | 6 +++--- .../parNew/asParNewGeneration.cpp | 5 ++--- .../parallelScavenge/psAdaptiveSizePolicy.cpp | 12 ++++++------ .../parallelScavenge/psAdaptiveSizePolicy.hpp | 14 +++++++------- .../psGCAdaptivePolicyCounters.hpp | 4 ++-- .../parallelScavenge/psMarkSweep.cpp | 14 +++++++------- .../parallelScavenge/psParallelCompact.cpp | 14 +++++++------- .../shared/adaptiveSizePolicy.cpp | 4 ++-- 9 files changed, 41 insertions(+), 42 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp index 838e35fb599..d60fe806892 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2010, 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 @@ -969,8 +969,8 @@ size_t CMSAdaptiveSizePolicy::promo_increment_aligned_up(size_t cur_promo) { } -void CMSAdaptiveSizePolicy::compute_young_generation_free_space(size_t cur_eden, - size_t max_eden_size) +void CMSAdaptiveSizePolicy::compute_eden_space_size(size_t cur_eden, + size_t max_eden_size) { size_t desired_eden_size = cur_eden; size_t eden_limit = max_eden_size; @@ -978,7 +978,7 @@ void CMSAdaptiveSizePolicy::compute_young_generation_free_space(size_t cur_eden, // Printout input if (PrintGC && PrintAdaptiveSizePolicy) { gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::compute_young_generation_free_space: " + "CMSAdaptiveSizePolicy::compute_eden_space_size: " "cur_eden " SIZE_FORMAT, cur_eden); } @@ -1024,7 +1024,7 @@ void CMSAdaptiveSizePolicy::compute_young_generation_free_space(size_t cur_eden, if (PrintGC && PrintAdaptiveSizePolicy) { gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::compute_young_generation_free_space limits:" + "CMSAdaptiveSizePolicy::compute_eden_space_size limits:" " desired_eden_size: " SIZE_FORMAT " old_eden_size: " SIZE_FORMAT, desired_eden_size, cur_eden); diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp index 6053b4323bd..00a4f8fd781 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2010, 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 @@ -436,8 +436,8 @@ class CMSAdaptiveSizePolicy : public AdaptiveSizePolicy { size_t generation_alignment() { return _generation_alignment; } - virtual void compute_young_generation_free_space(size_t cur_eden, - size_t max_eden_size); + virtual void compute_eden_space_size(size_t cur_eden, + size_t max_eden_size); // Calculates new survivor space size; returns a new tenuring threshold // value. Stores new survivor size in _survivor_size. virtual uint compute_survivor_space_size_and_threshold( diff --git a/hotspot/src/share/vm/gc_implementation/parNew/asParNewGeneration.cpp b/hotspot/src/share/vm/gc_implementation/parNew/asParNewGeneration.cpp index a18933356a7..2925b9d439d 100644 --- a/hotspot/src/share/vm/gc_implementation/parNew/asParNewGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/parNew/asParNewGeneration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -585,8 +585,7 @@ void ASParNewGeneration::compute_new_size() { size_policy->avg_young_live()->sample(used()); size_policy->avg_eden_live()->sample(eden()->used()); - size_policy->compute_young_generation_free_space(eden()->capacity(), - max_gen_size()); + size_policy->compute_eden_space_size(eden()->capacity(), max_gen_size()); resize(size_policy->calculated_eden_size_in_bytes(), size_policy->calculated_survivor_size_in_bytes()); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp index 8b3ee26548d..7727017959d 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp @@ -194,7 +194,7 @@ void PSAdaptiveSizePolicy::clear_generation_free_space_flags() { // If this is not a full GC, only test and modify the young generation. -void PSAdaptiveSizePolicy::compute_generation_free_space( +void PSAdaptiveSizePolicy::compute_generations_free_space( size_t young_live, size_t eden_live, size_t old_live, @@ -729,7 +729,7 @@ void PSAdaptiveSizePolicy::adjust_promo_for_pause_time(bool is_full_gc, if (PrintAdaptiveSizePolicy && Verbose) { gclog_or_tty->print_cr( - "PSAdaptiveSizePolicy::compute_old_gen_free_space " + "PSAdaptiveSizePolicy::adjust_promo_for_pause_time " "adjusting gen sizes for major pause (avg %f goal %f). " "desired_promo_size " SIZE_FORMAT " promo delta " SIZE_FORMAT, _avg_major_pause->average(), gc_pause_goal_sec(), @@ -786,7 +786,7 @@ void PSAdaptiveSizePolicy::adjust_eden_for_pause_time(bool is_full_gc, if (PrintAdaptiveSizePolicy && Verbose) { gclog_or_tty->print_cr( - "PSAdaptiveSizePolicy::compute_eden_space_size " + "PSAdaptiveSizePolicy::adjust_eden_for_pause_time " "adjusting gen sizes for major pause (avg %f goal %f). " "desired_eden_size " SIZE_FORMAT " eden delta " SIZE_FORMAT, _avg_major_pause->average(), gc_pause_goal_sec(), @@ -1001,7 +1001,7 @@ size_t PSAdaptiveSizePolicy::adjust_promo_for_footprint( if (PrintAdaptiveSizePolicy && Verbose) { gclog_or_tty->print_cr( - "AdaptiveSizePolicy::compute_generation_free_space " + "AdaptiveSizePolicy::adjust_promo_for_footprint " "adjusting tenured gen for footprint. " "starting promo size " SIZE_FORMAT " reduced promo size " SIZE_FORMAT, @@ -1025,7 +1025,7 @@ size_t PSAdaptiveSizePolicy::adjust_eden_for_footprint( if (PrintAdaptiveSizePolicy && Verbose) { gclog_or_tty->print_cr( - "AdaptiveSizePolicy::compute_generation_free_space " + "AdaptiveSizePolicy::adjust_eden_for_footprint " "adjusting eden for footprint. " " starting eden size " SIZE_FORMAT " reduced eden size " SIZE_FORMAT @@ -1280,7 +1280,7 @@ void PSAdaptiveSizePolicy::update_averages(bool is_survivor_overflow, if (PrintAdaptiveSizePolicy) { gclog_or_tty->print( - "AdaptiveSizePolicy::compute_survivor_space_size_and_thresh:" + "AdaptiveSizePolicy::update_averages:" " survived: " SIZE_FORMAT " promoted: " SIZE_FORMAT " overflow: %s", diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp index 683c6a991fe..b0cb8c7efbf 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp @@ -344,13 +344,13 @@ class PSAdaptiveSizePolicy : public AdaptiveSizePolicy { // Takes current used space in all generations as input, as well // as an indication if a full gc has just been performed, for use // in deciding if an OOM error should be thrown. - void compute_generation_free_space(size_t young_live, - size_t eden_live, - size_t old_live, - size_t cur_eden, // current eden in bytes - size_t max_old_gen_size, - size_t max_eden_size, - bool is_full_gc); + void compute_generations_free_space(size_t young_live, + size_t eden_live, + size_t old_live, + size_t cur_eden, // current eden in bytes + size_t max_old_gen_size, + size_t max_eden_size, + bool is_full_gc); void compute_eden_space_size(size_t young_live, size_t eden_live, diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psGCAdaptivePolicyCounters.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psGCAdaptivePolicyCounters.hpp index c6839705625..1db22443178 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psGCAdaptivePolicyCounters.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psGCAdaptivePolicyCounters.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, 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 @@ -119,7 +119,7 @@ class PSGCAdaptivePolicyCounters : public GCAdaptivePolicyCounters { ps_size_policy()->change_old_gen_for_min_pauses()); } - // compute_generation_free_space() statistics + // compute_generations_free_space() statistics inline void update_avg_major_pause() { _avg_major_pause->set_value( diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp index e9b8280d921..01b3a5b6d1e 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp @@ -290,13 +290,13 @@ bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) { // Used for diagnostics size_policy->clear_generation_free_space_flags(); - size_policy->compute_generation_free_space(young_live, - eden_live, - old_live, - cur_eden, - max_old_gen_size, - max_eden_size, - true /* full gc*/); + size_policy->compute_generations_free_space(young_live, + eden_live, + old_live, + cur_eden, + max_old_gen_size, + max_eden_size, + true /* full gc*/); size_policy->check_gc_overhead_limit(young_live, eden_live, diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp index d01bdc8b13b..d85f5d3e486 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @@ -2101,13 +2101,13 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) { // Used for diagnostics size_policy->clear_generation_free_space_flags(); - size_policy->compute_generation_free_space(young_live, - eden_live, - old_live, - cur_eden, - max_old_gen_size, - max_eden_size, - true /* full gc*/); + size_policy->compute_generations_free_space(young_live, + eden_live, + old_live, + cur_eden, + max_old_gen_size, + max_eden_size, + true /* full gc*/); size_policy->check_gc_overhead_limit(young_live, eden_live, diff --git a/hotspot/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp b/hotspot/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp index 90093a2cb2e..3e7c716d481 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2010, 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 @@ -467,7 +467,7 @@ void AdaptiveSizePolicy::check_gc_overhead_limit( (free_in_old_gen < (size_t) mem_free_old_limit && free_in_eden < (size_t) mem_free_eden_limit))) { gclog_or_tty->print_cr( - "PSAdaptiveSizePolicy::compute_generation_free_space limits:" + "PSAdaptiveSizePolicy::check_gc_overhead_limit:" " promo_limit: " SIZE_FORMAT " max_eden_size: " SIZE_FORMAT " total_free_limit: " SIZE_FORMAT From 6ed8c8fcea1f1b2549c4b8a09e492b3247e32394 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 22 May 2013 14:37:49 -0400 Subject: [PATCH 039/206] 8003421: NPG: Move oops out of InstanceKlass into mirror Inject protection_domain, signers, init_lock into java_lang_Class Reviewed-by: stefank, dholmes, sla --- .../jvm/hotspot/memory/DictionaryEntry.java | 7 ++- .../sun/jvm/hotspot/oops/InstanceKlass.java | 8 --- .../jvm/hotspot/utilities/HeapGXLWriter.java | 12 ++-- .../hotspot/utilities/HeapHprofBinWriter.java | 8 +-- .../utilities/soql/JSJavaInstanceKlass.java | 8 --- .../share/vm/classfile/classFileParser.cpp | 14 +---- .../src/share/vm/classfile/javaClasses.cpp | 63 +++++++++++++++---- .../src/share/vm/classfile/javaClasses.hpp | 19 +++++- hotspot/src/share/vm/classfile/vmSymbols.hpp | 3 + hotspot/src/share/vm/oops/arrayKlass.cpp | 2 +- hotspot/src/share/vm/oops/instanceKlass.cpp | 57 ++++++----------- hotspot/src/share/vm/oops/instanceKlass.hpp | 36 +++-------- hotspot/src/share/vm/oops/klass.cpp | 5 +- hotspot/src/share/vm/oops/klass.hpp | 2 +- hotspot/src/share/vm/oops/objArrayKlass.hpp | 2 +- hotspot/src/share/vm/oops/typeArrayKlass.hpp | 2 + hotspot/src/share/vm/prims/jvm.cpp | 14 ++--- hotspot/src/share/vm/runtime/vmStructs.cpp | 4 +- 18 files changed, 130 insertions(+), 136 deletions(-) diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java index be40fd44c51..301410408d2 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java @@ -96,9 +96,10 @@ public class DictionaryEntry extends sun.jvm.hotspot.utilities.HashtableEntry { public boolean containsProtectionDomain(Oop protectionDomain) { InstanceKlass ik = (InstanceKlass) klass(); - if (protectionDomain.equals(ik.getProtectionDomain())) { - return true; // Succeeds trivially - } + // Currently unimplemented and not used. + // if (protectionDomain.equals(ik.getJavaMirror().getProtectionDomain())) { + // return true; // Succeeds trivially + // } for (ProtectionDomainEntry current = pdSet(); current != null; current = current.next()) { if (protectionDomain.equals(current.protectionDomain())) { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java index cfa26eacdbd..80d5b795b3f 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java @@ -75,8 +75,6 @@ public class InstanceKlass extends Klass { javaFieldsCount = new CIntField(type.getCIntegerField("_java_fields_count"), 0); constants = new MetadataField(type.getAddressField("_constants"), 0); classLoaderData = type.getAddressField("_class_loader_data"); - protectionDomain = new OopField(type.getOopField("_protection_domain"), 0); - signers = new OopField(type.getOopField("_signers"), 0); sourceFileName = type.getAddressField("_source_file_name"); sourceDebugExtension = type.getAddressField("_source_debug_extension"); innerClasses = type.getAddressField("_inner_classes"); @@ -136,8 +134,6 @@ public class InstanceKlass extends Klass { private static CIntField javaFieldsCount; private static MetadataField constants; private static AddressField classLoaderData; - private static OopField protectionDomain; - private static OopField signers; private static AddressField sourceFileName; private static AddressField sourceDebugExtension; private static AddressField innerClasses; @@ -350,8 +346,6 @@ public class InstanceKlass extends Klass { public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); } public ClassLoaderData getClassLoaderData() { return ClassLoaderData.instantiateWrapperFor(classLoaderData.getValue(getAddress())); } public Oop getClassLoader() { return getClassLoaderData().getClassLoader(); } - public Oop getProtectionDomain() { return protectionDomain.getValue(this); } - public ObjArray getSigners() { return (ObjArray) signers.getValue(this); } public Symbol getSourceFileName() { return getSymbol(sourceFileName); } public String getSourceDebugExtension(){ return CStringUtilities.getString(sourceDebugExtension.getValue(getAddress())); } public long getNonstaticFieldSize() { return nonstaticFieldSize.getValue(this); } @@ -541,8 +535,6 @@ public class InstanceKlass extends Klass { // visitor.doOop(methods, true); // visitor.doOop(localInterfaces, true); // visitor.doOop(transitiveInterfaces, true); - visitor.doOop(protectionDomain, true); - visitor.doOop(signers, true); visitor.doCInt(nonstaticFieldSize, true); visitor.doCInt(staticFieldSize, true); visitor.doCInt(staticOopFieldCount, true); diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java index f5058386662..47494e826b3 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java @@ -204,13 +204,13 @@ public class HeapGXLWriter extends AbstractHeapGraphWriter { Oop loader = ik.getClassLoader(); writeEdge(instance, loader, "loaded-by"); - // write signers - Oop signers = ik.getSigners(); - writeEdge(instance, signers, "signed-by"); + // write signers NYI + // Oop signers = ik.getJavaMirror().getSigners(); + writeEdge(instance, null, "signed-by"); - // write protection domain - Oop protectionDomain = ik.getProtectionDomain(); - writeEdge(instance, protectionDomain, "protection-domain"); + // write protection domain NYI + // Oop protectionDomain = ik.getJavaMirror().getProtectionDomain(); + writeEdge(instance, null, "protection-domain"); // write edges for static reference fields from this class for (Iterator itr = refFields.iterator(); itr.hasNext();) { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java index 58fd75ee8b8..65299721f17 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java @@ -477,8 +477,8 @@ public class HeapHprofBinWriter extends AbstractHeapGraphWriter { if (k instanceof InstanceKlass) { InstanceKlass ik = (InstanceKlass) k; writeObjectID(ik.getClassLoader()); - writeObjectID(ik.getSigners()); - writeObjectID(ik.getProtectionDomain()); + writeObjectID(null); // ik.getJavaMirror().getSigners()); + writeObjectID(null); // ik.getJavaMirror().getProtectionDomain()); // two reserved id fields writeObjectID(null); writeObjectID(null); @@ -516,8 +516,8 @@ public class HeapHprofBinWriter extends AbstractHeapGraphWriter { if (bottomKlass instanceof InstanceKlass) { InstanceKlass ik = (InstanceKlass) bottomKlass; writeObjectID(ik.getClassLoader()); - writeObjectID(ik.getSigners()); - writeObjectID(ik.getProtectionDomain()); + writeObjectID(null); // ik.getJavaMirror().getSigners()); + writeObjectID(null); // ik.getJavaMirror().getProtectionDomain()); } else { writeObjectID(null); writeObjectID(null); diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java index 7198e5cec14..a76e5ddbf31 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java @@ -47,8 +47,6 @@ public class JSJavaInstanceKlass extends JSJavaKlass { private static final int FIELD_IS_SYNTHETIC = 13; private static final int FIELD_IS_INTERFACE = 14; private static final int FIELD_CLASS_LOADER = 15; - private static final int FIELD_PROTECTION_DOMAIN = 16; - private static final int FIELD_SIGNERS = 17; private static final int FIELD_STATICS = 18; private static final int FIELD_UNDEFINED = -1; @@ -100,10 +98,6 @@ public class JSJavaInstanceKlass extends JSJavaKlass { return Boolean.valueOf(ik.isInterface()); case FIELD_CLASS_LOADER: return factory.newJSJavaObject(ik.getClassLoader()); - case FIELD_PROTECTION_DOMAIN: - return factory.newJSJavaObject(ik.getProtectionDomain()); - case FIELD_SIGNERS: - return factory.newJSJavaObject(ik.getSigners()); case FIELD_STATICS: return getStatics(); case FIELD_UNDEFINED: @@ -246,8 +240,6 @@ public class JSJavaInstanceKlass extends JSJavaKlass { addField("isSynthetic", FIELD_IS_SYNTHETIC); addField("isInterface", FIELD_IS_INTERFACE); addField("classLoader", FIELD_CLASS_LOADER); - addField("protectionDomain", FIELD_PROTECTION_DOMAIN); - addField("signers", FIELD_SIGNERS); addField("statics", FIELD_STATICS); } diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index f7676c0def4..8aa15736447 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -4040,6 +4040,9 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name, } } + // Allocate mirror and initialize static fields + java_lang_Class::create_mirror(this_klass, protection_domain, CHECK_(nullHandle)); + #ifdef ASSERT if (ParseAllGenericSignatures) { @@ -4055,17 +4058,6 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name, this_klass(), &all_mirandas, CHECK_(nullHandle)); } - // Allocate mirror and initialize static fields - java_lang_Class::create_mirror(this_klass, CHECK_(nullHandle)); - - // Allocate a simple java object for locking during class initialization. - // This needs to be a java object because it can be held across a java call. - typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK_NULL); - this_klass->set_init_lock(r); - - // TODO: Move these oops to the mirror - this_klass->set_protection_domain(protection_domain()); - // Update the loader_data graph. record_defined_class_dependencies(this_klass, CHECK_NULL); diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index bb02a6d8694..cbe3581ff4a 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -512,22 +512,22 @@ void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) { // If the offset was read from the shared archive, it was fixed up already if (!k->is_shared()) { - if (k->oop_is_instance()) { - // During bootstrap, java.lang.Class wasn't loaded so static field - // offsets were computed without the size added it. Go back and - // update all the static field offsets to included the size. - for (JavaFieldStream fs(InstanceKlass::cast(k())); !fs.done(); fs.next()) { - if (fs.access_flags().is_static()) { - int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields(); - fs.set_offset(real_offset); + if (k->oop_is_instance()) { + // During bootstrap, java.lang.Class wasn't loaded so static field + // offsets were computed without the size added it. Go back and + // update all the static field offsets to included the size. + for (JavaFieldStream fs(InstanceKlass::cast(k())); !fs.done(); fs.next()) { + if (fs.access_flags().is_static()) { + int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields(); + fs.set_offset(real_offset); + } } } } - } - create_mirror(k, CHECK); + create_mirror(k, Handle(NULL), CHECK); } -oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) { +oop java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRAPS) { assert(k->java_mirror() == NULL, "should only assign mirror once"); // Use this moment of initialization to cache modifier_flags also, // to support Class.getModifiers(). Instance classes recalculate @@ -563,6 +563,16 @@ oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) { set_array_klass(comp_mirror(), k()); } else { assert(k->oop_is_instance(), "Must be"); + + // Allocate a simple java object for a lock. + // This needs to be a java object because during class initialization + // it can be held across a java call. + typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK_NULL); + set_init_lock(mirror(), r); + + // Set protection domain also + set_protection_domain(mirror(), protection_domain()); + // Initialize static fields InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, CHECK_NULL); } @@ -597,6 +607,34 @@ void java_lang_Class::set_static_oop_field_count(oop java_class, int size) { java_class->int_field_put(_static_oop_field_count_offset, size); } +oop java_lang_Class::protection_domain(oop java_class) { + assert(_protection_domain_offset != 0, "must be set"); + return java_class->obj_field(_protection_domain_offset); +} +void java_lang_Class::set_protection_domain(oop java_class, oop pd) { + assert(_protection_domain_offset != 0, "must be set"); + java_class->obj_field_put(_protection_domain_offset, pd); +} + +oop java_lang_Class::init_lock(oop java_class) { + assert(_init_lock_offset != 0, "must be set"); + return java_class->obj_field(_init_lock_offset); +} +void java_lang_Class::set_init_lock(oop java_class, oop init_lock) { + assert(_init_lock_offset != 0, "must be set"); + java_class->obj_field_put(_init_lock_offset, init_lock); +} + +objArrayOop java_lang_Class::signers(oop java_class) { + assert(_signers_offset != 0, "must be set"); + return (objArrayOop)java_class->obj_field(_signers_offset); +} +void java_lang_Class::set_signers(oop java_class, objArrayOop signers) { + assert(_signers_offset != 0, "must be set"); + java_class->obj_field_put(_signers_offset, (oop)signers); +} + + oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) { // This should be improved by adding a field at the Java level or by // introducing a new VM klass (see comment in ClassFileParser) @@ -2934,6 +2972,9 @@ int java_lang_Class::_klass_offset; int java_lang_Class::_array_klass_offset; int java_lang_Class::_oop_size_offset; int java_lang_Class::_static_oop_field_count_offset; +int java_lang_Class::_protection_domain_offset; +int java_lang_Class::_init_lock_offset; +int java_lang_Class::_signers_offset; GrowableArray* java_lang_Class::_fixup_mirror_list = NULL; int java_lang_Throwable::backtrace_offset; int java_lang_Throwable::detailMessage_offset; diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp index 8e4dd46f3e9..e240bc27e43 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.hpp +++ b/hotspot/src/share/vm/classfile/javaClasses.hpp @@ -208,7 +208,10 @@ class java_lang_String : AllStatic { macro(java_lang_Class, klass, intptr_signature, false) \ macro(java_lang_Class, array_klass, intptr_signature, false) \ macro(java_lang_Class, oop_size, int_signature, false) \ - macro(java_lang_Class, static_oop_field_count, int_signature, false) + macro(java_lang_Class, static_oop_field_count, int_signature, false) \ + macro(java_lang_Class, protection_domain, object_signature, false) \ + macro(java_lang_Class, init_lock, object_signature, false) \ + macro(java_lang_Class, signers, object_signature, false) class java_lang_Class : AllStatic { friend class VMStructs; @@ -222,15 +225,20 @@ class java_lang_Class : AllStatic { static int _oop_size_offset; static int _static_oop_field_count_offset; + static int _protection_domain_offset; + static int _init_lock_offset; + static int _signers_offset; + static bool offsets_computed; static int classRedefinedCount_offset; static GrowableArray* _fixup_mirror_list; + static void set_init_lock(oop java_class, oop init_lock); public: static void compute_offsets(); // Instance creation - static oop create_mirror(KlassHandle k, TRAPS); + static oop create_mirror(KlassHandle k, Handle protection_domain, TRAPS); static void fixup_mirror(KlassHandle k, TRAPS); static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); // Conversion @@ -262,6 +270,13 @@ class java_lang_Class : AllStatic { static int classRedefinedCount(oop the_class_mirror); static void set_classRedefinedCount(oop the_class_mirror, int value); + // Support for embedded per-class oops + static oop protection_domain(oop java_class); + static void set_protection_domain(oop java_class, oop protection_domain); + static oop init_lock(oop java_class); + static objArrayOop signers(oop java_class); + static void set_signers(oop java_class, objArrayOop signers); + static int oop_size(oop java_class); static void set_oop_size(oop java_class, int size); static int static_oop_field_count(oop java_class); diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp index 9fd9aff5e22..e0bff971d0c 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp @@ -392,6 +392,9 @@ template(array_klass_name, "array_klass") \ template(oop_size_name, "oop_size") \ template(static_oop_field_count_name, "static_oop_field_count") \ + template(protection_domain_name, "protection_domain") \ + template(init_lock_name, "init_lock") \ + template(signers_name, "signers_name") \ template(loader_data_name, "loader_data") \ template(dependencies_name, "dependencies") \ \ diff --git a/hotspot/src/share/vm/oops/arrayKlass.cpp b/hotspot/src/share/vm/oops/arrayKlass.cpp index 9b5ec951bbb..dc2fbe92e2a 100644 --- a/hotspot/src/share/vm/oops/arrayKlass.cpp +++ b/hotspot/src/share/vm/oops/arrayKlass.cpp @@ -94,7 +94,7 @@ void ArrayKlass::complete_create_array_klass(ArrayKlass* k, KlassHandle super_kl ResourceMark rm(THREAD); k->initialize_supers(super_klass(), CHECK); k->vtable()->initialize_vtable(false, CHECK); - java_lang_Class::create_mirror(k, CHECK); + java_lang_Class::create_mirror(k, Handle(NULL), CHECK); } GrowableArray* ArrayKlass::compute_secondary_supers(int num_extra_slots) { diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 06827e68148..b61f595424e 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -268,8 +268,6 @@ InstanceKlass::InstanceKlass(int vtable_len, set_fields(NULL, 0); set_constants(NULL); set_class_loader_data(NULL); - set_protection_domain(NULL); - set_signers(NULL); set_source_file_name(NULL); set_source_debug_extension(NULL, 0); set_array_name(NULL); @@ -279,7 +277,6 @@ InstanceKlass::InstanceKlass(int vtable_len, set_is_marked_dependent(false); set_init_state(InstanceKlass::allocated); set_init_thread(NULL); - set_init_lock(NULL); set_reference_type(rt); set_oop_map_cache(NULL); set_jni_ids(NULL); @@ -408,12 +405,6 @@ void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) { } set_inner_classes(NULL); - // Null out Java heap objects, although these won't be walked to keep - // alive once this InstanceKlass is deallocated. - set_protection_domain(NULL); - set_signers(NULL); - set_init_lock(NULL); - // We should deallocate the Annotations instance MetadataFactory::free_metadata(loader_data, annotations()); set_annotations(NULL); @@ -451,6 +442,24 @@ void InstanceKlass::eager_initialize(Thread *thread) { } } +// JVMTI spec thinks there are signers and protection domain in the +// instanceKlass. These accessors pretend these fields are there. +// The hprof specification also thinks these fields are in InstanceKlass. +oop InstanceKlass::protection_domain() const { + // return the protection_domain from the mirror + return java_lang_Class::protection_domain(java_mirror()); +} + +// To remove these from requires an incompatible change and CCC request. +objArrayOop InstanceKlass::signers() const { + // return the signers from the mirror + return java_lang_Class::signers(java_mirror()); +} + +volatile oop InstanceKlass::init_lock() const { + // return the init lock from the mirror + return java_lang_Class::init_lock(java_mirror()); +} void InstanceKlass::eager_initialize_impl(instanceKlassHandle this_oop) { EXCEPTION_MARK; @@ -1883,16 +1892,6 @@ bool InstanceKlass::is_dependent_nmethod(nmethod* nm) { // Garbage collection -void InstanceKlass::oops_do(OopClosure* cl) { - Klass::oops_do(cl); - - cl->do_oop(adr_protection_domain()); - cl->do_oop(adr_signers()); - cl->do_oop(adr_init_lock()); - - // Don't walk the arrays since they are walked from the ClassLoaderData objects. -} - #ifdef ASSERT template void assert_is_in(T *p) { T heap_oop = oopDesc::load_heap_oop(p); @@ -2241,9 +2240,6 @@ void InstanceKlass::remove_unshareable_info() { m->remove_unshareable_info(); } - // Need to reinstate when reading back the class. - set_init_lock(NULL); - // do array classes also. array_klasses_do(remove_unshareable_in_class); } @@ -2275,13 +2271,6 @@ void InstanceKlass::restore_unshareable_info(TRAPS) { ik->itable()->initialize_itable(false, CHECK); } - // Allocate a simple java object for a lock. - // This needs to be a java object because during class initialization - // it can be held across a java call. - typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK); - Handle h(THREAD, (oop)r); - ik->set_init_lock(h()); - // restore constant pool resolved references ik->constants()->restore_unshareable_info(CHECK); @@ -2836,10 +2825,7 @@ void InstanceKlass::print_on(outputStream* st) const { class_loader_data()->print_value_on(st); st->cr(); } - st->print(BULLET"protection domain: "); ((InstanceKlass*)this)->protection_domain()->print_value_on(st); st->cr(); st->print(BULLET"host class: "); host_klass()->print_value_on_maybe_null(st); st->cr(); - st->print(BULLET"signers: "); signers()->print_value_on(st); st->cr(); - st->print(BULLET"init_lock: "); ((oop)_init_lock)->print_value_on(st); st->cr(); if (source_file_name() != NULL) { st->print(BULLET"source file: "); source_file_name()->print_value_on(st); @@ -3040,7 +3026,6 @@ void InstanceKlass::collect_statistics(KlassSizeStats *sz) const { n += (sz->_method_ordering_bytes = sz->count_array(method_ordering())); n += (sz->_local_interfaces_bytes = sz->count_array(local_interfaces())); n += (sz->_transitive_interfaces_bytes = sz->count_array(transitive_interfaces())); - n += (sz->_signers_bytes = sz->count_array(signers())); n += (sz->_fields_bytes = sz->count_array(fields())); n += (sz->_inner_classes_bytes = sz->count_array(inner_classes())); sz->_ro_bytes += n; @@ -3206,17 +3191,11 @@ void InstanceKlass::verify_on(outputStream* st) { guarantee(constants()->is_metadata(), "should be in metaspace"); guarantee(constants()->is_constantPool(), "should be constant pool"); } - if (protection_domain() != NULL) { - guarantee(protection_domain()->is_oop(), "should be oop"); - } const Klass* host = host_klass(); if (host != NULL) { guarantee(host->is_metadata(), "should be in metaspace"); guarantee(host->is_klass(), "should be klass"); } - if (signers() != NULL) { - guarantee(signers()->is_objArray(), "should be obj array"); - } } void InstanceKlass::oop_verify_on(oop obj, outputStream* st) { diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 8ee9adc01f1..1a370711fd7 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -58,8 +58,6 @@ // [fields ] // [constants ] // [class loader ] -// [protection domain ] -// [signers ] // [source file name ] // [inner classes ] // [static field size ] @@ -180,16 +178,6 @@ class InstanceKlass: public Klass { static volatile int _total_instanceKlass_count; protected: - // Protection domain. - oop _protection_domain; - // Class signers. - objArrayOop _signers; - // Lock for (1) initialization; (2) access to the ConstantPool of this class. - // Must be one per class and it has to be a VM internal object so java code - // cannot lock it (like the mirror). - // It has to be an object not a Mutex because it's held through java calls. - volatile oop _init_lock; - // Annotations for this class Annotations* _annotations; // Array classes holding elements of this class. @@ -527,8 +515,10 @@ class InstanceKlass: public Klass { void set_constants(ConstantPool* c) { _constants = c; } // protection domain - oop protection_domain() { return _protection_domain; } - void set_protection_domain(oop pd) { klass_oop_store(&_protection_domain, pd); } + oop protection_domain() const; + + // signers + objArrayOop signers() const; // host class Klass* host_klass() const { @@ -575,10 +565,6 @@ class InstanceKlass: public Klass { } } - // signers - objArrayOop signers() const { return _signers; } - void set_signers(objArrayOop s) { klass_oop_store((oop*)&_signers, s); } - // source file name Symbol* source_file_name() const { return _source_file_name; } void set_source_file_name(Symbol* n); @@ -912,8 +898,6 @@ class InstanceKlass: public Klass { Method* method_at_itable(Klass* holder, int index, TRAPS); // Garbage collection - virtual void oops_do(OopClosure* cl); - void oop_follow_contents(oop obj); int oop_adjust_pointers(oop obj); @@ -999,14 +983,12 @@ private: // Lock during initialization public: - volatile oop init_lock() const {return _init_lock; } + // Lock for (1) initialization; (2) access to the ConstantPool of this class. + // Must be one per class and it has to be a VM internal object so java code + // cannot lock it (like the mirror). + // It has to be an object not a Mutex because it's held through java calls. + volatile oop init_lock() const; private: - void set_init_lock(oop value) { klass_oop_store(&_init_lock, value); } - - // Offsets for memory management - oop* adr_protection_domain() const { return (oop*)&this->_protection_domain;} - oop* adr_signers() const { return (oop*)&this->_signers;} - oop* adr_init_lock() const { return (oop*)&this->_init_lock;} // Static methods that are used to implement member methods where an exposed this pointer // is needed due to possible GCs diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp index 52dd2645979..5c334206b97 100644 --- a/hotspot/src/share/vm/oops/klass.cpp +++ b/hotspot/src/share/vm/oops/klass.cpp @@ -511,8 +511,9 @@ void Klass::restore_unshareable_info(TRAPS) { // (same order as class file parsing) loader_data->add_class(this); - // Recreate the class mirror - java_lang_Class::create_mirror(this, CHECK); + // Recreate the class mirror. The protection_domain is always null for + // boot loader, for now. + java_lang_Class::create_mirror(this, Handle(NULL), CHECK); } Klass* Klass::array_klass_or_null(int rank) { diff --git a/hotspot/src/share/vm/oops/klass.hpp b/hotspot/src/share/vm/oops/klass.hpp index acd402c79ad..6b0103abb5e 100644 --- a/hotspot/src/share/vm/oops/klass.hpp +++ b/hotspot/src/share/vm/oops/klass.hpp @@ -445,7 +445,7 @@ class Klass : public Metadata { Klass* array_klass_or_null(int rank); Klass* array_klass_or_null(); - virtual oop protection_domain() { return NULL; } + virtual oop protection_domain() const = 0; oop class_loader() const; diff --git a/hotspot/src/share/vm/oops/objArrayKlass.hpp b/hotspot/src/share/vm/oops/objArrayKlass.hpp index 74aa4f8d76d..9905704ccab 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.hpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.hpp @@ -75,7 +75,7 @@ class ObjArrayKlass : public ArrayKlass { void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); // Compute protection domain - oop protection_domain() { return bottom_klass()->protection_domain(); } + oop protection_domain() const { return bottom_klass()->protection_domain(); } private: // Either oop or narrowOop depending on UseCompressedOops. diff --git a/hotspot/src/share/vm/oops/typeArrayKlass.hpp b/hotspot/src/share/vm/oops/typeArrayKlass.hpp index 3fe8312a0ba..f8bf2ac74c0 100644 --- a/hotspot/src/share/vm/oops/typeArrayKlass.hpp +++ b/hotspot/src/share/vm/oops/typeArrayKlass.hpp @@ -67,6 +67,8 @@ class TypeArrayKlass : public ArrayKlass { typeArrayOop allocate(int length, TRAPS) { return allocate_common(length, true, THREAD); } oop multi_allocate(int rank, jint* sizes, TRAPS); + oop protection_domain() const { return NULL; } + // Copying void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index bedfc619035..733d04a1b69 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -1072,11 +1072,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassSigners(JNIEnv *env, jclass cls)) return NULL; } - Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); - objArrayOop signers = NULL; - if (k->oop_is_instance()) { - signers = InstanceKlass::cast(k)->signers(); - } + objArrayOop signers = java_lang_Class::signers(JNIHandles::resolve_non_null(cls)); // If there are no signers set in the class, or if the class // is an array, return NULL. @@ -1102,7 +1098,7 @@ JVM_ENTRY(void, JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signer // be called with an array. Only the bootstrap loader creates arrays. Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); if (k->oop_is_instance()) { - InstanceKlass::cast(k)->set_signers(objArrayOop(JNIHandles::resolve(signers))); + java_lang_Class::set_signers(k->java_mirror(), objArrayOop(JNIHandles::resolve(signers))); } } JVM_END @@ -1119,8 +1115,8 @@ JVM_ENTRY(jobject, JVM_GetProtectionDomain(JNIEnv *env, jclass cls)) return NULL; } - Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); - return (jobject) JNIHandles::make_local(env, k->protection_domain()); + oop pd = java_lang_Class::protection_domain(JNIHandles::resolve(cls)); + return (jobject) JNIHandles::make_local(env, pd); JVM_END @@ -1139,7 +1135,7 @@ JVM_ENTRY(void, JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protect if (k->oop_is_instance()) { oop pd = JNIHandles::resolve(protection_domain); assert(pd == NULL || pd->is_oop(), "just checking"); - InstanceKlass::cast(k)->set_protection_domain(pd); + java_lang_Class::set_protection_domain(k->java_mirror(), pd); } } JVM_END diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index b3fdd1e7097..6e12cd447fc 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -292,10 +292,8 @@ typedef BinaryTreeDictionary MetablockTreeDictionary; nonstatic_field(InstanceKlass, _transitive_interfaces, Array*) \ nonstatic_field(InstanceKlass, _fields, Array*) \ nonstatic_field(InstanceKlass, _java_fields_count, u2) \ - nonstatic_field(InstanceKlass, _constants, ConstantPool*) \ + nonstatic_field(InstanceKlass, _constants, ConstantPool*) \ nonstatic_field(InstanceKlass, _class_loader_data, ClassLoaderData*) \ - nonstatic_field(InstanceKlass, _protection_domain, oop) \ - nonstatic_field(InstanceKlass, _signers, objArrayOop) \ nonstatic_field(InstanceKlass, _source_file_name, Symbol*) \ nonstatic_field(InstanceKlass, _source_debug_extension, char*) \ nonstatic_field(InstanceKlass, _inner_classes, Array*) \ From 59c9296f63756e4f3309944a66976a2a6fb59962 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 22 May 2013 13:34:03 -0700 Subject: [PATCH 040/206] 8010680: Clarify "present" and annotation ordering in javax.lang.model Reviewed-by: abuckley, jjg --- .../javax/lang/model/AnnotatedConstruct.java | 101 +++++++++++++----- .../javax/lang/model/util/Elements.java | 5 +- 2 files changed, 76 insertions(+), 30 deletions(-) diff --git a/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java b/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java index c96bff48432..f02f5cdbbd0 100644 --- a/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java +++ b/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java @@ -39,35 +39,76 @@ import javax.lang.model.type.*; * are on a declaration, whereas annotations on a type are on * a specific use of a type name. * - * The terms directly present and present are used + * The terms directly present, present, + * indirectly present, and associated are used * throughout this interface to describe precisely which annotations - * are returned by methods: + * are returned by the methods defined herein. * - *

    An annotation A is directly present on a - * construct E if E is annotated, and: + *

    In the definitions below, an annotation A has an + * annotation type AT. If AT is a repeatable annotation + * type, the type of the containing annotation is ATC. + * + *

    Annotation A is directly present on a construct + * C if either: * *

      * - *
    • for an invocation of {@code getAnnotation(Class)} or - * {@code getAnnotationMirrors()}, E's annotations contain A. + *
    • A is explicitly or implicitly declared as applying to + * the source code representation of C. * - *
    • for an invocation of {@code getAnnotationsByType(Class)}, - * E's annotations either contain A or, if the type of - * A is repeatable, contain exactly one annotation whose value - * element contains A and whose type is the containing - * annotation type of A's type. + *

      Typically, if exactly one annotation of type AT appears in + * the source code of representation of C, then A is + * explicitly declared as applying to C. + * + * If there are multiple annotations of type AT present on + * C, then if AT is repeatable annotation type, an + * annotation of type ATC is implicitly declared on C. + * + *

    • A representation of A appears in the executable output + * for C, such as the {@code RuntimeVisibleAnnotations} or + * {@code RuntimeVisibleParameterAnnotations} attributes of a class + * file. * *
    * - *

    An annotation A is present on a construct E if either: + *

    An annotation A is present on a + * construct C if either: + *

      + * + *
    • A is directly present on C. + * + *
    • No annotation of type AT is directly present on + * C, and C is a class and AT is inheritable + * and A is present on the superclass of C. + * + *
    + * + * An annotation A is indirectly present on a construct + * C if both: * *
      - *
    • A is directly present on E; or * - *
    • A is not directly present on E, and - * E is an element representing a class, and A's type - * is inheritable, and A is present on the element - * representing the superclass of E. + *
    • AT is a repeatable annotation type with a containing + * annotation type ATC. + * + *
    • An annotation of type ATC is directly present on + * C and A is an annotation included in the result of + * calling the {@code value} method of the directly present annotation + * of type ATC. + * + *
    + * + * An annotation A is associated with a construct + * C if either: + * + *
      + * + *
    • A is directly or indirectly present on C. + * + *
    • No annotation of type AT is directly or indirectly + * present on C, and C is a class, and AT is + * inheritable, and A is associated with the superclass of + * C. * *
    * @@ -86,9 +127,8 @@ public interface AnnotatedConstruct { List getAnnotationMirrors(); /** - * Returns this construct's annotation of the - * specified type if such an annotation is present, else {@code - * null}. + * Returns this construct's annotation of the specified type if + * such an annotation is present, else {@code null}. * *

    The annotation returned by this method could contain an element * whose value is of type {@code Class}. @@ -118,9 +158,8 @@ public interface AnnotatedConstruct { * @param the annotation type * @param annotationType the {@code Class} object corresponding to * the annotation type - * @return this element's or type use's annotation for the - * specified annotation type if present on this element, else - * {@code null} + * @return this construct's annotation for the specified + * annotation type if present, else {@code null} * * @see #getAnnotationMirrors() * @see java.lang.reflect.AnnotatedElement#getAnnotation @@ -134,10 +173,16 @@ public interface AnnotatedConstruct { A getAnnotation(Class annotationType); /** - * Returns annotations that are present on this construct. + * Returns annotations that are associated with this construct. * - * If there are no annotations present on this construct, - * the return value is an array of length 0. + * If there are no annotations associated with this construct, the + * return value is an array of length 0. + * + * The order of annotations which are directly or indirectly + * present on a construct C is computed as if indirectly present + * annotations on C are directly present on C in place of their + * container annotation, in the order in which they appear in the + * value element of the container annotation. * * The difference between this method and {@link #getAnnotation(Class)} * is that this method detects if its argument is a repeatable @@ -172,8 +217,8 @@ public interface AnnotatedConstruct { * @param the annotation type * @param annotationType the {@code Class} object corresponding to * the annotation type - * @return this element's annotations for the specified annotation - * type if present on this element, else an empty array + * @return this construct's annotations for the specified annotation + * type if present on this construct, else an empty array * * @see #getAnnotationMirrors() * @see #getAnnotation(java.lang.Class) diff --git a/langtools/src/share/classes/javax/lang/model/util/Elements.java b/langtools/src/share/classes/javax/lang/model/util/Elements.java index f782294299a..bc4eb283201 100644 --- a/langtools/src/share/classes/javax/lang/model/util/Elements.java +++ b/langtools/src/share/classes/javax/lang/model/util/Elements.java @@ -143,12 +143,13 @@ public interface Elements { List getAllMembers(TypeElement type); /** - * Returns all annotations of an element, whether - * inherited or directly present. + * Returns all annotations present on an element, whether + * directly present or present via inheritance. * * @param e the element being examined * @return all annotations of the element * @see Element#getAnnotationMirrors + * @see javax.lang.model.AnnotatedConstruct */ List getAllAnnotationMirrors(Element e); From dd837d94dd37125c29d62e073ebd5fc86910b5a5 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Thu, 23 May 2013 12:01:35 +0200 Subject: [PATCH 041/206] 8015267: Allow conversion of JS arrays to Java List/Deque Reviewed-by: lagergren, sundar --- nashorn/make/build.xml | 16 +- .../nashorn/internal/objects/NativeJava.java | 45 ++- .../nashorn/internal/runtime/ListAdapter.java | 337 ++++++++++++++++++ .../internal/runtime/linker/InvokeByName.java | 14 +- .../runtime/resources/Messages.properties | 2 +- nashorn/test/script/basic/JDK-8015267.js | 109 ++++++ .../test/script/basic/JDK-8015267.js.EXPECTED | 40 +++ 7 files changed, 526 insertions(+), 37 deletions(-) create mode 100644 nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java create mode 100644 nashorn/test/script/basic/JDK-8015267.js create mode 100644 nashorn/test/script/basic/JDK-8015267.js.EXPECTED diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index 7c05e789fe9..5324d91f405 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -42,8 +42,6 @@ - - @@ -80,19 +78,7 @@ - - - - - - + * var anArray = [1, "13", false] * var javaIntArray = Java.to(anArray, "int[]") @@ -250,42 +253,46 @@ public final class NativeJava { * print(javaIntArray[2]) // prints 0, as boolean false was converted to number 0 as per ECMAScript ToNumber conversion * * @param self not used - * @param objArray the script object. Can be null. + * @param obj the script object. Can be null. * @param objType either a {@link #type(Object, Object) type object} or a String describing the type of the Java * object to create. Can not be null. If undefined, a "default" conversion is presumed (allowing the argument to be * omitted). * @return a Java object whose value corresponds to the original script object's value. Specifically, for array * target types, returns a Java array of the same type with contents converted to the array's component type. Does - * not recursively convert for multidimensional arrays. - * type. Returns null if scriptObject is null. + * not recursively convert for multidimensional arrays. For {@link List} or {@link Deque}, returns a live wrapper + * around the object, see {@link ListAdapter} for details. Returns null if obj is null. * @throws ClassNotFoundException if the class described by objType is not found */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object to(final Object self, final Object objArray, final Object objType) throws ClassNotFoundException { - if (objArray == null) { + public static Object to(final Object self, final Object obj, final Object objType) throws ClassNotFoundException { + if (obj == null) { return null; } - final Class componentType; + Global.checkObject(obj); + + final Class targetClass; if(objType == UNDEFINED) { - componentType = Object.class; + targetClass = Object[].class; } else { - final StaticClass arrayType; + final StaticClass targetType; if(objType instanceof StaticClass) { - arrayType = (StaticClass)objType; + targetType = (StaticClass)objType; } else { - arrayType = type(objType); + targetType = type(objType); } - final Class arrayClass = arrayType.getRepresentedClass(); - if(!arrayClass.isArray()) { - throw typeError("to.expects.array.type", arrayClass.getName()); - } - componentType = arrayClass.getComponentType(); + targetClass = targetType.getRepresentedClass(); } - Global.checkObject(objArray); + if(targetClass.isArray()) { + return ((ScriptObject)obj).getArray().asArrayOfType(targetClass.getComponentType()); + } - return ((ScriptObject)objArray).getArray().asArrayOfType(componentType); + if(targetClass == List.class || targetClass == Deque.class) { + return new ListAdapter((ScriptObject)obj); + } + + throw typeError("unsupported.java.to.type", targetClass.getName()); } /** diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java b/nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java new file mode 100644 index 00000000000..cc99cd126bf --- /dev/null +++ b/nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java @@ -0,0 +1,337 @@ +package jdk.nashorn.internal.runtime; + +import java.util.AbstractList; +import java.util.Deque; +import java.util.Iterator; +import java.util.ListIterator; +import java.util.NoSuchElementException; +import java.util.RandomAccess; +import jdk.nashorn.internal.runtime.linker.InvokeByName; + +/** + * An adapter that can wrap any ECMAScript Array-like object (that adheres to the array rules for the property + * {@code length} and having conforming {@code push}, {@code pop}, {@code shift}, {@code unshift}, and {@code splice} + * methods) and expose it as both a Java list and double-ended queue. While script arrays aren't necessarily efficient + * as dequeues, it's still slightly more efficient to be able to translate dequeue operations into pushes, pops, shifts, + * and unshifts, than to blindly translate all list's add/remove operations into splices. Also, it is conceivable that a + * custom script object that implements an Array-like API can have a background data representation that is optimized + * for dequeue-like access. Note that with ECMAScript arrays, {@code push} and {@pop} operate at the end of the array, + * while in Java {@code Deque} they operate on the front of the queue and as such the Java dequeue {@link #push(Object)} + * and {@link #pop()} operations will translate to {@code unshift} and {@code shift} script operations respectively, + * while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and {@code pop}. + */ +public class ListAdapter extends AbstractList implements RandomAccess, Deque { + // These add to the back and front of the list + private static final InvokeByName PUSH = new InvokeByName("push", ScriptObject.class, void.class, Object.class); + private static final InvokeByName UNSHIFT = new InvokeByName("unshift", ScriptObject.class, void.class, Object.class); + + // These remove from the back and front of the list + private static final InvokeByName POP = new InvokeByName("pop", ScriptObject.class, Object.class); + private static final InvokeByName SHIFT = new InvokeByName("shift", ScriptObject.class, Object.class); + + // These insert and remove in the middle of the list + private static final InvokeByName SPLICE_ADD = new InvokeByName("splice", ScriptObject.class, void.class, int.class, int.class, Object.class); + private static final InvokeByName SPLICE_REMOVE = new InvokeByName("splice", ScriptObject.class, void.class, int.class, int.class); + + private final ScriptObject obj; + + /** + * Creates a new list wrapper for the specified script object. + * @param obj script the object to wrap + */ + public ListAdapter(ScriptObject obj) { + this.obj = obj; + } + + @Override + public int size() { + return JSType.toInt32(obj.getLength()); + } + + @Override + public Object get(int index) { + checkRange(index); + return obj.get(index); + } + + @Override + public Object set(int index, Object element) { + checkRange(index); + final Object prevValue = get(index); + obj.set(index, element, false); + return prevValue; + } + + private void checkRange(int index) { + if(index < 0 || index >= size()) { + throw invalidIndex(index); + } + } + + @Override + public void push(Object e) { + addFirst(e); + } + + @Override + public boolean add(Object e) { + addLast(e); + return true; + } + + @Override + public void addFirst(Object e) { + try { + final Object fn = UNSHIFT.getGetter().invokeExact(obj); + checkFunction(fn, UNSHIFT); + UNSHIFT.getInvoker().invokeExact(fn, obj, e); + } catch(RuntimeException | Error ex) { + throw ex; + } catch(Throwable t) { + throw new RuntimeException(t); + } + } + + @Override + public void addLast(Object e) { + try { + final Object fn = PUSH.getGetter().invokeExact(obj); + checkFunction(fn, PUSH); + PUSH.getInvoker().invokeExact(fn, obj, e); + } catch(RuntimeException | Error ex) { + throw ex; + } catch(Throwable t) { + throw new RuntimeException(t); + } + } + + @Override + public void add(int index, Object e) { + try { + if(index < 0) { + throw invalidIndex(index); + } else if(index == 0) { + addFirst(e); + } else { + final int size = size(); + if(index < size) { + final Object fn = SPLICE_ADD.getGetter().invokeExact(obj); + checkFunction(fn, SPLICE_ADD); + SPLICE_ADD.getInvoker().invokeExact(fn, obj, index, 0, e); + } else if(index == size) { + addLast(e); + } else { + throw invalidIndex(index); + } + } + } catch(RuntimeException | Error ex) { + throw ex; + } catch(Throwable t) { + throw new RuntimeException(t); + } + } + private static void checkFunction(Object fn, InvokeByName invoke) { + if(!(fn instanceof ScriptFunction)) { + throw new UnsupportedOperationException("The script object doesn't have a function named " + invoke.getName()); + } + } + + private static IndexOutOfBoundsException invalidIndex(int index) { + return new IndexOutOfBoundsException(String.valueOf(index)); + } + + @Override + public boolean offer(Object e) { + return offerLast(e); + } + + @Override + public boolean offerFirst(Object e) { + addFirst(e); + return true; + } + + @Override + public boolean offerLast(Object e) { + addLast(e); + return true; + } + + @Override + public Object pop() { + return removeFirst(); + } + + @Override + public Object remove() { + return removeFirst(); + } + + @Override + public Object removeFirst() { + checkNonEmpty(); + return invokeShift(); + } + + @Override + public Object removeLast() { + checkNonEmpty(); + return invokePop(); + } + + private void checkNonEmpty() { + if(isEmpty()) { + throw new NoSuchElementException(); + } + } + + @Override + public Object remove(int index) { + if(index < 0) { + throw invalidIndex(index); + } else if (index == 0) { + return invokeShift(); + } else { + final int maxIndex = size() - 1; + if(index < maxIndex) { + final Object prevValue = get(index); + invokeSpliceRemove(index, 1); + return prevValue; + } else if(index == maxIndex) { + return invokePop(); + } else { + throw invalidIndex(index); + } + } + } + + private Object invokeShift() { + try { + final Object fn = SHIFT.getGetter().invokeExact(obj); + checkFunction(fn, SHIFT); + return SHIFT.getInvoker().invokeExact(fn, obj); + } catch(RuntimeException | Error ex) { + throw ex; + } catch(Throwable t) { + throw new RuntimeException(t); + } + } + + private Object invokePop() { + try { + final Object fn = POP.getGetter().invokeExact(obj); + checkFunction(fn, POP); + return POP.getInvoker().invokeExact(fn, obj); + } catch(RuntimeException | Error ex) { + throw ex; + } catch(Throwable t) { + throw new RuntimeException(t); + } + } + + @Override + protected void removeRange(int fromIndex, int toIndex) { + invokeSpliceRemove(fromIndex, toIndex - fromIndex); + } + + private void invokeSpliceRemove(int fromIndex, int count) { + try { + final Object fn = SPLICE_REMOVE.getGetter().invokeExact(obj); + checkFunction(fn, SPLICE_REMOVE); + SPLICE_REMOVE.getInvoker().invokeExact(fn, obj, fromIndex, count); + } catch(RuntimeException | Error ex) { + throw ex; + } catch(Throwable t) { + throw new RuntimeException(t); + } + } + + @Override + public Object poll() { + return pollFirst(); + } + + @Override + public Object pollFirst() { + return isEmpty() ? null : invokeShift(); + } + + @Override + public Object pollLast() { + return isEmpty() ? null : invokePop(); + } + + @Override + public Object peek() { + return peekFirst(); + } + + @Override + public Object peekFirst() { + return isEmpty() ? null : get(0); + } + + @Override + public Object peekLast() { + return isEmpty() ? null : get(size() - 1); + } + + @Override + public Object element() { + return getFirst(); + } + + @Override + public Object getFirst() { + checkNonEmpty(); + return get(0); + } + + @Override + public Object getLast() { + checkNonEmpty(); + return get(size() - 1); + } + + @Override + public Iterator descendingIterator() { + final ListIterator it = listIterator(size()); + return new Iterator() { + @Override + public boolean hasNext() { + return it.hasPrevious(); + } + + @Override + public Object next() { + return it.previous(); + } + + @Override + public void remove() { + it.remove(); + } + }; + } + + @Override + public boolean removeFirstOccurrence(Object o) { + return removeOccurrence(o, iterator()); + } + + @Override + public boolean removeLastOccurrence(Object o) { + return removeOccurrence(o, descendingIterator()); + } + + private static boolean removeOccurrence(Object o, Iterator it) { + while(it.hasNext()) { + final Object e = it.next(); + if(o == null ? e == null : o.equals(e)) { + it.remove(); + return true; + } + } + return false; + } +} diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/InvokeByName.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/InvokeByName.java index 30e91ec332b..4bfb6851c08 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/InvokeByName.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/InvokeByName.java @@ -40,7 +40,7 @@ import java.lang.invoke.MethodHandle; * private static final InvokeByName TO_JSON = new InvokeByName("toJSON", Object.class, Object.class, Object.class); * ... * final Object toJSONFn = TO_JSON.getGetter().invokeExact(obj); - * value = TO_JSON.getInvoker().invokeExact(toJSON, obj, key); + * value = TO_JSON.getInvoker().invokeExact(toJSONFn, obj, key); * * In practice, you can have stronger type assumptions if it makes sense for your code, just remember that you must use * the same parameter types as the formal types of the arguments for {@code invokeExact} to work: @@ -50,7 +50,7 @@ import java.lang.invoke.MethodHandle; * final ScriptObject sobj = (ScriptObject)obj; * final Object toJSONFn = TO_JSON.getGetter().invokeExact(sobj); * if(toJSONFn instanceof ScriptFunction) { - * value = TO_JSON.getInvoker().invokeExact(toJSON, sobj, key); + * value = TO_JSON.getInvoker().invokeExact(toJSONFn, sobj, key); * } * * Note that in general you will not want to reuse a single instance of this class for implementing more than one call @@ -59,6 +59,7 @@ import java.lang.invoke.MethodHandle; * separate instance of this class for every place. */ public class InvokeByName { + private final String name; private final MethodHandle getter; private final MethodHandle invoker; @@ -81,6 +82,7 @@ public class InvokeByName { * @param ptypes the parameter types of the function. */ public InvokeByName(final String name, final Class targetClass, final Class rtype, final Class... ptypes) { + this.name = name; getter = Bootstrap.createDynamicInvoker("dyn:getMethod|getProp|getItem:" + name, Object.class, targetClass); final Class[] finalPtypes; @@ -96,6 +98,14 @@ public class InvokeByName { invoker = Bootstrap.createDynamicInvoker("dyn:call", rtype, finalPtypes); } + /** + * Returns the name of the function retrieved through this invoker. + * @return the name of the function retrieved through this invoker. + */ + public String getName() { + return name; + } + /** * Returns the property getter that can be invoked on an object to retrieve the function object that will be * subsequently invoked by the invoker returned by {@link #getInvoker()}. diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties index 4f435ea2e96..b8d9e5e3c82 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties @@ -125,7 +125,7 @@ type.error.no.constructor.matches.args=Can not construct {0} with the passed arg type.error.no.method.matches.args=Can not invoke method {0} with the passed arguments; they do not match any of its method signatures. type.error.method.not.constructor=Java method {0} can't be used as a constructor. type.error.env.not.object=$ENV must be an Object. -type.error.to.expects.array.type=Java.to() expects an array target type. {0} is not an array type. +type.error.unsupported.java.to.type=Unsupported Java.to target type {0}. range.error.inappropriate.array.length=inappropriate array length: {0} range.error.invalid.fraction.digits=fractionDigits argument to {0} must be in [0, 20] range.error.invalid.precision=precision argument toPrecision() must be in [1, 21] diff --git a/nashorn/test/script/basic/JDK-8015267.js b/nashorn/test/script/basic/JDK-8015267.js new file mode 100644 index 00000000000..b7c1f9bfacf --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015267.js @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8015267: have a List/Deque adapter for JS array-like objects + * + * @test + * @run + */ + +var a = ['a', 'b', 'c', 'd'] + +var l = Java.to(a, java.util.List) +print(l instanceof java.util.List) +print(l instanceof java.util.Deque) + +print(l[0]) +print(l[1]) +print(l[2]) +print(l[3]) + +print(l.size()) + +l.push('x') +print(a) + +l.addLast('y') +print(a) + +print(l.pop()) +print(l.removeLast()) +print(a) + +l.add('e') +l.add(5, 'f') +print(a) + +l.add(0, 'z') +print(a) + +l.add(2, 'x') +print(a) + +l[7] = 'g' +print(a) + +try { l.add(15, '') } catch(e) { print(e.class) } +try { l.remove(15) } catch(e) { print(e.class) } +try { l.add(-1, '') } catch(e) { print(e.class) } +try { l.remove(-1) } catch(e) { print(e.class) } + +l.remove(7) +l.remove(2) +l.remove(0) +print(a) + +print(l.peek()) +print(l.peekFirst()) +print(l.peekLast()) + +print(l.element()) +print(l.getFirst()) +print(l.getLast()) + +l.offer('1') +l.offerFirst('2') +l.offerLast('3') +print(a) + +a = ['1', '2', 'x', '3', '4', 'x', '5', '6', 'x', '7', '8'] +print(a) +var l = Java.to(a, java.util.List) +l.removeFirstOccurrence('x') +print(a) +l.removeLastOccurrence('x') +print(a) + +var empty = Java.to([], java.util.List) +try { empty.pop() } catch(e) { print(e.class) } +try { empty.removeFirst() } catch(e) { print(e.class) } +try { empty.removeLast() } catch(e) { print(e.class) } + +try { empty.element() } catch(e) { print(e.class) } +try { empty.getFirst() } catch(e) { print(e.class) } +try { empty.getLast() } catch(e) { print(e.class) } + +print(empty.peek()) +print(empty.peekFirst()) +print(empty.peekLast()) diff --git a/nashorn/test/script/basic/JDK-8015267.js.EXPECTED b/nashorn/test/script/basic/JDK-8015267.js.EXPECTED new file mode 100644 index 00000000000..9f49603b439 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015267.js.EXPECTED @@ -0,0 +1,40 @@ +true +true +a +b +c +d +4 +x,a,b,c,d +x,a,b,c,d,y +x +y +a,b,c,d +a,b,c,d,e,f +z,a,b,c,d,e,f +z,a,x,b,c,d,e,f +z,a,x,b,c,d,e,g +class java.lang.IndexOutOfBoundsException +class java.lang.IndexOutOfBoundsException +class java.lang.IndexOutOfBoundsException +class java.lang.IndexOutOfBoundsException +a,b,c,d,e +a +a +e +a +a +e +2,a,b,c,d,e,1,3 +1,2,x,3,4,x,5,6,x,7,8 +1,2,3,4,x,5,6,x,7,8 +1,2,3,4,x,5,6,7,8 +class java.util.NoSuchElementException +class java.util.NoSuchElementException +class java.util.NoSuchElementException +class java.util.NoSuchElementException +class java.util.NoSuchElementException +class java.util.NoSuchElementException +null +null +null From f9d1d0f53875c62de1a54e3f5433791f34fed175 Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Thu, 23 May 2013 13:10:58 +0200 Subject: [PATCH 042/206] 8012083: Array literal constant folding issue Reviewed-by: attila, jlaskey --- .../internal/codegen/CodeGenerator.java | 2 +- .../internal/codegen/FinalizeTypes.java | 2 +- .../internal/codegen/FoldConstants.java | 9 +++ nashorn/test/script/basic/JDK-8012083.js | 70 +++++++++++++++++++ .../test/script/basic/JDK-8012083.js.EXPECTED | 19 +++++ 5 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8012083.js create mode 100644 nashorn/test/script/basic/JDK-8012083.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index 617b5ab8474..56202ea0848 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -2295,7 +2295,7 @@ final class CodeGenerator extends NodeOperatorVisitor { @Override public boolean enterADD(final UnaryNode unaryNode) { load(unaryNode.rhs()); - assert unaryNode.rhs().getType().isNumber(); + assert unaryNode.rhs().getType().isNumber() : unaryNode.rhs().getType() + " "+ unaryNode.getSymbol(); method.store(unaryNode.getSymbol()); return false; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java b/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java index e94dab7c4ba..6f7a51f43c2 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java @@ -800,7 +800,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { Node resultNode = node; - if (node instanceof LiteralNode && !to.isObject()) { + if (node instanceof LiteralNode && !(node instanceof ArrayLiteralNode) && !to.isObject()) { final LiteralNode newNode = new LiteralNodeConstantEvaluator((LiteralNode)node, to).eval(); if (newNode != null) { resultNode = newNode; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java index 2e87631c5b6..321eaebe5fc 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java @@ -34,6 +34,7 @@ import jdk.nashorn.internal.ir.FunctionNode; import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.IfNode; import jdk.nashorn.internal.ir.LiteralNode; +import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.TernaryNode; import jdk.nashorn.internal.ir.UnaryNode; @@ -141,6 +142,10 @@ final class FoldConstants extends NodeVisitor { return null; } + if (rhsNode instanceof ArrayLiteralNode) { + return null; + } + final LiteralNode rhs = (LiteralNode)rhsNode; final boolean rhsInteger = rhs.getType().isInteger(); @@ -212,6 +217,10 @@ final class FoldConstants extends NodeVisitor { final LiteralNode lhs = (LiteralNode)parent.lhs(); final LiteralNode rhs = (LiteralNode)parent.rhs(); + if (lhs instanceof ArrayLiteralNode || rhs instanceof ArrayLiteralNode) { + return null; + } + final Type widest = Type.widest(lhs.getType(), rhs.getType()); boolean isInteger = widest.isInteger(); diff --git a/nashorn/test/script/basic/JDK-8012083.js b/nashorn/test/script/basic/JDK-8012083.js new file mode 100644 index 00000000000..e782ff538ef --- /dev/null +++ b/nashorn/test/script/basic/JDK-8012083.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8012093 - array literals can only be subject to constant evaluation under very special + * circumstances. + * + * @test + * @run + */ + + +var w00t = 17; +print(+[w00t]); + +var empty = []; +print(empty == false); + +print([] == false); +print([] === false); +print(!![]); + +print(~[]); +print(![]); +print(![17]); +print(![17,1,2]); + +var one = 1; +var two = 2; +var a1 = [one]; +var a2 = [two]; +print(+a1 + +a2); //3 + +var x = 1; +print(+["apa"]); +print(+[]); //0 +print(+[1]); //1 +print(+[x]); //1 +print(+[1,2,3]); //NaN +var a = []; +var b = [1]; +print(a/b); +print(++[[]][+[]]+[+[]]); //10 +print(+[] == 0); + +var first = [![]+[]][+[]][+[]]+[![]+[]][+[]][+!+[]]+[!+[]+[]][+![]][+![]]+[![]+[]][+[]][+!+[]]+[![]+[]][+[]][+!+[]+!+[]]; +var second =(![]+[])[+[]]+(![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]; + +print(first + " " + second); + diff --git a/nashorn/test/script/basic/JDK-8012083.js.EXPECTED b/nashorn/test/script/basic/JDK-8012083.js.EXPECTED new file mode 100644 index 00000000000..72d1e6738a9 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8012083.js.EXPECTED @@ -0,0 +1,19 @@ +17 +true +true +false +true +-1 +false +false +false +3 +NaN +0 +1 +1 +NaN +0 +10 +true +fatal fail From 75c3e853b403e50278036737278327fbe01ad109 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Thu, 23 May 2013 13:36:49 +0200 Subject: [PATCH 043/206] 8015278: Revert accidental changes to build.xml Reviewed-by: jlaskey, lagergren --- nashorn/make/build.xml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index 5324d91f405..7c05e789fe9 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -42,6 +42,8 @@ + + @@ -78,7 +80,19 @@ - + + + + + + Date: Thu, 23 May 2013 15:51:08 +0200 Subject: [PATCH 044/206] 8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts Reviewed-by: attila, jlaskey --- .../jdk/nashorn/internal/codegen/Attr.java | 116 ++--- .../internal/codegen/CodeGenerator.java | 485 ++++++------------ .../codegen/CodeGeneratorLexicalContext.java | 235 +++++++++ .../internal/codegen/CompilationPhase.java | 21 +- .../internal/codegen/FinalizeTypes.java | 36 +- .../internal/codegen/FoldConstants.java | 6 +- .../jdk/nashorn/internal/codegen/Lower.java | 53 +- .../internal/codegen/RangeAnalyzer.java | 8 +- .../internal/codegen/SharedScopeCall.java | 5 +- .../nashorn/internal/codegen/Splitter.java | 25 +- .../nashorn/internal/codegen/WeighNodes.java | 6 +- .../jdk/nashorn/internal/ir/AccessNode.java | 3 +- .../jdk/nashorn/internal/ir/BinaryNode.java | 2 +- .../src/jdk/nashorn/internal/ir/Block.java | 2 +- .../jdk/nashorn/internal/ir/BreakNode.java | 2 +- .../src/jdk/nashorn/internal/ir/CallNode.java | 3 +- .../src/jdk/nashorn/internal/ir/CaseNode.java | 2 +- .../jdk/nashorn/internal/ir/CatchNode.java | 2 +- .../jdk/nashorn/internal/ir/ContinueNode.java | 2 +- .../jdk/nashorn/internal/ir/EmptyNode.java | 2 +- .../jdk/nashorn/internal/ir/ExecuteNode.java | 2 +- .../src/jdk/nashorn/internal/ir/ForNode.java | 2 +- .../jdk/nashorn/internal/ir/FunctionNode.java | 2 +- .../jdk/nashorn/internal/ir/IdentNode.java | 3 +- .../src/jdk/nashorn/internal/ir/IfNode.java | 2 +- .../jdk/nashorn/internal/ir/IndexNode.java | 22 +- .../jdk/nashorn/internal/ir/LabelNode.java | 6 +- .../internal/ir/LexicalContextNode.java | 4 +- .../jdk/nashorn/internal/ir/LiteralNode.java | 7 +- nashorn/src/jdk/nashorn/internal/ir/Node.java | 5 +- .../jdk/nashorn/internal/ir/ObjectNode.java | 2 +- .../jdk/nashorn/internal/ir/PropertyNode.java | 2 +- .../jdk/nashorn/internal/ir/ReturnNode.java | 2 +- .../jdk/nashorn/internal/ir/RuntimeNode.java | 3 +- .../jdk/nashorn/internal/ir/SplitNode.java | 2 +- .../jdk/nashorn/internal/ir/SwitchNode.java | 6 +- .../jdk/nashorn/internal/ir/TernaryNode.java | 2 +- .../jdk/nashorn/internal/ir/ThrowNode.java | 2 +- .../src/jdk/nashorn/internal/ir/TryNode.java | 2 +- .../jdk/nashorn/internal/ir/UnaryNode.java | 3 +- .../src/jdk/nashorn/internal/ir/VarNode.java | 2 +- .../jdk/nashorn/internal/ir/WhileNode.java | 2 +- .../src/jdk/nashorn/internal/ir/WithNode.java | 2 +- .../nashorn/internal/ir/debug/JSONWriter.java | 9 +- .../internal/ir/debug/PrintVisitor.java | 4 +- .../ir/visitor/NodeOperatorVisitor.java | 12 +- .../internal/ir/visitor/NodeVisitor.java | 17 +- .../internal/objects/ArrayBufferView.java | 1 - .../nashorn/internal/runtime/DebugLogger.java | 1 - .../linker/JavaAdapterClassLoader.java | 2 + .../runtime/linker/JavaAdapterFactory.java | 2 + .../linker/JavaAdapterGeneratorBase.java | 1 + 52 files changed, 609 insertions(+), 543 deletions(-) create mode 100644 nashorn/src/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java index 4e47892f845..cf3e6946174 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java @@ -84,8 +84,8 @@ import jdk.nashorn.internal.ir.TryNode; import jdk.nashorn.internal.ir.UnaryNode; import jdk.nashorn.internal.ir.VarNode; import jdk.nashorn.internal.ir.WithNode; -import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor; import jdk.nashorn.internal.ir.visitor.NodeVisitor; +import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor; import jdk.nashorn.internal.parser.TokenType; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.Debug; @@ -111,7 +111,7 @@ import jdk.nashorn.internal.runtime.ScriptObject; * computed. */ -final class Attr extends NodeOperatorVisitor { +final class Attr extends NodeOperatorVisitor { /** * Local definitions in current block (to discriminate from function @@ -138,6 +138,7 @@ final class Attr extends NodeOperatorVisitor { * Constructor. */ Attr(final TemporarySymbols temporarySymbols) { + super(new LexicalContext()); this.temporarySymbols = temporarySymbols; this.localDefs = new ArrayDeque<>(); this.localUses = new ArrayDeque<>(); @@ -202,7 +203,7 @@ final class Attr extends NodeOperatorVisitor { private void acceptDeclarations(final FunctionNode functionNode, final Block body) { // This visitor will assign symbol to all declared variables, except function declarations (which are taken care // in a separate step above) and "var" declarations in for loop initializers. - body.accept(new NodeOperatorVisitor() { + body.accept(new NodeVisitor(new LexicalContext()) { @Override public boolean enterFunctionNode(final FunctionNode nestedFn) { return false; @@ -218,7 +219,7 @@ final class Attr extends NodeOperatorVisitor { if (varNode.isFunctionDeclaration()) { newType(symbol, FunctionNode.FUNCTION_TYPE); } - return varNode.setName((IdentNode)ident.setSymbol(getLexicalContext(), symbol)); + return varNode.setName((IdentNode)ident.setSymbol(lc, symbol)); } return varNode; } @@ -227,8 +228,8 @@ final class Attr extends NodeOperatorVisitor { private void enterFunctionBody() { - final FunctionNode functionNode = getLexicalContext().getCurrentFunction(); - final Block body = getLexicalContext().getCurrentBlock(); + final FunctionNode functionNode = lc.getCurrentFunction(); + final Block body = lc.getCurrentBlock(); initFunctionWideVariables(functionNode, body); @@ -256,7 +257,7 @@ final class Attr extends NodeOperatorVisitor { //the symbols in the block should really be stateless block.clearSymbols(); - if (getLexicalContext().isFunctionBody()) { + if (lc.isFunctionBody()) { enterFunctionBody(); } pushLocalsBlock(); @@ -283,7 +284,7 @@ final class Attr extends NodeOperatorVisitor { @Override public boolean enterCatchNode(final CatchNode catchNode) { final IdentNode exception = catchNode.getException(); - final Block block = getLexicalContext().getCurrentBlock(); + final Block block = lc.getCurrentBlock(); start(catchNode); @@ -298,10 +299,10 @@ final class Attr extends NodeOperatorVisitor { @Override public Node leaveCatchNode(final CatchNode catchNode) { final IdentNode exception = catchNode.getException(); - final Block block = getLexicalContext().getCurrentBlock(); + final Block block = lc.getCurrentBlock(); final Symbol symbol = findSymbol(block, exception.getName()); assert symbol != null; - return end(catchNode.setException((IdentNode)exception.setSymbol(getLexicalContext(), symbol))); + return end(catchNode.setException((IdentNode)exception.setSymbol(lc, symbol))); } /** @@ -320,7 +321,7 @@ final class Attr extends NodeOperatorVisitor { flags |= IS_SCOPE; } - final FunctionNode function = getLexicalContext().getFunction(block); + final FunctionNode function = lc.getFunction(block); if (symbol != null) { // Symbol was already defined. Check if it needs to be redefined. if ((flags & KINDMASK) == IS_PARAM) { @@ -353,12 +354,12 @@ final class Attr extends NodeOperatorVisitor { if ((flags & Symbol.KINDMASK) == IS_VAR && ((flags & IS_INTERNAL) == IS_INTERNAL || (flags & IS_LET) == IS_LET)) { symbolBlock = block; //internal vars are always defined in the block closest to them } else { - symbolBlock = getLexicalContext().getFunctionBody(function); + symbolBlock = lc.getFunctionBody(function); } // Create and add to appropriate block. symbol = new Symbol(name, flags); - symbolBlock.putSymbol(getLexicalContext(), symbol); + symbolBlock.putSymbol(lc, symbol); if ((flags & Symbol.KINDMASK) != IS_GLOBAL) { symbol.setNeedsSlot(true); @@ -381,7 +382,7 @@ final class Attr extends NodeOperatorVisitor { //an outermost function in our lexical context that is not a program (runScript) //is possible - it is a function being compiled lazily if (functionNode.isDeclared()) { - final Iterator blocks = getLexicalContext().getBlocks(); + final Iterator blocks = lc.getBlocks(); if (blocks.hasNext()) { defineSymbol(blocks.next(), functionNode.getIdent().getName(), IS_VAR); } @@ -397,13 +398,11 @@ final class Attr extends NodeOperatorVisitor { public Node leaveFunctionNode(final FunctionNode functionNode) { FunctionNode newFunctionNode = functionNode; - final LexicalContext lc = getLexicalContext(); - final Block body = newFunctionNode.getBody(); //look for this function in the parent block if (functionNode.isDeclared()) { - final Iterator blocks = getLexicalContext().getBlocks(); + final Iterator blocks = lc.getBlocks(); if (blocks.hasNext()) { newFunctionNode = (FunctionNode)newFunctionNode.setSymbol(lc, findSymbol(blocks.next(), functionNode.getIdent().getName())); } @@ -411,7 +410,7 @@ final class Attr extends NodeOperatorVisitor { final boolean anonymous = functionNode.isAnonymous(); final String name = anonymous ? null : functionNode.getIdent().getName(); if (anonymous || body.getExistingSymbol(name) != null) { - newFunctionNode = (FunctionNode)ensureSymbol(lc, FunctionNode.FUNCTION_TYPE, newFunctionNode); + newFunctionNode = (FunctionNode)ensureSymbol(FunctionNode.FUNCTION_TYPE, newFunctionNode); } else { assert name != null; final Symbol self = body.getExistingSymbol(name); @@ -490,8 +489,6 @@ final class Attr extends NodeOperatorVisitor { start(identNode); - final LexicalContext lc = getLexicalContext(); - if (identNode.isPropertyName()) { // assign a pseudo symbol to property name final Symbol pseudoSymbol = pseudoSymbol(name); @@ -549,7 +546,7 @@ final class Attr extends NodeOperatorVisitor { */ private void maybeForceScope(final Symbol symbol) { if (!symbol.isScope() && symbolNeedsToBeScope(symbol)) { - Symbol.setSymbolIsScope(getLexicalContext(), symbol); + Symbol.setSymbolIsScope(lc, symbol); } } @@ -558,7 +555,7 @@ final class Attr extends NodeOperatorVisitor { return false; } boolean previousWasBlock = false; - for(final Iterator it = getLexicalContext().getAllNodes(); it.hasNext();) { + for(final Iterator it = lc.getAllNodes(); it.hasNext();) { final LexicalContextNode node = it.next(); if(node instanceof FunctionNode) { // We reached the function boundary without seeing a definition for the symbol - it needs to be in @@ -594,10 +591,8 @@ final class Attr extends NodeOperatorVisitor { } if (symbol.isScope()) { - final LexicalContext lc = getLexicalContext(); - Block scopeBlock = null; - for (final Iterator contextNodeIter = getLexicalContext().getAllNodes(); contextNodeIter.hasNext(); ) { + for (final Iterator contextNodeIter = lc.getAllNodes(); contextNodeIter.hasNext(); ) { final LexicalContextNode node = contextNodeIter.next(); if (node instanceof Block) { if (((Block)node).getExistingSymbol(name) != null) { @@ -610,7 +605,7 @@ final class Attr extends NodeOperatorVisitor { } if (scopeBlock != null) { - assert getLexicalContext().contains(scopeBlock); + assert lc.contains(scopeBlock); lc.setFlag(scopeBlock, Block.NEEDS_SCOPE); } } @@ -622,8 +617,8 @@ final class Attr extends NodeOperatorVisitor { * @see #needsParentScope() */ private void setUsesGlobalSymbol() { - for (final Iterator fns = getLexicalContext().getFunctions(); fns.hasNext();) { - getLexicalContext().setFlag(fns.next(), FunctionNode.USES_ANCESTOR_SCOPE); + for (final Iterator fns = lc.getFunctions(); fns.hasNext();) { + lc.setFlag(fns.next(), FunctionNode.USES_ANCESTOR_SCOPE); } } @@ -635,7 +630,7 @@ final class Attr extends NodeOperatorVisitor { private Symbol findSymbol(final Block block, final String name) { // Search up block chain to locate symbol. - for (final Iterator blocks = getLexicalContext().getBlocks(block); blocks.hasNext();) { + for (final Iterator blocks = lc.getBlocks(block); blocks.hasNext();) { // Find name. final Symbol symbol = blocks.next().getExistingSymbol(name); // If found then we are good. @@ -656,11 +651,11 @@ final class Attr extends NodeOperatorVisitor { public Node leaveLiteralNode(final LiteralNode literalNode) { assert !literalNode.isTokenType(TokenType.THIS) : "tokentype for " + literalNode + " is this"; //guard against old dead code case. literal nodes should never inherit tokens assert literalNode instanceof ArrayLiteralNode || !(literalNode.getValue() instanceof Node) : "literals with Node values not supported"; - final Symbol symbol = new Symbol(getLexicalContext().getCurrentFunction().uniqueName(LITERAL_PREFIX.symbolName()), IS_CONSTANT, literalNode.getType()); + final Symbol symbol = new Symbol(lc.getCurrentFunction().uniqueName(LITERAL_PREFIX.symbolName()), IS_CONSTANT, literalNode.getType()); if (literalNode instanceof ArrayLiteralNode) { ((ArrayLiteralNode)literalNode).analyze(); } - return end(literalNode.setSymbol(getLexicalContext(), symbol)); + return end(literalNode.setSymbol(lc, symbol)); } @Override @@ -676,7 +671,7 @@ final class Attr extends NodeOperatorVisitor { @Override public Node leavePropertyNode(final PropertyNode propertyNode) { // assign a pseudo symbol to property name, see NASHORN-710 - return propertyNode.setSymbol(getLexicalContext(), new Symbol(propertyNode.getKeyName(), 0, Type.OBJECT)); + return propertyNode.setSymbol(lc, new Symbol(propertyNode.getKeyName(), 0, Type.OBJECT)); } @Override @@ -734,11 +729,11 @@ final class Attr extends NodeOperatorVisitor { type = Type.OBJECT; } - switchNode.setTag(newInternal(getLexicalContext().getCurrentFunction().uniqueName(SWITCH_TAG_PREFIX.symbolName()), type)); + switchNode.setTag(newInternal(lc.getCurrentFunction().uniqueName(SWITCH_TAG_PREFIX.symbolName()), type)); end(switchNode); - return switchNode.setCases(getLexicalContext(), newCases); + return switchNode.setCases(lc, newCases); } @Override @@ -761,7 +756,7 @@ final class Attr extends NodeOperatorVisitor { final IdentNode ident = varNode.getName(); final String name = ident.getName(); - final Symbol symbol = defineSymbol(getLexicalContext().getCurrentBlock(), name, IS_VAR); + final Symbol symbol = defineSymbol(lc.getCurrentBlock(), name, IS_VAR); assert symbol != null; // NASHORN-467 - use before definition of vars - conservative @@ -781,7 +776,6 @@ final class Attr extends NodeOperatorVisitor { final IdentNode ident = newVarNode.getName(); final String name = ident.getName(); - final LexicalContext lc = getLexicalContext(); final Symbol symbol = findSymbol(lc.getCurrentBlock(), ident.getName()); if (init == null) { @@ -834,7 +828,7 @@ final class Attr extends NodeOperatorVisitor { @Override public Node leaveDELETE(final UnaryNode unaryNode) { - final FunctionNode currentFunctionNode = getLexicalContext().getCurrentFunction(); + final FunctionNode currentFunctionNode = lc.getCurrentFunction(); final boolean strictMode = currentFunctionNode.isStrict(); final Node rhs = unaryNode.rhs(); final Node strictFlagNode = LiteralNode.newInstance(unaryNode, strictMode).accept(this); @@ -894,10 +888,10 @@ final class Attr extends NodeOperatorVisitor { * @return true if the symbol denoted by the specified name in the current lexical context defined in the program level. */ private boolean isProgramLevelSymbol(final String name) { - for(final Iterator it = getLexicalContext().getBlocks(); it.hasNext();) { + for(final Iterator it = lc.getBlocks(); it.hasNext();) { final Block next = it.next(); if(next.getExistingSymbol(name) != null) { - return next == getLexicalContext().getFunctionBody(getLexicalContext().getOutermostFunction()); + return next == lc.getFunctionBody(lc.getOutermostFunction()); } } throw new AssertionError("Couldn't find symbol " + name + " in the context"); @@ -914,14 +908,14 @@ final class Attr extends NodeOperatorVisitor { } private IdentNode compilerConstant(CompilerConstants cc) { - final FunctionNode functionNode = getLexicalContext().getCurrentFunction(); + final FunctionNode functionNode = lc.getCurrentFunction(); return (IdentNode) new IdentNode( functionNode.getToken(), functionNode.getFinish(), cc.symbolName()). setSymbol( - getLexicalContext(), + lc, functionNode.compilerConstant(cc)); } @@ -999,7 +993,7 @@ final class Attr extends NodeOperatorVisitor { final Node lhs = binaryNode.lhs(); if (lhs instanceof IdentNode) { - final Block block = getLexicalContext().getCurrentBlock(); + final Block block = lc.getCurrentBlock(); final IdentNode ident = (IdentNode)lhs; final String name = ident.getName(); @@ -1043,7 +1037,7 @@ final class Attr extends NodeOperatorVisitor { } private boolean isLocal(FunctionNode function, Symbol symbol) { - final FunctionNode definingFn = getLexicalContext().getDefiningFunction(symbol); + final FunctionNode definingFn = lc.getDefiningFunction(symbol); // Temp symbols are not assigned to a block, so their defining fn is null; those can be assumed local return definingFn == null || definingFn == function; } @@ -1329,7 +1323,7 @@ final class Attr extends NodeOperatorVisitor { @Override public Node leaveForNode(final ForNode forNode) { if (forNode.isForIn()) { - forNode.setIterator(newInternal(getLexicalContext().getCurrentFunction().uniqueName(ITERATOR_PREFIX.symbolName()), Type.OBJECT)); //NASHORN-73 + forNode.setIterator(newInternal(lc.getCurrentFunction().uniqueName(ITERATOR_PREFIX.symbolName()), Type.OBJECT)); //NASHORN-73 /* * Iterators return objects, so we need to widen the scope of the * init variable if it, for example, has been assigned double type @@ -1407,7 +1401,7 @@ final class Attr extends NodeOperatorVisitor { final Symbol paramSymbol = functionNode.getBody().getExistingSymbol(param.getName()); assert paramSymbol != null; assert paramSymbol.isParam(); - newParams.add((IdentNode)param.setSymbol(getLexicalContext(), paramSymbol)); + newParams.add((IdentNode)param.setSymbol(lc, paramSymbol)); assert paramSymbol != null; Type type = functionNode.getHints().getParameterType(pos); @@ -1439,10 +1433,10 @@ final class Attr extends NodeOperatorVisitor { FunctionNode newFunctionNode = functionNode; if (nparams == 0 || (specialize * 2) < nparams) { - newFunctionNode = newFunctionNode.clearSnapshot(getLexicalContext()); + newFunctionNode = newFunctionNode.clearSnapshot(lc); } - return newFunctionNode.setParameters(getLexicalContext(), newParams); + return newFunctionNode.setParameters(lc, newParams); } /** @@ -1506,7 +1500,7 @@ final class Attr extends NodeOperatorVisitor { } private Symbol exceptionSymbol() { - return newInternal(getLexicalContext().getCurrentFunction().uniqueName(EXCEPTION_PREFIX.symbolName()), Type.typeFor(ECMAException.class)); + return newInternal(lc.getCurrentFunction().uniqueName(EXCEPTION_PREFIX.symbolName()), Type.typeFor(ECMAException.class)); } /** @@ -1520,8 +1514,8 @@ final class Attr extends NodeOperatorVisitor { * @param assignmentDest the destination node of the assignment, e.g. lhs for binary nodes */ private Node ensureAssignmentSlots(final Node assignmentDest) { - final LexicalContext attrLexicalContext = getLexicalContext(); - return assignmentDest.accept(new NodeVisitor() { + final LexicalContext attrLexicalContext = lc; + return assignmentDest.accept(new NodeVisitor(new LexicalContext()) { @Override public Node leaveIndexNode(final IndexNode indexNode) { assert indexNode.getSymbol().isTemp(); @@ -1565,7 +1559,7 @@ final class Attr extends NodeOperatorVisitor { FunctionNode currentFunctionNode = functionNode; do { changed.clear(); - final FunctionNode newFunctionNode = (FunctionNode)currentFunctionNode.accept(new NodeVisitor() { + final FunctionNode newFunctionNode = (FunctionNode)currentFunctionNode.accept(new NodeVisitor(new LexicalContext()) { private Node widen(final Node node, final Type to) { if (node instanceof LiteralNode) { @@ -1579,7 +1573,7 @@ final class Attr extends NodeOperatorVisitor { symbol = temporarySymbols.getTypedTemporarySymbol(to); } newType(symbol, to); - final Node newNode = node.setSymbol(getLexicalContext(), symbol); + final Node newNode = node.setSymbol(lc, symbol); changed.add(newNode); return newNode; } @@ -1622,7 +1616,7 @@ final class Attr extends NodeOperatorVisitor { return newBinaryNode; } }); - getLexicalContext().replace(currentFunctionNode, newFunctionNode); + lc.replace(currentFunctionNode, newFunctionNode); currentFunctionNode = newFunctionNode; } while (!changed.isEmpty()); return currentFunctionNode; @@ -1643,12 +1637,12 @@ final class Attr extends NodeOperatorVisitor { } private Node ensureSymbol(final Type type, final Node node) { - LOG.info("New TEMPORARY added to ", getLexicalContext().getCurrentFunction().getName(), " type=", type); - return ensureSymbol(getLexicalContext(), type, node); + LOG.info("New TEMPORARY added to ", lc.getCurrentFunction().getName(), " type=", type); + return temporarySymbols.ensureSymbol(lc, type, node); } private Symbol newInternal(final String name, final Type type) { - final Symbol iter = defineSymbol(getLexicalContext().getCurrentBlock(), name, IS_VAR | IS_INTERNAL); + final Symbol iter = defineSymbol(lc.getCurrentBlock(), name, IS_VAR | IS_INTERNAL); iter.setType(type); // NASHORN-73 return iter; } @@ -1705,10 +1699,6 @@ final class Attr extends NodeOperatorVisitor { localUses.peek().add(name); } - private Node ensureSymbol(final LexicalContext lc, final Type type, final Node node) { - return temporarySymbols.ensureSymbol(lc, type, node); - } - /** * Pessimistically promote all symbols in current function node to Object types * This is done when the function contains unevaluated black boxes such as @@ -1717,7 +1707,7 @@ final class Attr extends NodeOperatorVisitor { * @param body body for the function node we are leaving */ private static void objectifySymbols(final Block body) { - body.accept(new NodeVisitor() { + body.accept(new NodeVisitor(new LexicalContext()) { private void toObject(final Block block) { for (final Symbol symbol : block.getSymbols()) { if (!symbol.isTemp()) { @@ -1761,7 +1751,7 @@ final class Attr extends NodeOperatorVisitor { append("] "). append(printNode ? node.toString() : ""). append(" in '"). - append(getLexicalContext().getCurrentFunction().getName()). + append(lc.getCurrentFunction().getName()). append("'"); LOG.info(sb); LOG.indent(); @@ -1787,7 +1777,7 @@ final class Attr extends NodeOperatorVisitor { append("] "). append(printNode ? node.toString() : ""). append(" in '"). - append(getLexicalContext().getCurrentFunction().getName()); + append(lc.getCurrentFunction().getName()); if (node.getSymbol() == null) { sb.append(" "); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index 56202ea0848..aae2fd2df7c 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -52,16 +52,12 @@ import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALL import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_STRICT; import java.io.PrintWriter; -import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; -import java.util.Deque; import java.util.EnumSet; -import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import java.util.Map; import java.util.TreeMap; import jdk.nashorn.internal.codegen.ClassEmitter.Flag; @@ -83,11 +79,11 @@ import jdk.nashorn.internal.ir.EmptyNode; import jdk.nashorn.internal.ir.ExecuteNode; import jdk.nashorn.internal.ir.ForNode; import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.IdentNode; import jdk.nashorn.internal.ir.IfNode; import jdk.nashorn.internal.ir.IndexNode; -import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.LexicalContextNode; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; @@ -150,7 +146,7 @@ import jdk.nashorn.internal.runtime.linker.LinkerCallSite; * The CodeGenerator visits nodes only once, tags them as resolved and emits * bytecode for them. */ -final class CodeGenerator extends NodeOperatorVisitor { +final class CodeGenerator extends NodeOperatorVisitor { /** Name of the Global object, cannot be referred to as .class, @see CodeGenerator */ private static final String GLOBAL_OBJECT = Compiler.OBJECTS_PACKAGE + '/' + "Global"; @@ -168,23 +164,12 @@ final class CodeGenerator extends NodeOperatorVisitor { /** How many regexp fields have been emitted */ private int regexFieldCount; - /** Map of shared scope call sites */ - private final Map scopeCalls = new HashMap<>(); + /** Line number for last statement. If we encounter a new line number, line number bytecode information + * needs to be generated */ + private int lastLineNumber = -1; - /** Compile unit stack - every time we start a sub method (e.g. a split) we push one */ - private final Deque compileUnits = new ArrayDeque<>(); - - /** Method emitter stack - every time we start a sub method (e.g. a split) we push one */ - private final Deque methodEmitters = new ArrayDeque<>(); - - /** The discard stack - whenever we enter a discard node we keep track of its return value status - - * i.e. should we keep it or throw it away */ - private final Deque discard = new ArrayDeque<>(); - - // A stack tracking the next free local variable slot in the blocks. There's one entry for every block - // currently on the lexical context stack. - private int[] nextFreeSlots = new int[16]; - private int nextFreeSlotsSize = 0; + /** When should we stop caching regexp expressions in fields to limit bytecode size? */ + private static final int MAX_REGEX_FIELDS = 2 * 1024; /** Current method emitter */ private MethodEmitter method; @@ -192,20 +177,16 @@ final class CodeGenerator extends NodeOperatorVisitor { /** Current compile unit */ private CompileUnit unit; - private int lastLineNumber = -1; - - /** When should we stop caching regexp expressions in fields to limit bytecode size? */ - private static final int MAX_REGEX_FIELDS = 2 * 1024; - private static final DebugLogger LOG = new DebugLogger("codegen", "nashorn.codegen.debug"); + /** * Constructor. * * @param compiler */ CodeGenerator(final Compiler compiler) { - super(new DynamicScopeTrackingLexicalContext()); + super(new CodeGeneratorLexicalContext()); this.compiler = compiler; this.callSiteFlags = compiler.getEnv()._callsite_flags; } @@ -217,37 +198,7 @@ final class CodeGenerator extends NodeOperatorVisitor { * @return the correct flags for a call site in the current function */ int getCallSiteFlags() { - return getLexicalContext().getCurrentFunction().isStrict() ? callSiteFlags | CALLSITE_STRICT : callSiteFlags; - } - - private void pushMethodEmitter(final MethodEmitter newMethod) { - methodEmitters.push(newMethod); - this.method = newMethod; - } - - private void popMethodEmitter(final MethodEmitter oldMethod) { - assert methodEmitters.peek() == oldMethod; - methodEmitters.pop(); - if (!methodEmitters.isEmpty()) { - this.method = methodEmitters.peek(); - } else { - this.method = null; - } - } - - private void push(final CompileUnit newUnit) { - compileUnits.push(newUnit); - this.unit = newUnit; - } - - private void pop(final CompileUnit oldUnit) { - assert compileUnits.peek() == oldUnit; - compileUnits.pop(); - if (!compileUnits.isEmpty()) { - this.unit = compileUnits.peek(); - } else { - this.unit = null; - } + return lc.getCurrentFunction().isStrict() ? callSiteFlags | CALLSITE_STRICT : callSiteFlags; } /** @@ -265,7 +216,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } final String name = symbol.getName(); - final Source source = getLexicalContext().getCurrentFunction().getSource(); + final Source source = lc.getCurrentFunction().getSource(); if (CompilerConstants.__FILE__.name().equals(name)) { return method.load(source.getName()); @@ -290,53 +241,6 @@ final class CodeGenerator extends NodeOperatorVisitor { } } - /** - * A lexical context that also tracks if we have any dynamic scopes in the context. Such scopes can have new - * variables introduced into them at run time - a with block or a function directly containing an eval call. - */ - private static class DynamicScopeTrackingLexicalContext extends LexicalContext { - int dynamicScopeCount = 0; - - @Override - public T push(T node) { - if(isDynamicScopeBoundary(node)) { - ++dynamicScopeCount; - } - return super.push(node); - } - - @Override - public T pop(T node) { - final T popped = super.pop(node); - if(isDynamicScopeBoundary(popped)) { - --dynamicScopeCount; - } - return popped; - } - - private boolean isDynamicScopeBoundary(LexicalContextNode node) { - if(node instanceof Block) { - // Block's immediate parent is a with node. Note we aren't testing for a WithNode, as that'd capture - // processing of WithNode.expression too, but it should be unaffected. - return !isEmpty() && peek() instanceof WithNode; - } else if(node instanceof FunctionNode) { - // Function has a direct eval in it (so a top-level "var ..." in the eval code can introduce a new - // variable into the function's scope), and it isn't strict (as evals in strict functions get an - // isolated scope). - return isFunctionDynamicScope((FunctionNode)node); - } - return false; - } - } - - boolean inDynamicScope() { - return ((DynamicScopeTrackingLexicalContext)getLexicalContext()).dynamicScopeCount > 0; - } - - static boolean isFunctionDynamicScope(FunctionNode fn) { - return fn.hasEval() && !fn.isStrict(); - } - /** * Check if this symbol can be accessed directly with a putfield or getfield or dynamic load * @@ -344,35 +248,37 @@ final class CodeGenerator extends NodeOperatorVisitor { * @return true if fast scope */ private boolean isFastScope(final Symbol symbol) { - if(!symbol.isScope()) { + if (!symbol.isScope()) { return false; } - final LexicalContext lc = getLexicalContext(); - if(!inDynamicScope()) { + + if (!lc.inDynamicScope()) { // If there's no with or eval in context, and the symbol is marked as scoped, it is fast scoped. Such a // symbol must either be global, or its defining block must need scope. assert symbol.isGlobal() || lc.getDefiningBlock(symbol).needsScope() : symbol.getName(); return true; } - if(symbol.isGlobal()) { + + if (symbol.isGlobal()) { // Shortcut: if there's a with or eval in context, globals can't be fast scoped return false; } + // Otherwise, check if there's a dynamic scope between use of the symbol and its definition final String name = symbol.getName(); boolean previousWasBlock = false; for (final Iterator it = lc.getAllNodes(); it.hasNext();) { final LexicalContextNode node = it.next(); - if(node instanceof Block) { + if (node instanceof Block) { // If this block defines the symbol, then we can fast scope the symbol. final Block block = (Block)node; - if(block.getExistingSymbol(name) == symbol) { + if (block.getExistingSymbol(name) == symbol) { assert block.needsScope(); return true; } previousWasBlock = true; } else { - if((node instanceof WithNode && previousWasBlock) || (node instanceof FunctionNode && isFunctionDynamicScope((FunctionNode)node))) { + if ((node instanceof WithNode && previousWasBlock) || (node instanceof FunctionNode && CodeGeneratorLexicalContext.isFunctionDynamicScope((FunctionNode)node))) { // If we hit a scope that can have symbols introduced into it at run time before finding the defining // block, the symbol can't be fast scoped. A WithNode only counts if we've immediately seen a block // before - its block. Otherwise, we are currently processing the WithNode's expression, and that's @@ -387,16 +293,14 @@ final class CodeGenerator extends NodeOperatorVisitor { } private MethodEmitter loadSharedScopeVar(final Type valueType, final Symbol symbol, final int flags) { - method.load(isFastScope(symbol) ? getScopeProtoDepth(getLexicalContext().getCurrentBlock(), symbol) : -1); - final SharedScopeCall scopeCall = getScopeGet(valueType, symbol, flags | CALLSITE_FAST_SCOPE); - scopeCall.generateInvoke(method); - return method; + method.load(isFastScope(symbol) ? getScopeProtoDepth(lc.getCurrentBlock(), symbol) : -1); + final SharedScopeCall scopeCall = lc.getScopeGet(unit, valueType, symbol, flags | CALLSITE_FAST_SCOPE); + return scopeCall.generateInvoke(method); } private MethodEmitter loadFastScopeVar(final Type valueType, final Symbol symbol, final int flags, final boolean isMethod) { loadFastScopeProto(symbol, false); - method.dynamicGet(valueType, symbol.getName(), flags | CALLSITE_FAST_SCOPE, isMethod); - return method; + return method.dynamicGet(valueType, symbol.getName(), flags | CALLSITE_FAST_SCOPE, isMethod); } private MethodEmitter storeFastScopeVar(final Type valueType, final Symbol symbol, final int flags) { @@ -408,7 +312,7 @@ final class CodeGenerator extends NodeOperatorVisitor { private int getScopeProtoDepth(final Block startingBlock, final Symbol symbol) { int depth = 0; final String name = symbol.getName(); - for(final Iterator blocks = getLexicalContext().getBlocks(startingBlock); blocks.hasNext();) { + for(final Iterator blocks = lc.getBlocks(startingBlock); blocks.hasNext();) { final Block currentBlock = blocks.next(); if (currentBlock.getExistingSymbol(name) == symbol) { return depth; @@ -421,7 +325,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } private void loadFastScopeProto(final Symbol symbol, final boolean swap) { - final int depth = getScopeProtoDepth(getLexicalContext().getCurrentBlock(), symbol); + final int depth = getScopeProtoDepth(lc.getCurrentBlock(), symbol); assert depth != -1; if (depth > 0) { if (swap) { @@ -464,7 +368,7 @@ final class CodeGenerator extends NodeOperatorVisitor { */ final CodeGenerator codegen = this; - node.accept(new NodeVisitor() { + node.accept(new NodeVisitor(new LexicalContext()) { @Override public boolean enterIdentNode(final IdentNode identNode) { loadIdent(identNode); @@ -538,7 +442,7 @@ final class CodeGenerator extends NodeOperatorVisitor { final boolean isInternal = symbol.isParam() || symbol.isInternal() || symbol.isThis() || !symbol.canBeUndefined(); if (symbol.hasSlot() && !isInternal) { - assert symbol.getSymbolType().isNumber() || symbol.getSymbolType().isObject() : "no potentially undefined narrower local vars than doubles are allowed: " + symbol + " in " + getLexicalContext().getCurrentFunction(); + assert symbol.getSymbolType().isNumber() || symbol.getSymbolType().isObject() : "no potentially undefined narrower local vars than doubles are allowed: " + symbol + " in " + lc.getCurrentFunction(); if (symbol.getSymbolType().isNumber()) { numbers.add(symbol); } else if (symbol.getSymbolType().isObject()) { @@ -595,7 +499,6 @@ final class CodeGenerator extends NodeOperatorVisitor { if (block.needsScope() && !block.isTerminal()) { popBlockScope(block); } - --nextFreeSlotsSize; return block; } @@ -624,11 +527,11 @@ final class CodeGenerator extends NodeOperatorVisitor { public boolean enterBreakNode(final BreakNode breakNode) { lineNumber(breakNode); - final BreakableNode breakFrom = getLexicalContext().getBreakable(breakNode.getLabel()); - for (int i = 0; i < getLexicalContext().getScopeNestingLevelTo(breakFrom); i++) { + final BreakableNode breakFrom = lc.getBreakable(breakNode.getLabel()); + for (int i = 0; i < lc.getScopeNestingLevelTo(breakFrom); i++) { closeWith(); } - method.splitAwareGoto(getLexicalContext(), breakFrom.getBreakLabel()); + method.splitAwareGoto(lc, breakFrom.getBreakLabel()); return false; } @@ -672,11 +575,12 @@ final class CodeGenerator extends NodeOperatorVisitor { final List args = callNode.getArgs(); final Node function = callNode.getFunction(); - final Block currentBlock = getLexicalContext().getCurrentBlock(); + final Block currentBlock = lc.getCurrentBlock(); + final CodeGeneratorLexicalContext codegenLexicalContext = lc; - function.accept(new NodeVisitor() { + function.accept(new NodeVisitor(new LexicalContext()) { - private void sharedScopeCall(final IdentNode identNode, final int flags) { + private MethodEmitter sharedScopeCall(final IdentNode identNode, final int flags) { final Symbol symbol = identNode.getSymbol(); int scopeCallFlags = flags; method.loadCompilerConstant(SCOPE); @@ -688,8 +592,8 @@ final class CodeGenerator extends NodeOperatorVisitor { } loadArgs(args); final Type[] paramTypes = method.getTypesFromStack(args.size()); - final SharedScopeCall scopeCall = getScopeCall(symbol, identNode.getType(), callNode.getType(), paramTypes, scopeCallFlags); - scopeCall.generateInvoke(method); + final SharedScopeCall scopeCall = codegenLexicalContext.getScopeCall(unit, symbol, identNode.getType(), callNode.getType(), paramTypes, scopeCallFlags); + return scopeCall.generateInvoke(method); } private void scopeCall(final IdentNode node, final int flags) { @@ -756,7 +660,7 @@ final class CodeGenerator extends NodeOperatorVisitor { evalCall(node, flags); } else if (useCount <= SharedScopeCall.FAST_SCOPE_CALL_THRESHOLD || (!isFastScope(symbol) && useCount <= SharedScopeCall.SLOW_SCOPE_CALL_THRESHOLD) - || CodeGenerator.this.inDynamicScope()) { + || CodeGenerator.this.lc.inDynamicScope()) { scopeCall(node, flags); } else { sharedScopeCall(node, flags); @@ -845,11 +749,11 @@ final class CodeGenerator extends NodeOperatorVisitor { public boolean enterContinueNode(final ContinueNode continueNode) { lineNumber(continueNode); - final LoopNode continueTo = getLexicalContext().getContinueTo(continueNode.getLabel()); - for (int i = 0; i < getLexicalContext().getScopeNestingLevelTo(continueTo); i++) { + final LoopNode continueTo = lc.getContinueTo(continueNode.getLabel()); + for (int i = 0; i < lc.getScopeNestingLevelTo(continueTo); i++) { closeWith(); } - method.splitAwareGoto(getLexicalContext(), continueTo.getContinueLabel()); + method.splitAwareGoto(lc, continueTo.getContinueLabel()); return false; } @@ -875,90 +779,89 @@ final class CodeGenerator extends NodeOperatorVisitor { public boolean enterForNode(final ForNode forNode) { lineNumber(forNode); - final Node test = forNode.getTest(); - final Block body = forNode.getBody(); - final Node modify = forNode.getModify(); - - final Label breakLabel = forNode.getBreakLabel(); - final Label continueLabel = forNode.getContinueLabel(); - final Label loopLabel = new Label("loop"); - - Node init = forNode.getInit(); - if (forNode.isForIn()) { - final Symbol iter = forNode.getIterator(); - - // We have to evaluate the optional initializer expression - // of the iterator variable of the for-in statement. - if (init instanceof VarNode) { - init.accept(this); - init = ((VarNode)init).getName(); - } - - load(modify); - assert modify.getType().isObject(); - method.invoke(forNode.isForEach() ? ScriptRuntime.TO_VALUE_ITERATOR : ScriptRuntime.TO_PROPERTY_ITERATOR); - method.store(iter); - method._goto(continueLabel); - method.label(loopLabel); - - new Store(init) { - @Override - protected void storeNonDiscard() { - return; - } - @Override - protected void evaluate() { - method.load(iter); - method.invoke(interfaceCallNoLookup(Iterator.class, "next", Object.class)); - } - }.store(); - - body.accept(this); - - method.label(continueLabel); - method.load(iter); - method.invoke(interfaceCallNoLookup(Iterator.class, "hasNext", boolean.class)); - method.ifne(loopLabel); - method.label(breakLabel); + enterForIn(forNode); } else { - if (init != null) { - init.accept(this); - } - - final Label testLabel = new Label("test"); - - method._goto(testLabel); - method.label(loopLabel); - body.accept(this); - method.label(continueLabel); - - if (!body.isTerminal() && modify != null) { - load(modify); - } - - method.label(testLabel); - if (test != null) { - new BranchOptimizer(this, method).execute(test, loopLabel, true); - } else { - method._goto(loopLabel); - } - - method.label(breakLabel); + enterFor(forNode); } return false; } - private static int assignSlots(final Block block, final int firstSlot) { - int nextSlot = firstSlot; - for (final Symbol symbol : block.getSymbols()) { - if (symbol.hasSlot()) { - symbol.setSlot(nextSlot); - nextSlot += symbol.slotCount(); - } + private void enterFor(final ForNode forNode) { + final Node init = forNode.getInit(); + final Node test = forNode.getTest(); + final Block body = forNode.getBody(); + final Node modify = forNode.getModify(); + + if (init != null) { + init.accept(this); } - return nextSlot; + + final Label loopLabel = new Label("loop"); + final Label testLabel = new Label("test"); + + method._goto(testLabel); + method.label(loopLabel); + body.accept(this); + method.label(forNode.getContinueLabel()); + + if (!body.isTerminal() && modify != null) { + load(modify); + } + + method.label(testLabel); + if (test != null) { + new BranchOptimizer(this, method).execute(test, loopLabel, true); + } else { + method._goto(loopLabel); + } + + method.label(forNode.getBreakLabel()); + } + + private void enterForIn(final ForNode forNode) { + final Block body = forNode.getBody(); + final Node modify = forNode.getModify(); + + final Symbol iter = forNode.getIterator(); + final Label loopLabel = new Label("loop"); + + Node init = forNode.getInit(); + + // We have to evaluate the optional initializer expression + // of the iterator variable of the for-in statement. + if (init instanceof VarNode) { + init.accept(this); + init = ((VarNode)init).getName(); + } + + load(modify); + assert modify.getType().isObject(); + method.invoke(forNode.isForEach() ? ScriptRuntime.TO_VALUE_ITERATOR : ScriptRuntime.TO_PROPERTY_ITERATOR); + method.store(iter); + method._goto(forNode.getContinueLabel()); + method.label(loopLabel); + + new Store(init) { + @Override + protected void storeNonDiscard() { + return; + } + @Override + protected void evaluate() { + method.load(iter); + method.invoke(interfaceCallNoLookup(Iterator.class, "next", Object.class)); + } + }.store(); + + body.accept(this); + + method.label(forNode.getContinueLabel()); + method.load(iter); + method.invoke(interfaceCallNoLookup(Iterator.class, "hasNext", boolean.class)); + method.ifne(loopLabel); + method.label(forNode.getBreakLabel()); } /** @@ -967,24 +870,11 @@ final class CodeGenerator extends NodeOperatorVisitor { * @param block block with local vars. */ private void initLocals(final Block block) { - final boolean isFunctionBody = getLexicalContext().isFunctionBody(); + lc.nextFreeSlot(block); - final int nextFreeSlot; - if (isFunctionBody) { - // On entry to function, start with slot 0 - nextFreeSlot = 0; - } else { - // Otherwise, continue from previous block's first free slot - nextFreeSlot = nextFreeSlots[nextFreeSlotsSize - 1]; - } - if(nextFreeSlotsSize == nextFreeSlots.length) { - final int[] newNextFreeSlots = new int[nextFreeSlotsSize * 2]; - System.arraycopy(nextFreeSlots, 0, newNextFreeSlots, 0, nextFreeSlotsSize); - nextFreeSlots = newNextFreeSlots; - } - nextFreeSlots[nextFreeSlotsSize++] = assignSlots(block, nextFreeSlot); + final boolean isFunctionBody = lc.isFunctionBody(); - final FunctionNode function = getLexicalContext().getCurrentFunction(); + final FunctionNode function = lc.getCurrentFunction(); if (isFunctionBody) { /* Fix the predefined slots so they have numbers >= 0, like varargs. */ if (function.needsParentScope()) { @@ -1023,7 +913,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } if (symbol.isVar()) { - if(varsInScope || symbol.isScope()) { + if (varsInScope || symbol.isScope()) { nameList.add(symbol.getName()); newSymbols.add(symbol); values.add(null); @@ -1062,7 +952,7 @@ final class CodeGenerator extends NodeOperatorVisitor { @Override protected void loadScope(MethodEmitter m) { - if(function.needsParentScope()) { + if (function.needsParentScope()) { m.loadCompilerConstant(SCOPE); } else { m.loadNull(); @@ -1096,7 +986,7 @@ final class CodeGenerator extends NodeOperatorVisitor { private void initArguments(final FunctionNode function) { method.loadCompilerConstant(VARARGS); - if(function.needsCallee()) { + if (function.needsCallee()) { method.loadCompilerConstant(CALLEE); } else { // If function is strict mode, "arguments.callee" is not populated, so we don't necessarily need the @@ -1126,10 +1016,10 @@ final class CodeGenerator extends NodeOperatorVisitor { LOG.info("=== BEGIN ", functionNode.getName()); assert functionNode.getCompileUnit() != null : "no compile unit for " + functionNode.getName() + " " + Debug.id(functionNode); - push(functionNode.getCompileUnit()); - assert !compileUnits.isEmpty(); + unit = lc.pushCompileUnit(functionNode.getCompileUnit()); + assert lc.hasCompileUnits(); - pushMethodEmitter(unit.getClassEmitter().method(functionNode)); + method = lc.pushMethodEmitter(unit.getClassEmitter().method(functionNode)); // Mark end for variable tables. method.begin(); @@ -1140,11 +1030,11 @@ final class CodeGenerator extends NodeOperatorVisitor { public Node leaveFunctionNode(final FunctionNode functionNode) { try { method.end(); // wrap up this method - pop(functionNode.getCompileUnit()); - popMethodEmitter(method); + unit = lc.popCompileUnit(functionNode.getCompileUnit()); + method = lc.popMethodEmitter(method); LOG.info("=== END ", functionNode.getName()); - final FunctionNode newFunctionNode = functionNode.setState(getLexicalContext(), CompilationState.EMITTED); + final FunctionNode newFunctionNode = functionNode.setState(lc, CompilationState.EMITTED); newFunctionObject(newFunctionNode, functionNode); return newFunctionNode; @@ -1238,16 +1128,16 @@ final class CodeGenerator extends NodeOperatorVisitor { final MethodEmitter savedMethod = method; for (final ArrayUnit arrayUnit : units) { - push(arrayUnit.getCompileUnit()); + unit = lc.pushCompileUnit(arrayUnit.getCompileUnit()); final String className = unit.getUnitClassName(); - final String name = getLexicalContext().getCurrentFunction().uniqueName(SPLIT_PREFIX.symbolName()); + final String name = lc.getCurrentFunction().uniqueName(SPLIT_PREFIX.symbolName()); final String signature = methodDescriptor(type, Object.class, ScriptFunction.class, ScriptObject.class, type); final MethodEmitter me = unit.getClassEmitter().method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), name, signature); - pushMethodEmitter(me); + method = lc.pushMethodEmitter(me); - method.setFunctionNode(getLexicalContext().getCurrentFunction()); + method.setFunctionNode(lc.getCurrentFunction()); method.begin(); fixScopeSlot(); @@ -1260,7 +1150,7 @@ final class CodeGenerator extends NodeOperatorVisitor { method._return(); method.end(); - popMethodEmitter(me); + method = lc.popMethodEmitter(me); assert method == savedMethod; method.loadCompilerConstant(THIS); @@ -1271,7 +1161,7 @@ final class CodeGenerator extends NodeOperatorVisitor { method.swap(); method.invokestatic(className, name, signature); - pop(unit); + unit = lc.popCompileUnit(unit); } return method; @@ -1407,7 +1297,7 @@ final class CodeGenerator extends NodeOperatorVisitor { return loadRegexToken(regexToken); } // emit field - final String regexName = getLexicalContext().getCurrentFunction().uniqueName(REGEX_PREFIX.symbolName()); + final String regexName = lc.getCurrentFunction().uniqueName(REGEX_PREFIX.symbolName()); final ClassEmitter classEmitter = unit.getClassEmitter(); classEmitter.field(EnumSet.of(PRIVATE, STATIC), regexName, Object.class); @@ -1545,7 +1435,7 @@ final class CodeGenerator extends NodeOperatorVisitor { method.registerReturn(); - final Type returnType = getLexicalContext().getCurrentFunction().getReturnType(); + final Type returnType = lc.getCurrentFunction().getReturnType(); final Node expression = returnNode.getExpression(); if (expression != null) { @@ -1756,7 +1646,7 @@ final class CodeGenerator extends NodeOperatorVisitor { final CompileUnit splitCompileUnit = splitNode.getCompileUnit(); - final FunctionNode fn = getLexicalContext().getCurrentFunction(); + final FunctionNode fn = lc.getCurrentFunction(); final String className = splitCompileUnit.getUnitClassName(); final String name = splitNode.getName(); @@ -1767,7 +1657,7 @@ final class CodeGenerator extends NodeOperatorVisitor { new Class[] {ScriptFunction.class, Object.class, ScriptObject.class}; final MethodEmitter caller = method; - push(splitCompileUnit); + unit = lc.pushCompileUnit(splitCompileUnit); final Call splitCall = staticCallNoLookup( className, @@ -1781,8 +1671,7 @@ final class CodeGenerator extends NodeOperatorVisitor { rtype, ptypes); - pushMethodEmitter(splitEmitter); - + method = lc.pushMethodEmitter(splitEmitter); method.setFunctionNode(fn); if (fn.needsCallee()) { @@ -1809,7 +1698,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } private void fixScopeSlot() { - if (getLexicalContext().getCurrentFunction().compilerConstant(SCOPE).getSlot() != SCOPE.slot()) { + if (lc.getCurrentFunction().compilerConstant(SCOPE).getSlot() != SCOPE.slot()) { // TODO hack to move the scope to the expected slot (that's needed because split methods reuse the same slots as the root method) method.load(Type.typeFor(ScriptObject.class), SCOPE.slot()); method.storeCompilerConstant(SCOPE); @@ -1826,15 +1715,15 @@ final class CodeGenerator extends NodeOperatorVisitor { // Wrap up this method. method.loadCompilerConstant(RETURN); - method._return(getLexicalContext().getCurrentFunction().getReturnType()); + method._return(lc.getCurrentFunction().getReturnType()); method.end(); - pop(splitNode.getCompileUnit()); - popMethodEmitter(method); + unit = lc.popCompileUnit(splitNode.getCompileUnit()); + method = lc.popMethodEmitter(method); } catch (final Throwable t) { Context.printStackTrace(t); - final VerifyError e = new VerifyError("Code generation bug in \"" + splitNode.getName() + "\": likely stack misaligned: " + t + " " + getLexicalContext().getCurrentFunction().getSource().getName()); + final VerifyError e = new VerifyError("Code generation bug in \"" + splitNode.getName() + "\": likely stack misaligned: " + t + " " + lc.getCurrentFunction().getSource().getName()); e.initCause(t); throw e; } @@ -1862,7 +1751,7 @@ final class CodeGenerator extends NodeOperatorVisitor { //has to be zero caller.label(new Label("split_return")); method.loadCompilerConstant(RETURN); - caller._return(getLexicalContext().getCurrentFunction().getReturnType()); + caller._return(lc.getCurrentFunction().getReturnType()); caller.label(breakLabel); } else { assert !targets.isEmpty(); @@ -1879,14 +1768,14 @@ final class CodeGenerator extends NodeOperatorVisitor { caller.label(labels[i - low]); if (i == 0) { caller.loadCompilerConstant(RETURN); - caller._return(getLexicalContext().getCurrentFunction().getReturnType()); + caller._return(lc.getCurrentFunction().getReturnType()); } else { // Clear split state. caller.loadCompilerConstant(SCOPE); caller.checkcast(Scope.class); caller.load(-1); caller.invoke(Scope.SET_SPLIT_STATE); - caller.splitAwareGoto(getLexicalContext(), targets.get(i - 1)); + caller.splitAwareGoto(lc, targets.get(i - 1)); } } caller.label(breakLabel); @@ -2037,7 +1926,7 @@ final class CodeGenerator extends NodeOperatorVisitor { method._new(ECMAException.class).dup(); - final Source source = getLexicalContext().getCurrentFunction().getSource(); + final Source source = lc.getCurrentFunction().getSource(); final Node expression = throwNode.getExpression(); final int position = throwNode.position(); @@ -2088,7 +1977,7 @@ final class CodeGenerator extends NodeOperatorVisitor { //TODO this is very ugly - try not to call enter/leave methods directly //better to use the implicit lexical context scoping given by the visitor's //accept method. - getLexicalContext().push(catchBlock); + lc.push(catchBlock); enterBlock(catchBlock); final CatchNode catchNode = (CatchNode)catchBlocks.get(i).getStatements().get(0); @@ -2101,6 +1990,7 @@ final class CodeGenerator extends NodeOperatorVisitor { protected void storeNonDiscard() { return; } + @Override protected void evaluate() { if (catchNode.isSyntheticRethrow()) { @@ -2147,7 +2037,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } leaveBlock(catchBlock); - getLexicalContext().pop(catchBlock); + lc.pop(catchBlock); } method.label(skip); @@ -2244,7 +2134,7 @@ final class CodeGenerator extends NodeOperatorVisitor { final boolean hasScope = method.hasScope(); final Label tryLabel; - if(hasScope) { + if (hasScope) { tryLabel = new Label("with_try"); method.label(tryLabel); method.loadCompilerConstant(SCOPE); @@ -2255,7 +2145,7 @@ final class CodeGenerator extends NodeOperatorVisitor { load(expression); assert expression.getType().isObject() : "with expression needs to be object: " + expression; - if(hasScope) { + if (hasScope) { // Construct a WithObject if we have a scope method.invoke(ScriptRuntime.OPEN_WITH); method.storeCompilerConstant(SCOPE); @@ -2397,13 +2287,13 @@ final class CodeGenerator extends NodeOperatorVisitor { public boolean enterDISCARD(final UnaryNode unaryNode) { final Node rhs = unaryNode.rhs(); - discard.push(rhs); + lc.pushDiscard(rhs); load(rhs); - if (discard.peek() == rhs) { + if (lc.getCurrentDiscard() == rhs) { assert !rhs.isAssignment(); method.pop(); - discard.pop(); + lc.popDiscard(); } return false; @@ -2455,7 +2345,7 @@ final class CodeGenerator extends NodeOperatorVisitor { assert lhs.getType().equals(rhs.getType()) && lhs.getType().equals(type) : lhs.getType() + " != " + rhs.getType() + " != " + type + " " + new ASTWriter(lhs) + " " + new ASTWriter(rhs); load(lhs); load(rhs); - method.add(); + method.add(); //if the symbol is optimistic, it always needs to be written, not on the stack? method.store(symbol); return null; } @@ -2999,52 +2889,11 @@ final class CodeGenerator extends NodeOperatorVisitor { * Generate all shared scope calls generated during codegen. */ protected void generateScopeCalls() { - for (final SharedScopeCall scopeAccess : scopeCalls.values()) { + for (final SharedScopeCall scopeAccess : lc.getScopeCalls()) { scopeAccess.generateScopeCall(); } } - /** - * Get a shared static method representing a dynamic scope callsite. - * - * @param symbol the symbol - * @param valueType the value type of the symbol - * @param returnType the return type - * @param paramTypes the parameter types - * @param flags the callsite flags - * @return an object representing a shared scope call - */ - private SharedScopeCall getScopeCall(final Symbol symbol, final Type valueType, final Type returnType, - final Type[] paramTypes, final int flags) { - - final SharedScopeCall scopeCall = new SharedScopeCall(symbol, valueType, returnType, paramTypes, flags); - if (scopeCalls.containsKey(scopeCall)) { - return scopeCalls.get(scopeCall); - } - scopeCall.setClassAndName(unit, getLexicalContext().getCurrentFunction().uniqueName("scopeCall")); - scopeCalls.put(scopeCall, scopeCall); - return scopeCall; - } - - /** - * Get a shared static method representing a dynamic scope get access. - * - * @param type the type of the variable - * @param symbol the symbol - * @param flags the callsite flags - * @return an object representing a shared scope call - */ - private SharedScopeCall getScopeGet(final Type type, final Symbol symbol, final int flags) { - - final SharedScopeCall scopeCall = new SharedScopeCall(symbol, type, type, null, flags); - if (scopeCalls.containsKey(scopeCall)) { - return scopeCalls.get(scopeCall); - } - scopeCall.setClassAndName(unit, getLexicalContext().getCurrentFunction().uniqueName("scopeCall")); - scopeCalls.put(scopeCall, scopeCall); - return scopeCall; - } - /** * Debug code used to print symbols * @@ -3139,14 +2988,14 @@ final class CodeGenerator extends NodeOperatorVisitor { private void prologue() { final Symbol targetSymbol = target.getSymbol(); - final Symbol scopeSymbol = getLexicalContext().getCurrentFunction().compilerConstant(SCOPE); + final Symbol scopeSymbol = lc.getCurrentFunction().compilerConstant(SCOPE); /** * This loads the parts of the target, e.g base and index. they are kept * on the stack throughout the store and used at the end to execute it */ - target.accept(new NodeVisitor() { + target.accept(new NodeVisitor(new LexicalContext()) { @Override public boolean enterIdentNode(final IdentNode node) { if (targetSymbol.isScope()) { @@ -3213,22 +3062,21 @@ final class CodeGenerator extends NodeOperatorVisitor { * @return the quick symbol */ private Symbol quickSymbol(final Type type, final String prefix) { - final String name = getLexicalContext().getCurrentFunction().uniqueName(prefix); + final String name = lc.getCurrentFunction().uniqueName(prefix); final Symbol symbol = new Symbol(name, IS_TEMP | IS_INTERNAL); symbol.setType(type); - final int quickSlot = nextFreeSlots[nextFreeSlotsSize - 1]; - nextFreeSlots[nextFreeSlotsSize - 1] = quickSlot + symbol.slotCount(); - symbol.setSlot(quickSlot); + + symbol.setSlot(lc.quickSlot(symbol)); return symbol; } // store the result that "lives on" after the op, e.g. "i" in i++ postfix. protected void storeNonDiscard() { - if (discard.peek() == assignNode) { + if (lc.getCurrentDiscard() == assignNode) { assert assignNode.isAssignment(); - discard.pop(); + lc.popDiscard(); return; } @@ -3256,7 +3104,7 @@ final class CodeGenerator extends NodeOperatorVisitor { */ method.convert(target.getType()); - target.accept(new NodeVisitor() { + target.accept(new NodeVisitor(new LexicalContext()) { @Override protected boolean enterDefault(Node node) { throw new AssertionError("Unexpected node " + node + " in store epilogue"); @@ -3318,7 +3166,6 @@ final class CodeGenerator extends NodeOperatorVisitor { } private void newFunctionObject(final FunctionNode functionNode, final FunctionNode originalFunctionNode) { - final LexicalContext lc = getLexicalContext(); assert lc.peek() == functionNode; // We don't emit a ScriptFunction on stack for: // 1. the outermost compiled function (as there's no code being generated in its outer context that'd need it diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java new file mode 100644 index 00000000000..d27bdd953ec --- /dev/null +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2010, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.nashorn.internal.codegen; + +import java.util.ArrayDeque; +import java.util.Collection; +import java.util.Collections; +import java.util.Deque; +import java.util.HashMap; +import java.util.Map; + +import jdk.nashorn.internal.codegen.types.Type; +import jdk.nashorn.internal.ir.Block; +import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.LexicalContext; +import jdk.nashorn.internal.ir.LexicalContextNode; +import jdk.nashorn.internal.ir.Node; +import jdk.nashorn.internal.ir.Symbol; +import jdk.nashorn.internal.ir.WithNode; + +/** + * A lexical context that also tracks if we have any dynamic scopes in the context. Such scopes can have new + * variables introduced into them at run time - a with block or a function directly containing an eval call. + * Furthermore, this class keeps track of current discard state, which the current method emitter being used is, + * the current compile unit, and local variable indexes + */ +final class CodeGeneratorLexicalContext extends LexicalContext { + private int dynamicScopeCount; + + /** Map of shared scope call sites */ + private final Map scopeCalls = new HashMap<>(); + + /** Compile unit stack - every time we start a sub method (e.g. a split) we push one */ + private final Deque compileUnits = new ArrayDeque<>(); + + /** Method emitter stack - every time we start a sub method (e.g. a split) we push one */ + private final Deque methodEmitters = new ArrayDeque<>(); + + /** The discard stack - whenever we enter a discard node we keep track of its return value status - + * i.e. should we keep it or throw it away */ + private final Deque discard = new ArrayDeque<>(); + + /** A stack tracking the next free local variable slot in the blocks. There's one entry for every block + * currently on the lexical context stack. */ + private int[] nextFreeSlots = new int[16]; + + /** size of next free slot vector */ + private int nextFreeSlotsSize; + + @Override + public T push(final T node) { + if (isDynamicScopeBoundary(node)) { + ++dynamicScopeCount; + } + return super.push(node); + } + + @Override + public T pop(final T node) { + final T popped = super.pop(node); + if (isDynamicScopeBoundary(popped)) { + --dynamicScopeCount; + } + if (node instanceof Block) { + --nextFreeSlotsSize; + } + return popped; + } + + private boolean isDynamicScopeBoundary(final LexicalContextNode node) { + if (node instanceof Block) { + // Block's immediate parent is a with node. Note we aren't testing for a WithNode, as that'd capture + // processing of WithNode.expression too, but it should be unaffected. + return !isEmpty() && peek() instanceof WithNode; + } else if (node instanceof FunctionNode) { + // Function has a direct eval in it (so a top-level "var ..." in the eval code can introduce a new + // variable into the function's scope), and it isn't strict (as evals in strict functions get an + // isolated scope). + return isFunctionDynamicScope((FunctionNode)node); + } + return false; + } + + boolean inDynamicScope() { + return dynamicScopeCount > 0; + } + + static boolean isFunctionDynamicScope(FunctionNode fn) { + return fn.hasEval() && !fn.isStrict(); + } + + MethodEmitter pushMethodEmitter(final MethodEmitter newMethod) { + methodEmitters.push(newMethod); + return newMethod; + } + + MethodEmitter popMethodEmitter(final MethodEmitter oldMethod) { + assert methodEmitters.peek() == oldMethod; + methodEmitters.pop(); + return methodEmitters.isEmpty() ? null : methodEmitters.peek(); + } + + CompileUnit pushCompileUnit(final CompileUnit newUnit) { + compileUnits.push(newUnit); + return newUnit; + } + + CompileUnit popCompileUnit(final CompileUnit oldUnit) { + assert compileUnits.peek() == oldUnit; + compileUnits.pop(); + return compileUnits.isEmpty() ? null : compileUnits.peek(); + } + + boolean hasCompileUnits() { + return !compileUnits.isEmpty(); + } + + Collection getScopeCalls() { + return Collections.unmodifiableCollection(scopeCalls.values()); + } + + /** + * Get a shared static method representing a dynamic scope callsite. + * + * @param unit current compile unit + * @param symbol the symbol + * @param valueType the value type of the symbol + * @param returnType the return type + * @param paramTypes the parameter types + * @param flags the callsite flags + * @return an object representing a shared scope call + */ + SharedScopeCall getScopeCall(final CompileUnit unit, final Symbol symbol, final Type valueType, final Type returnType, final Type[] paramTypes, final int flags) { + final SharedScopeCall scopeCall = new SharedScopeCall(symbol, valueType, returnType, paramTypes, flags); + if (scopeCalls.containsKey(scopeCall)) { + return scopeCalls.get(scopeCall); + } + scopeCall.setClassAndName(unit, getCurrentFunction().uniqueName("scopeCall")); + scopeCalls.put(scopeCall, scopeCall); + return scopeCall; + } + + /** + * Get a shared static method representing a dynamic scope get access. + * + * @param unit current compile unit + * @param type the type of the variable + * @param symbol the symbol + * @param flags the callsite flags + * @return an object representing a shared scope call + */ + SharedScopeCall getScopeGet(final CompileUnit unit, final Type type, final Symbol symbol, final int flags) { + final SharedScopeCall scopeCall = new SharedScopeCall(symbol, type, type, null, flags); + if (scopeCalls.containsKey(scopeCall)) { + return scopeCalls.get(scopeCall); + } + scopeCall.setClassAndName(unit, getCurrentFunction().uniqueName("scopeCall")); + scopeCalls.put(scopeCall, scopeCall); + return scopeCall; + } + + + void nextFreeSlot(final Block block) { + final boolean isFunctionBody = isFunctionBody(); + + final int nextFreeSlot; + if (isFunctionBody) { + // On entry to function, start with slot 0 + nextFreeSlot = 0; + } else { + // Otherwise, continue from previous block's first free slot + nextFreeSlot = nextFreeSlots[nextFreeSlotsSize - 1]; + } + if (nextFreeSlotsSize == nextFreeSlots.length) { + final int[] newNextFreeSlots = new int[nextFreeSlotsSize * 2]; + System.arraycopy(nextFreeSlots, 0, newNextFreeSlots, 0, nextFreeSlotsSize); + nextFreeSlots = newNextFreeSlots; + } + nextFreeSlots[nextFreeSlotsSize++] = assignSlots(block, nextFreeSlot); + } + + private static int assignSlots(final Block block, final int firstSlot) { + int nextSlot = firstSlot; + for (final Symbol symbol : block.getSymbols()) { + if (symbol.hasSlot()) { + symbol.setSlot(nextSlot); + nextSlot += symbol.slotCount(); + } + } + return nextSlot; + } + + void pushDiscard(final Node node) { + discard.push(node); + } + + Node popDiscard() { + return discard.pop(); + } + + Node getCurrentDiscard() { + return discard.peek(); + } + + int quickSlot(final Symbol symbol) { + final int quickSlot = nextFreeSlots[nextFreeSlotsSize - 1]; + nextFreeSlots[nextFreeSlotsSize - 1] = quickSlot + symbol.slotCount(); + return quickSlot; + } + +} + diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java b/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java index f2603393612..9f263067c80 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java @@ -24,15 +24,14 @@ import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.Block; import jdk.nashorn.internal.ir.CallNode; import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.ReturnNode; import jdk.nashorn.internal.ir.Symbol; import jdk.nashorn.internal.ir.FunctionNode.CompilationState; -import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.TemporarySymbols; import jdk.nashorn.internal.ir.debug.ASTWriter; import jdk.nashorn.internal.ir.debug.PrintVisitor; -import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.runtime.ECMAErrors; import jdk.nashorn.internal.runtime.ScriptEnvironment; @@ -74,7 +73,7 @@ enum CompilationPhase { FunctionNode newFunctionNode = outermostFunctionNode; - newFunctionNode = (FunctionNode)newFunctionNode.accept(new NodeVisitor() { + newFunctionNode = (FunctionNode)newFunctionNode.accept(new NodeVisitor(new LexicalContext()) { // self references are done with invokestatic and thus cannot // have trampolines - never lazy @Override @@ -107,10 +106,9 @@ enum CompilationPhase { lazy.remove(node); } - newFunctionNode = (FunctionNode)newFunctionNode.accept(new NodeOperatorVisitor() { + newFunctionNode = (FunctionNode)newFunctionNode.accept(new NodeVisitor(new LexicalContext()) { @Override public Node leaveFunctionNode(final FunctionNode functionNode) { - final LexicalContext lc = getLexicalContext(); if (lazy.contains(functionNode)) { Compiler.LOG.fine( "Marking ", @@ -194,12 +192,11 @@ enum CompilationPhase { * @param functionNode node where to start iterating */ private FunctionNode enterAttr(final FunctionNode functionNode, final TemporarySymbols ts) { - return (FunctionNode)functionNode.accept(new NodeVisitor() { + return (FunctionNode)functionNode.accept(new NodeVisitor(new LexicalContext()) { @Override public Node leaveFunctionNode(final FunctionNode node) { - final LexicalContext lc = getLexicalContext(); if (node.isLazy()) { - FunctionNode newNode = node.setReturnType(getLexicalContext(), Type.OBJECT); + FunctionNode newNode = node.setReturnType(lc, Type.OBJECT); return ts.ensureSymbol(lc, Type.OBJECT, newNode); } //node may have a reference here that needs to be nulled if it was referred to by @@ -230,7 +227,7 @@ enum CompilationPhase { FunctionNode newFunctionNode = (FunctionNode)fn.accept(new RangeAnalyzer()); final List returns = new ArrayList<>(); - newFunctionNode = (FunctionNode)newFunctionNode.accept(new NodeVisitor() { + newFunctionNode = (FunctionNode)newFunctionNode.accept(new NodeVisitor(new LexicalContext()) { private final Deque> returnStack = new ArrayDeque<>(); @Override @@ -249,7 +246,7 @@ enum CompilationPhase { } returnType = Type.widest(returnType, ret.getExpression().getType()); } - return functionNode.setReturnType(getLexicalContext(), returnType); + return functionNode.setReturnType(lc, returnType); } @Override @@ -270,8 +267,8 @@ enum CompilationPhase { } final Type rangeType = range.getType(); if (!Type.areEquivalent(symbolType, rangeType) && Type.widest(symbolType, rangeType) == symbolType) { //we can narrow range - RangeAnalyzer.LOG.info("[", getLexicalContext().getCurrentFunction().getName(), "] ", symbol, " can be ", range.getType(), " ", symbol.getRange()); - return node.setSymbol(getLexicalContext(), symbol.setTypeOverrideShared(range.getType(), compiler.getTemporarySymbols())); + RangeAnalyzer.LOG.info("[", lc.getCurrentFunction().getName(), "] ", symbol, " can be ", range.getType(), " ", symbol.getRange()); + return node.setSymbol(lc, symbol.setTypeOverrideShared(range.getType(), compiler.getTemporarySymbols())); } } return node; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java b/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java index 6f7a51f43c2..f9d643228e8 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java @@ -31,6 +31,7 @@ import static jdk.nashorn.internal.codegen.CompilerConstants.SCOPE; import java.util.ArrayList; import java.util.HashSet; import java.util.List; + import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.AccessNode; import jdk.nashorn.internal.ir.Assignment; @@ -84,13 +85,14 @@ import jdk.nashorn.internal.runtime.JSType; * and frame optimizations */ -final class FinalizeTypes extends NodeOperatorVisitor { +final class FinalizeTypes extends NodeOperatorVisitor { private static final DebugLogger LOG = new DebugLogger("finalize"); private final TemporarySymbols temporarySymbols; FinalizeTypes(final TemporarySymbols temporarySymbols) { + super(new LexicalContext()); this.temporarySymbols = temporarySymbols; } @@ -233,7 +235,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { private boolean symbolIsInteger(Node node) { final Symbol symbol = node.getSymbol(); - assert symbol != null && symbol.getSymbolType().isInteger() : "int coercion expected: " + Debug.id(symbol) + " " + symbol + " " + getLexicalContext().getCurrentFunction().getSource(); + assert symbol != null && symbol.getSymbolType().isInteger() : "int coercion expected: " + Debug.id(symbol) + " " + symbol + " " + lc.getCurrentFunction().getSource(); return true; } @@ -382,12 +384,10 @@ final class FinalizeTypes extends NodeOperatorVisitor { final Node test = forNode.getTest(); final Node modify = forNode.getModify(); - final LexicalContext lc = getLexicalContext(); - if (forNode.isForIn()) { return forNode.setModify(lc, convert(forNode.getModify(), Type.OBJECT)); // NASHORN-400 } - assert test != null || forNode.hasGoto() : "forNode " + forNode + " needs goto and is missing it in " + getLexicalContext().getCurrentFunction(); + assert test != null || forNode.hasGoto() : "forNode " + forNode + " needs goto and is missing it in " + lc.getCurrentFunction(); return forNode. setInit(lc, init == null ? null : discard(init)). @@ -419,7 +419,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { @Override public Node leaveFunctionNode(final FunctionNode functionNode) { - return functionNode.setState(getLexicalContext(), CompilationState.FINALIZED); + return functionNode.setState(lc, CompilationState.FINALIZED); } @Override @@ -450,7 +450,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { public Node leaveReturnNode(final ReturnNode returnNode) { final Node expr = returnNode.getExpression(); if (expr != null) { - return returnNode.setExpression(convert(expr, getLexicalContext().getCurrentFunction().getReturnType())); + return returnNode.setExpression(convert(expr, lc.getCurrentFunction().getReturnType())); } return returnNode; } @@ -482,8 +482,8 @@ final class FinalizeTypes extends NodeOperatorVisitor { } return switchNode. - setExpression(getLexicalContext(), convert(expression, Type.OBJECT)). - setCases(getLexicalContext(), newCases); + setExpression(lc, convert(expression, Type.OBJECT)). + setCases(lc, newCases); } @Override @@ -519,14 +519,14 @@ final class FinalizeTypes extends NodeOperatorVisitor { public Node leaveWhileNode(final WhileNode whileNode) { final Node test = whileNode.getTest(); if (test != null) { - return whileNode.setTest(getLexicalContext(), convert(test, Type.BOOLEAN)); + return whileNode.setTest(lc, convert(test, Type.BOOLEAN)); } return whileNode; } @Override public Node leaveWithNode(final WithNode withNode) { - return withNode.setExpression(getLexicalContext(), convert(withNode.getExpression(), Type.OBJECT)); + return withNode.setExpression(lc, convert(withNode.getExpression(), Type.OBJECT)); } private static void updateSymbolsLog(final FunctionNode functionNode, final Symbol symbol, final boolean loseSlot) { @@ -550,7 +550,6 @@ final class FinalizeTypes extends NodeOperatorVisitor { return; // nothing to do } - final LexicalContext lc = getLexicalContext(); final FunctionNode functionNode = lc.getFunction(block); final boolean allVarsInScope = functionNode.allVarsInScope(); final boolean isVarArg = functionNode.isVarArg(); @@ -652,7 +651,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { private static void setCanBePrimitive(final Node node, final Type to) { final HashSet exclude = new HashSet<>(); - node.accept(new NodeVisitor() { + node.accept(new NodeVisitor(new LexicalContext()) { private void setCanBePrimitive(final Symbol symbol) { LOG.info("*** can be primitive symbol ", symbol, " ", Debug.id(symbol)); symbol.setCanBePrimitive(to); @@ -762,7 +761,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { } } LOG.info("Type override for lhs in '", node, "' => ", to); - return ((TypeOverride)node).setType(temporarySymbols, getLexicalContext(), to); + return ((TypeOverride)node).setType(temporarySymbols, lc, to); } /** @@ -785,8 +784,8 @@ final class FinalizeTypes extends NodeOperatorVisitor { private Node convert(final Node node, final Type to) { assert !to.isUnknown() : "unknown type for " + node + " class=" + node.getClass(); assert node != null : "node is null"; - assert node.getSymbol() != null : "node " + node + " " + node.getClass() + " has no symbol! " + getLexicalContext().getCurrentFunction(); - assert node.tokenType() != TokenType.CONVERT : "assert convert in convert " + node + " in " + getLexicalContext().getCurrentFunction(); + assert node.getSymbol() != null : "node " + node + " " + node.getClass() + " has no symbol! " + lc.getCurrentFunction(); + assert node.tokenType() != TokenType.CONVERT : "assert convert in convert " + node + " in " + lc.getCurrentFunction(); final Type from = node.getType(); @@ -817,7 +816,6 @@ final class FinalizeTypes extends NodeOperatorVisitor { assert !node.isTerminal(); - final LexicalContext lc = getLexicalContext(); //This is the only place in this file that can create new temporaries //FinalizeTypes may not introduce ANY node that is not a conversion. return temporarySymbols.ensureSymbol(lc, to, resultNode); @@ -854,7 +852,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { symbol = symbol.setTypeOverrideShared(to, temporarySymbols); LOG.info("Type override for temporary in '", node, "' => ", to); } - return node.setSymbol(getLexicalContext(), symbol); + return node.setSymbol(lc, symbol); } /** @@ -907,7 +905,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { if (literalNode != null) { //inherit literal symbol for attr. - literalNode = (LiteralNode)literalNode.setSymbol(getLexicalContext(), parent.getSymbol()); + literalNode = (LiteralNode)literalNode.setSymbol(lc, parent.getSymbol()); } return literalNode; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java index 321eaebe5fc..2331cf7570d 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java @@ -33,6 +33,7 @@ import jdk.nashorn.internal.ir.ExecuteNode; import jdk.nashorn.internal.ir.FunctionNode; import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.IfNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; import jdk.nashorn.internal.ir.Node; @@ -46,11 +47,12 @@ import jdk.nashorn.internal.runtime.ScriptRuntime; /** * Simple constant folding pass, executed before IR is starting to be lowered. */ -final class FoldConstants extends NodeVisitor { +final class FoldConstants extends NodeVisitor { private static final DebugLogger LOG = new DebugLogger("fold"); FoldConstants() { + super(new LexicalContext()); } @Override @@ -80,7 +82,7 @@ final class FoldConstants extends NodeVisitor { @Override public Node leaveFunctionNode(final FunctionNode functionNode) { - return functionNode.setState(getLexicalContext(), CompilationState.CONSTANT_FOLDED); + return functionNode.setState(lc, CompilationState.CONSTANT_FOLDED); } @Override diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java index a7089674d82..2747560a6e7 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java @@ -80,7 +80,7 @@ import jdk.nashorn.internal.runtime.Source; * finalized. */ -final class Lower extends NodeOperatorVisitor { +final class Lower extends NodeOperatorVisitor { private static final DebugLogger LOG = new DebugLogger("lower"); @@ -105,7 +105,7 @@ final class Lower extends NodeOperatorVisitor { terminated = true; } } else { - statement.accept(new NodeVisitor() { + statement.accept(new NodeVisitor(new LexicalContext()) { @Override public boolean enterVarNode(final VarNode varNode) { newStatements.add(varNode.setInit(null)); @@ -121,7 +121,6 @@ final class Lower extends NodeOperatorVisitor { @Override public boolean enterBlock(final Block block) { - final LexicalContext lc = getLexicalContext(); final FunctionNode function = lc.getCurrentFunction(); if (lc.isFunctionBody() && function.isProgram() && !function.hasDeclaredFunctions()) { new ExecuteNode(block.getLineNumber(), block.getToken(), block.getFinish(), LiteralNode.newInstance(block, ScriptRuntime.UNDEFINED)).accept(this); @@ -134,12 +133,10 @@ final class Lower extends NodeOperatorVisitor { //now we have committed the entire statement list to the block, but we need to truncate //whatever is after the last terminal. block append won't append past it - final BlockLexicalContext lc = (BlockLexicalContext)getLexicalContext(); - Statement last = lc.getLastStatement(); if (lc.isFunctionBody()) { - final FunctionNode currentFunction = getLexicalContext().getCurrentFunction(); + final FunctionNode currentFunction = lc.getCurrentFunction(); final boolean isProgram = currentFunction.isProgram(); final ReturnNode returnNode = new ReturnNode( last == null ? block.getLineNumber() : last.getLineNumber(), //TODO? @@ -191,7 +188,7 @@ final class Lower extends NodeOperatorVisitor { final Node expr = executeNode.getExpression(); ExecuteNode node = executeNode; - final FunctionNode currentFunction = getLexicalContext().getCurrentFunction(); + final FunctionNode currentFunction = lc.getCurrentFunction(); if (currentFunction.isProgram()) { if (!(expr instanceof Block) || expr instanceof FunctionNode) { // it's not a block, but can be a function @@ -216,7 +213,7 @@ final class Lower extends NodeOperatorVisitor { final Node test = forNode.getTest(); if (!forNode.isForIn() && conservativeAlwaysTrue(test)) { - newForNode = forNode.setTest(getLexicalContext(), null); + newForNode = forNode.setTest(lc, null); } return addStatement(checkEscape(newForNode)); @@ -230,7 +227,7 @@ final class Lower extends NodeOperatorVisitor { @Override public Node leaveFunctionNode(final FunctionNode functionNode) { LOG.info("END FunctionNode: ", functionNode.getName()); - return functionNode.setState(getLexicalContext(), CompilationState.LOWERED); + return functionNode.setState(lc, CompilationState.LOWERED); } @Override @@ -262,16 +259,16 @@ final class Lower extends NodeOperatorVisitor { } private static Node ensureUniqueNamesIn(final LexicalContext lc, final Node node) { - return node.accept(new NodeVisitor() { + return node.accept(new NodeVisitor(new LexicalContext()) { @Override public Node leaveFunctionNode(final FunctionNode functionNode) { final String name = functionNode.getName(); - return functionNode.setName(getLexicalContext(), lc.getCurrentFunction().uniqueName(name)); + return functionNode.setName(lc, lc.getCurrentFunction().uniqueName(name)); } @Override public Node leaveDefault(final Node labelledNode) { - return labelledNode.ensureUniqueLabels(getLexicalContext()); + return labelledNode.ensureUniqueLabels(lc); } }); } @@ -292,10 +289,10 @@ final class Lower extends NodeOperatorVisitor { final long token = tryNode.getToken(); final int finish = tryNode.getFinish(); - final IdentNode exception = new IdentNode(token, finish, getLexicalContext().getCurrentFunction().uniqueName("catch_all")); + final IdentNode exception = new IdentNode(token, finish, lc.getCurrentFunction().uniqueName("catch_all")); final Block catchBody = new Block(lineNumber, token, finish, new ThrowNode(lineNumber, token, finish, new IdentNode(exception), ThrowNode.IS_SYNTHETIC_RETHROW)). - setIsTerminal(getLexicalContext(), true); //ends with throw, so terminal + setIsTerminal(lc, true); //ends with throw, so terminal final CatchNode catchAllNode = new CatchNode(lineNumber, token, finish, new IdentNode(exception), null, catchBody, CatchNode.IS_SYNTHETIC_RETHROW); final Block catchAllBlock = new Block(lineNumber, token, finish, catchAllNode); @@ -306,7 +303,7 @@ final class Lower extends NodeOperatorVisitor { } private IdentNode compilerConstant(final CompilerConstants cc) { - final FunctionNode functionNode = getLexicalContext().getCurrentFunction(); + final FunctionNode functionNode = lc.getCurrentFunction(); return new IdentNode(functionNode.getToken(), functionNode.getFinish(), cc.symbolName()); } @@ -324,9 +321,8 @@ final class Lower extends NodeOperatorVisitor { private Node spliceFinally(final TryNode tryNode, final List rethrows, final Block finallyBody) { assert tryNode.getFinallyBody() == null; final int finish = tryNode.getFinish(); - final LexicalContext lc = getLexicalContext(); - final TryNode newTryNode = (TryNode)tryNode.accept(new NodeVisitor() { + final TryNode newTryNode = (TryNode)tryNode.accept(new NodeVisitor(new LexicalContext()) { final List insideTry = new ArrayList<>(); @Override @@ -355,12 +351,12 @@ final class Lower extends NodeOperatorVisitor { @Override public Node leaveBreakNode(final BreakNode breakNode) { - return copy(breakNode, Lower.this.getLexicalContext().getBreakable(breakNode.getLabel())); + return copy(breakNode, Lower.this.lc.getBreakable(breakNode.getLabel())); } @Override public Node leaveContinueNode(final ContinueNode continueNode) { - return copy(continueNode, Lower.this.getLexicalContext().getContinueTo(continueNode.getLabel())); + return copy(continueNode, Lower.this.lc.getContinueTo(continueNode.getLabel())); } @Override @@ -383,7 +379,7 @@ final class Lower extends NodeOperatorVisitor { newStatements.add(expr == null ? returnNode : returnNode.setExpression(resultNode)); } - return new ExecuteNode(returnNode.getLineNumber(), returnNode.getToken(), returnNode.getFinish(), new Block(returnNode.getLineNumber(), returnNode.getToken(), getLexicalContext().getCurrentBlock().getFinish(), newStatements)); + return new ExecuteNode(returnNode.getLineNumber(), returnNode.getToken(), returnNode.getFinish(), new Block(returnNode.getLineNumber(), returnNode.getToken(), lc.getCurrentBlock().getFinish(), newStatements)); } private Node copy(final Statement endpoint, final Node targetNode) { @@ -442,7 +438,7 @@ final class Lower extends NodeOperatorVisitor { final Block catchAll = catchAllBlock(tryNode); final List rethrows = new ArrayList<>(); - catchAll.accept(new NodeVisitor() { + catchAll.accept(new NodeVisitor(new LexicalContext()) { @Override public boolean enterThrowNode(final ThrowNode throwNode) { rethrows.add(throwNode); @@ -470,7 +466,7 @@ final class Lower extends NodeOperatorVisitor { @Override public Node leaveVarNode(final VarNode varNode) { addStatement(varNode); - if (varNode.getFlag(VarNode.IS_LAST_FUNCTION_DECLARATION) && getLexicalContext().getCurrentFunction().isProgram()) { + if (varNode.getFlag(VarNode.IS_LAST_FUNCTION_DECLARATION) && lc.getCurrentFunction().isProgram()) { new ExecuteNode(varNode.getLineNumber(), varNode.getToken(), varNode.getFinish(), new IdentNode(varNode.getName())).accept(this); } return varNode; @@ -484,7 +480,7 @@ final class Lower extends NodeOperatorVisitor { if (conservativeAlwaysTrue(test)) { //turn it into a for node without a test. final ForNode forNode = (ForNode)new ForNode(whileNode.getLineNumber(), whileNode.getToken(), whileNode.getFinish(), null, null, body, null, ForNode.IS_FOR).accept(this); - getLexicalContext().replace(whileNode, forNode); + lc.replace(whileNode, forNode); return forNode; } @@ -519,7 +515,7 @@ final class Lower extends NodeOperatorVisitor { * @return eval location */ private String evalLocation(final IdentNode node) { - final Source source = getLexicalContext().getCurrentFunction().getSource(); + final Source source = lc.getCurrentFunction().getSource(); return new StringBuilder(). append(source.getName()). append('#'). @@ -551,10 +547,10 @@ final class Lower extends NodeOperatorVisitor { // 'eval' call with at least one argument if (args.size() >= 1 && EVAL.symbolName().equals(callee.getName())) { - final FunctionNode currentFunction = getLexicalContext().getCurrentFunction(); + final FunctionNode currentFunction = lc.getCurrentFunction(); return callNode.setEvalArgs( new CallNode.EvalArgs( - ensureUniqueNamesIn(getLexicalContext(), args.get(0)).accept(this), + ensureUniqueNamesIn(lc, args.get(0)).accept(this), compilerConstant(THIS), evalLocation(callee), currentFunction.isStrict())); @@ -580,7 +576,7 @@ final class Lower extends NodeOperatorVisitor { private static boolean controlFlowEscapes(final LexicalContext lex, final Block loopBody) { final List escapes = new ArrayList<>(); - loopBody.accept(new NodeVisitor() { + loopBody.accept(new NodeVisitor(new LexicalContext()) { @Override public Node leaveBreakNode(final BreakNode node) { escapes.add(node); @@ -601,7 +597,6 @@ final class Lower extends NodeOperatorVisitor { } private LoopNode checkEscape(final LoopNode loopNode) { - final LexicalContext lc = getLexicalContext(); final boolean escapes = controlFlowEscapes(lc, loopNode.getBody()); if (escapes) { return loopNode. @@ -613,7 +608,7 @@ final class Lower extends NodeOperatorVisitor { private Node addStatement(final Statement statement) { - ((BlockLexicalContext)getLexicalContext()).appendStatement(statement); + lc.appendStatement(statement); return statement; } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/RangeAnalyzer.java b/nashorn/src/jdk/nashorn/internal/codegen/RangeAnalyzer.java index 1229caa1fea..ab61d374818 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/RangeAnalyzer.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/RangeAnalyzer.java @@ -35,6 +35,7 @@ import jdk.nashorn.internal.ir.Assignment; import jdk.nashorn.internal.ir.BinaryNode; import jdk.nashorn.internal.ir.ForNode; import jdk.nashorn.internal.ir.IdentNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; import jdk.nashorn.internal.ir.LoopNode; @@ -61,7 +62,7 @@ import jdk.nashorn.internal.runtime.DebugLogger; * * Proves that the multiplication never exceeds 24 bits and can thus be an int */ -final class RangeAnalyzer extends NodeOperatorVisitor { +final class RangeAnalyzer extends NodeOperatorVisitor { static final DebugLogger LOG = new DebugLogger("ranges"); private static final Range.Functionality RANGE = new Range.Functionality(LOG); @@ -69,6 +70,7 @@ final class RangeAnalyzer extends NodeOperatorVisitor { private final Map loopCounters = new HashMap<>(); RangeAnalyzer() { + super(new LexicalContext()); } @Override @@ -96,7 +98,7 @@ final class RangeAnalyzer extends NodeOperatorVisitor { final Range symRange = RANGE.join(symbol.getRange(), range); //anything assigned in the loop, not being the safe loop counter(s) invalidates its entire range - if (getLexicalContext().inLoop() && !isLoopCounter(getLexicalContext().getCurrentLoop(), symbol)) { + if (lc.inLoop() && !isLoopCounter(lc.getCurrentLoop(), symbol)) { symbol.setRange(Range.createGenericRange()); return symbol; } @@ -399,7 +401,7 @@ final class RangeAnalyzer extends NodeOperatorVisitor { final HashSet skip = new HashSet<>(); final HashSet assignmentsInLoop = new HashSet<>(); - loopNode.accept(new NodeVisitor() { + loopNode.accept(new NodeVisitor(new LexicalContext()) { private boolean assigns(final Node node, final Symbol s) { return node.isAssignment() && ((Assignment)node).getAssignmentDest().getSymbol() == s; } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/SharedScopeCall.java b/nashorn/src/jdk/nashorn/internal/codegen/SharedScopeCall.java index 588e2f4878e..c7dfb40a964 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/SharedScopeCall.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/SharedScopeCall.java @@ -116,9 +116,10 @@ class SharedScopeCall { /** * Generate the invoke instruction for this shared scope call. * @param method the method emitter + * @return the method emitter */ - public void generateInvoke(final MethodEmitter method) { - method.invokestatic(compileUnit.getUnitClassName(), methodName, getStaticSignature()); + public MethodEmitter generateInvoke(final MethodEmitter method) { + return method.invokestatic(compileUnit.getUnitClassName(), methodName, getStaticSignature()); } /** diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java b/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java index f18f686e3e7..e724ce261c3 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java @@ -49,12 +49,12 @@ import jdk.nashorn.internal.runtime.options.Options; /** * Split the IR into smaller compile units. */ -final class Splitter extends NodeVisitor { +final class Splitter extends NodeVisitor { /** Current compiler. */ private final Compiler compiler; /** IR to be broken down. */ - private FunctionNode outermost; + private final FunctionNode outermost; /** Compile unit for the main script. */ private final CompileUnit outermostCompileUnit; @@ -75,6 +75,7 @@ final class Splitter extends NodeVisitor { * @param outermostCompileUnit compile unit for outermost function, if non-lazy this is the script's compile unit */ public Splitter(final Compiler compiler, final FunctionNode functionNode, final CompileUnit outermostCompileUnit) { + super(new LexicalContext()); this.compiler = compiler; this.outermost = functionNode; this.outermostCompileUnit = outermostCompileUnit; @@ -93,8 +94,6 @@ final class Splitter extends NodeVisitor { LOG.finest("Initiating split of '", functionNode.getName(), "'"); - final LexicalContext lc = getLexicalContext(); - long weight = WeighNodes.weigh(functionNode); final boolean top = fn.isProgram(); //compiler.getFunctionNode() == outermost; @@ -127,7 +126,7 @@ final class Splitter extends NodeVisitor { final Block body = functionNode.getBody(); final List dc = directChildren(functionNode); - final Block newBody = (Block)body.accept(new NodeVisitor() { + final Block newBody = (Block)body.accept(new NodeVisitor(new LexicalContext()) { @Override public boolean enterFunctionNode(final FunctionNode nestedFunction) { return dc.contains(nestedFunction); @@ -136,7 +135,7 @@ final class Splitter extends NodeVisitor { @Override public Node leaveFunctionNode(final FunctionNode nestedFunction) { FunctionNode split = new Splitter(compiler, nestedFunction, outermostCompileUnit).split(nestedFunction); - getLexicalContext().replace(nestedFunction, split); + lc.replace(nestedFunction, split); return split; } }); @@ -149,13 +148,13 @@ final class Splitter extends NodeVisitor { private static List directChildren(final FunctionNode functionNode) { final List dc = new ArrayList<>(); - functionNode.accept(new NodeVisitor() { + functionNode.accept(new NodeVisitor(new LexicalContext()) { @Override public boolean enterFunctionNode(final FunctionNode child) { if (child == functionNode) { return true; } - if (getLexicalContext().getParentFunction(child) == functionNode) { + if (lc.getParentFunction(child) == functionNode) { dc.add(child); } return false; @@ -181,7 +180,7 @@ final class Splitter extends NodeVisitor { * @return new weight for the resulting block. */ private Block splitBlock(final Block block, final FunctionNode function) { - getLexicalContext().setFlag(getLexicalContext().getCurrentFunction(), FunctionNode.IS_SPLIT); + lc.setFlag(lc.getCurrentFunction(), FunctionNode.IS_SPLIT); final List splits = new ArrayList<>(); List statements = new ArrayList<>(); @@ -210,7 +209,7 @@ final class Splitter extends NodeVisitor { splits.add(createBlockSplitNode(block, function, statements, statementsWeight)); } - return block.setStatements(getLexicalContext(), splits); + return block.setStatements(lc, splits); } /** @@ -258,7 +257,7 @@ final class Splitter extends NodeVisitor { // been split already, so weigh again before splitting. long weight = WeighNodes.weigh(block, weightCache); if (weight >= SPLIT_THRESHOLD) { - newBlock = splitBlock(block, getLexicalContext().getFunction(block)); + newBlock = splitBlock(block, lc.getFunction(block)); weight = WeighNodes.weigh(newBlock, weightCache); } weightCache.put(newBlock, weight); @@ -274,9 +273,9 @@ final class Splitter extends NodeVisitor { return literal; } - final FunctionNode functionNode = getLexicalContext().getCurrentFunction(); + final FunctionNode functionNode = lc.getCurrentFunction(); - getLexicalContext().setFlag(functionNode, FunctionNode.IS_SPLIT); + lc.setFlag(functionNode, FunctionNode.IS_SPLIT); if (literal instanceof ArrayLiteralNode) { final ArrayLiteralNode arrayLiteralNode = (ArrayLiteralNode) literal; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/WeighNodes.java b/nashorn/src/jdk/nashorn/internal/codegen/WeighNodes.java index 002cc9020ba..1adef12bb3c 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/WeighNodes.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/WeighNodes.java @@ -27,6 +27,7 @@ package jdk.nashorn.internal.codegen; import java.util.List; import java.util.Map; + import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.AccessNode; import jdk.nashorn.internal.ir.BinaryNode; @@ -41,6 +42,7 @@ import jdk.nashorn.internal.ir.FunctionNode; import jdk.nashorn.internal.ir.IdentNode; import jdk.nashorn.internal.ir.IfNode; import jdk.nashorn.internal.ir.IndexNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode.ArrayUnit; @@ -63,7 +65,7 @@ import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor; * Computes the "byte code" weight of an AST segment. This is used * for Splitting too large class files */ -final class WeighNodes extends NodeOperatorVisitor { +final class WeighNodes extends NodeOperatorVisitor { /* * Weight constants. */ @@ -100,7 +102,7 @@ final class WeighNodes extends NodeOperatorVisitor { * @param weightCache cache of already calculated block weights */ private WeighNodes(FunctionNode topFunction, final Map weightCache) { - super(); + super(new LexicalContext()); this.topFunction = topFunction; this.weightCache = weightCache; } diff --git a/nashorn/src/jdk/nashorn/internal/ir/AccessNode.java b/nashorn/src/jdk/nashorn/internal/ir/AccessNode.java index 28b09a6cc6c..eecc5713541 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/AccessNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/AccessNode.java @@ -60,7 +60,7 @@ public final class AccessNode extends BaseNode { * @param visitor IR navigating visitor. */ @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterAccessNode(this)) { return visitor.leaveAccessNode( setBase(base.accept(visitor)). @@ -110,7 +110,6 @@ public final class AccessNode extends BaseNode { return new AccessNode(this, base, property, isFunction(), hasCallSiteType()); } - private AccessNode setProperty(final IdentNode property) { if (this.property == property) { return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java b/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java index 51a0664688d..4afa1945eae 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java @@ -160,7 +160,7 @@ public final class BinaryNode extends Node implements Assignment { * @param visitor IR navigating visitor. */ @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterBinaryNode(this)) { return visitor.leaveBinaryNode(setLHS(lhs.accept(visitor)).setRHS(rhs.accept(visitor))); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/Block.java b/nashorn/src/jdk/nashorn/internal/ir/Block.java index a0fa9372bdc..71692144167 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Block.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Block.java @@ -131,7 +131,7 @@ public class Block extends BreakableNode implements Flags { * @return new or same node */ @Override - public Node accept(final LexicalContext lc, final NodeVisitor visitor) { + public Node accept(final LexicalContext lc, final NodeVisitor visitor) { if (visitor.enterBlock(this)) { return visitor.leaveBlock(setStatements(lc, Node.accept(visitor, Statement.class, statements))); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/BreakNode.java b/nashorn/src/jdk/nashorn/internal/ir/BreakNode.java index f1b9cb9822c..2b8fbd83b9e 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/BreakNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/BreakNode.java @@ -59,7 +59,7 @@ public final class BreakNode extends Statement { * @param visitor IR navigating visitor. */ @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterBreakNode(this)) { return visitor.leaveBreakNode(this); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/CallNode.java b/nashorn/src/jdk/nashorn/internal/ir/CallNode.java index 46cf4588a54..7180d9ce120 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/CallNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/CallNode.java @@ -27,6 +27,7 @@ package jdk.nashorn.internal.ir; import java.util.Collections; import java.util.List; + import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.annotations.Ignore; import jdk.nashorn.internal.ir.annotations.Immutable; @@ -194,7 +195,7 @@ public final class CallNode extends LexicalContextNode implements TypeOverride visitor) { if (visitor.enterCallNode(this)) { final CallNode newCallNode = (CallNode)visitor.leaveCallNode( setFunction(function.accept(visitor)). diff --git a/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java b/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java index 8a438f8fb71..aae370f322f 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java @@ -78,7 +78,7 @@ public final class CaseNode extends Node { * @param visitor IR navigating visitor. */ @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterCaseNode(this)) { final Node newTest = test == null ? null : test.accept(visitor); final Block newBody = body == null ? null : (Block)body.accept(visitor); diff --git a/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java b/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java index 67da65f4041..f381814875e 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java @@ -79,7 +79,7 @@ public final class CatchNode extends Statement { * @param visitor IR navigating visitor. */ @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterCatchNode(this)) { return visitor.leaveCatchNode( setException((IdentNode)exception.accept(visitor)). diff --git a/nashorn/src/jdk/nashorn/internal/ir/ContinueNode.java b/nashorn/src/jdk/nashorn/internal/ir/ContinueNode.java index c82813b49f9..579414a92ac 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ContinueNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ContinueNode.java @@ -55,7 +55,7 @@ public class ContinueNode extends Statement { } @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterContinueNode(this)) { return visitor.leaveContinueNode(this); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/EmptyNode.java b/nashorn/src/jdk/nashorn/internal/ir/EmptyNode.java index 9f53a60242d..aa86f2f8918 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/EmptyNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/EmptyNode.java @@ -56,7 +56,7 @@ public final class EmptyNode extends Statement { @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterEmptyNode(this)) { return visitor.leaveEmptyNode(this); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/ExecuteNode.java b/nashorn/src/jdk/nashorn/internal/ir/ExecuteNode.java index 300254ddc62..c696202b9d4 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ExecuteNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ExecuteNode.java @@ -62,7 +62,7 @@ public final class ExecuteNode extends Statement { } @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterExecuteNode(this)) { return visitor.leaveExecuteNode(setExpression(expression.accept(visitor))); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/ForNode.java b/nashorn/src/jdk/nashorn/internal/ir/ForNode.java index 3d0ea3648b7..bad38c6a119 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ForNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ForNode.java @@ -86,7 +86,7 @@ public final class ForNode extends LoopNode { } @Override - protected Node accept(final LexicalContext lc, final NodeVisitor visitor) { + protected Node accept(final LexicalContext lc, final NodeVisitor visitor) { if (visitor.enterForNode(this)) { return visitor.leaveForNode( setInit(lc, init == null ? null : init.accept(visitor)). diff --git a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java index d271985cc8b..4c5eebb01d7 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java @@ -281,7 +281,7 @@ public final class FunctionNode extends LexicalContextNode implements Flags visitor) { if (visitor.enterFunctionNode(this)) { return visitor.leaveFunctionNode(setBody(lc, (Block)body.accept(visitor))); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java b/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java index 2fb769a96c7..de197c3c803 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java @@ -29,7 +29,6 @@ import static jdk.nashorn.internal.codegen.CompilerConstants.__DIR__; import static jdk.nashorn.internal.codegen.CompilerConstants.__FILE__; import static jdk.nashorn.internal.codegen.CompilerConstants.__LINE__; import static jdk.nashorn.internal.codegen.ObjectClassGenerator.DEBUG_FIELDS; - import jdk.nashorn.internal.codegen.ObjectClassGenerator; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.annotations.Immutable; @@ -119,7 +118,7 @@ public final class IdentNode extends Node implements PropertyKey, TypeOverride visitor) { if (visitor.enterIdentNode(this)) { return visitor.leaveIdentNode(this); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/IfNode.java b/nashorn/src/jdk/nashorn/internal/ir/IfNode.java index 7731b302c55..1b606cb068f 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/IfNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/IfNode.java @@ -72,7 +72,7 @@ public final class IfNode extends Statement { } @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterIfNode(this)) { return visitor.leaveIfNode( setTest(test.accept(visitor)). diff --git a/nashorn/src/jdk/nashorn/internal/ir/IndexNode.java b/nashorn/src/jdk/nashorn/internal/ir/IndexNode.java index a22c6179001..0a9b7db28be 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/IndexNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/IndexNode.java @@ -56,19 +56,12 @@ public final class IndexNode extends BaseNode { } @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterIndexNode(this)) { - final Node newBase = base.accept(visitor); - final Node newIndex = index.accept(visitor); - final IndexNode newNode; - if (newBase != base || newIndex != index) { - newNode = new IndexNode(this, newBase, newIndex, isFunction(), hasCallSiteType()); - } else { - newNode = this; - } - return visitor.leaveIndexNode(newNode); + return visitor.leaveIndexNode( + setBase(base.accept(visitor)). + setIndex(index.accept(visitor))); } - return this; } @@ -106,6 +99,13 @@ public final class IndexNode extends BaseNode { return index; } + private IndexNode setBase(final Node base) { + if (this.base == base) { + return this; + } + return new IndexNode(this, base, index, isFunction(), hasCallSiteType()); + } + /** * Set the index expression for this node * @param index new index expression diff --git a/nashorn/src/jdk/nashorn/internal/ir/LabelNode.java b/nashorn/src/jdk/nashorn/internal/ir/LabelNode.java index d791f3fa84a..ad9979ef904 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/LabelNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/LabelNode.java @@ -67,11 +67,11 @@ public final class LabelNode extends LexicalContextNode { } @Override - public Node accept(final LexicalContext lc, final NodeVisitor visitor) { + public Node accept(final LexicalContext lc, final NodeVisitor visitor) { if (visitor.enterLabelNode(this)) { return visitor.leaveLabelNode( - setLabel(visitor.getLexicalContext(), (IdentNode)label.accept(visitor)). - setBody(visitor.getLexicalContext(), (Block)body.accept(visitor))); + setLabel(lc, (IdentNode)label.accept(visitor)). + setBody(lc, (Block)body.accept(visitor))); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/LexicalContextNode.java b/nashorn/src/jdk/nashorn/internal/ir/LexicalContextNode.java index 52f62f0959d..020faf8e560 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/LexicalContextNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/LexicalContextNode.java @@ -60,10 +60,10 @@ public abstract class LexicalContextNode extends Statement { * * @return new node or same node depending on state change */ - protected abstract Node accept(final LexicalContext lc, final NodeVisitor visitor); + protected abstract Node accept(final LexicalContext lc, final NodeVisitor visitor); @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { final LexicalContext lc = visitor.getLexicalContext(); lc.push(this); final LexicalContextNode newNode = (LexicalContextNode)accept(lc, visitor); diff --git a/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java b/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java index 4c2f932cf4d..7a59c5fe840 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java @@ -28,6 +28,7 @@ package jdk.nashorn.internal.ir; import java.util.Arrays; import java.util.Collections; import java.util.List; + import jdk.nashorn.internal.codegen.CompileUnit; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.annotations.Immutable; @@ -208,7 +209,7 @@ public abstract class LiteralNode extends Node implements PropertyKey { * @param visitor IR navigating visitor. */ @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterLiteralNode(this)) { return visitor.leaveLiteralNode(this); } @@ -514,7 +515,7 @@ public abstract class LiteralNode extends Node implements PropertyKey { } @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterLiteralNode(this)) { if (value != null) { final Node newValue = value.accept(visitor); @@ -840,7 +841,7 @@ public abstract class LiteralNode extends Node implements PropertyKey { } @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterLiteralNode(this)) { final List oldValue = Arrays.asList(value); final List newValue = Node.accept(visitor, Node.class, oldValue); diff --git a/nashorn/src/jdk/nashorn/internal/ir/Node.java b/nashorn/src/jdk/nashorn/internal/ir/Node.java index 99e543e6110..4342c2be724 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Node.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Node.java @@ -27,6 +27,7 @@ package jdk.nashorn.internal.ir; import java.util.ArrayList; import java.util.List; + import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.Token; @@ -175,7 +176,7 @@ public abstract class Node implements Cloneable { * @param visitor Node visitor. * @return node the node or its replacement after visitation, null if no further visitations are required */ - public abstract Node accept(NodeVisitor visitor); + public abstract Node accept(NodeVisitor visitor); @Override public String toString() { @@ -337,7 +338,7 @@ public abstract class Node implements Cloneable { } //on change, we have to replace the entire list, that's we can't simple do ListIterator.set - static List accept(final NodeVisitor visitor, final Class clazz, final List list) { + static List accept(final NodeVisitor visitor, final Class clazz, final List list) { boolean changed = false; final List newList = new ArrayList<>(); diff --git a/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java b/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java index 34069725640..8529a1fe67d 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java @@ -58,7 +58,7 @@ public final class ObjectNode extends Node { } @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterObjectNode(this)) { return visitor.leaveObjectNode(setElements(Node.accept(visitor, Node.class, elements))); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/PropertyNode.java b/nashorn/src/jdk/nashorn/internal/ir/PropertyNode.java index 7040d41477d..8bf6b80f7c7 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/PropertyNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/PropertyNode.java @@ -81,7 +81,7 @@ public final class PropertyNode extends Node { } @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterPropertyNode(this)) { return visitor.leavePropertyNode( setKey((PropertyKey)((Node)key).accept(visitor)). diff --git a/nashorn/src/jdk/nashorn/internal/ir/ReturnNode.java b/nashorn/src/jdk/nashorn/internal/ir/ReturnNode.java index c0091eb419f..563d0519e99 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ReturnNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ReturnNode.java @@ -86,7 +86,7 @@ public class ReturnNode extends Statement { } @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterReturnNode(this)) { if (expression != null) { return visitor.leaveReturnNode(setExpression(expression.accept(visitor))); diff --git a/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java b/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java index 47509be12d4..540b2eaf781 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; + import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; @@ -407,7 +408,7 @@ public class RuntimeNode extends Node implements TypeOverride { } @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterRuntimeNode(this)) { final List newArgs = new ArrayList<>(); for (final Node arg : args) { diff --git a/nashorn/src/jdk/nashorn/internal/ir/SplitNode.java b/nashorn/src/jdk/nashorn/internal/ir/SplitNode.java index ee6e023c167..e71cd6bd2cf 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/SplitNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/SplitNode.java @@ -81,7 +81,7 @@ public class SplitNode extends LexicalContextNode { } @Override - public Node accept(final LexicalContext lc, final NodeVisitor visitor) { + public Node accept(final LexicalContext lc, final NodeVisitor visitor) { if (visitor.enterSplitNode(this)) { return visitor.leaveSplitNode(setBody(lc, body.accept(visitor))); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java b/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java index bfc03108412..3790ad518e5 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java @@ -100,11 +100,11 @@ public final class SwitchNode extends BreakableNode { } @Override - public Node accept(final LexicalContext lc, final NodeVisitor visitor) { + public Node accept(final LexicalContext lc, final NodeVisitor visitor) { if (visitor.enterSwitchNode(this)) { return visitor.leaveSwitchNode( - setExpression(visitor.getLexicalContext(), expression.accept(visitor)). - setCases(visitor.getLexicalContext(), Node.accept(visitor, CaseNode.class, cases), defaultCaseIndex)); + setExpression(lc, expression.accept(visitor)). + setCases(lc, Node.accept(visitor, CaseNode.class, cases), defaultCaseIndex)); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/TernaryNode.java b/nashorn/src/jdk/nashorn/internal/ir/TernaryNode.java index 25ac1a4ddaa..c05e6245673 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/TernaryNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/TernaryNode.java @@ -63,7 +63,7 @@ public final class TernaryNode extends Node { } @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterTernaryNode(this)) { final Node newLhs = lhs().accept(visitor); final Node newRhs = rhs().accept(visitor); diff --git a/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java b/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java index 70d385733be..3d33fc77559 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java @@ -72,7 +72,7 @@ public final class ThrowNode extends Statement { * @param visitor IR navigating visitor. */ @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterThrowNode(this)) { return visitor.leaveThrowNode(setExpression(expression.accept(visitor))); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/TryNode.java b/nashorn/src/jdk/nashorn/internal/ir/TryNode.java index 01ea75c7458..6c30118eeae 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/TryNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/TryNode.java @@ -106,7 +106,7 @@ public final class TryNode extends Statement { * @param visitor IR navigating visitor. */ @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterTryNode(this)) { // Need to do finallybody first for termination analysis. TODO still necessary? final Block newFinallyBody = finallyBody == null ? null : (Block)finallyBody.accept(visitor); diff --git a/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java b/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java index ed1d8a9bdbe..f9c971ede2d 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java @@ -29,7 +29,6 @@ import static jdk.nashorn.internal.parser.TokenType.BIT_NOT; import static jdk.nashorn.internal.parser.TokenType.CONVERT; import static jdk.nashorn.internal.parser.TokenType.DECPOSTFIX; import static jdk.nashorn.internal.parser.TokenType.INCPOSTFIX; - import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; @@ -121,7 +120,7 @@ public final class UnaryNode extends Node implements Assignment { * @param visitor IR navigating visitor. */ @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterUnaryNode(this)) { return visitor.leaveUnaryNode(setRHS(rhs.accept(visitor))); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/VarNode.java b/nashorn/src/jdk/nashorn/internal/ir/VarNode.java index c28f5456c3b..d4f41d6dea8 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/VarNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/VarNode.java @@ -121,7 +121,7 @@ public final class VarNode extends Statement implements Assignment { * @param visitor IR navigating visitor. */ @Override - public Node accept(final NodeVisitor visitor) { + public Node accept(final NodeVisitor visitor) { if (visitor.enterVarNode(this)) { final IdentNode newName = (IdentNode)name.accept(visitor); final Node newInit = init == null ? null : init.accept(visitor); diff --git a/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java b/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java index c52209fc1c0..c2d05b3d76d 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java @@ -75,7 +75,7 @@ public final class WhileNode extends LoopNode { } @Override - protected Node accept(final LexicalContext lc, final NodeVisitor visitor) { + protected Node accept(final LexicalContext lc, final NodeVisitor visitor) { if (visitor.enterWhileNode(this)) { if (isDoWhile()) { return visitor.leaveWhileNode( diff --git a/nashorn/src/jdk/nashorn/internal/ir/WithNode.java b/nashorn/src/jdk/nashorn/internal/ir/WithNode.java index e069ff5ef24..387659b212f 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/WithNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/WithNode.java @@ -64,7 +64,7 @@ public final class WithNode extends LexicalContextNode { * @param visitor IR navigating visitor. */ @Override - public Node accept(final LexicalContext lc, final NodeVisitor visitor) { + public Node accept(final LexicalContext lc, final NodeVisitor visitor) { if (visitor.enterWithNode(this)) { return visitor.leaveWithNode( setExpression(lc, expression.accept(visitor)). diff --git a/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java b/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java index 177fcf95b7f..4415ebd7689 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java +++ b/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java @@ -45,6 +45,7 @@ import jdk.nashorn.internal.ir.IdentNode; import jdk.nashorn.internal.ir.IfNode; import jdk.nashorn.internal.ir.IndexNode; import jdk.nashorn.internal.ir.LabelNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.ObjectNode; @@ -74,7 +75,8 @@ import jdk.nashorn.internal.runtime.Source; /** * This IR writer produces a JSON string that represents AST as a JSON string. */ -public final class JSONWriter extends NodeVisitor { +public final class JSONWriter extends NodeVisitor { + /** * Returns AST as JSON compatible string. * @@ -867,7 +869,8 @@ public final class JSONWriter extends NodeVisitor { // Internals below private JSONWriter(final boolean includeLocation) { - this.buf = new StringBuilder(); + super(new LexicalContext()); + this.buf = new StringBuilder(); this.includeLocation = includeLocation; } @@ -963,7 +966,7 @@ public final class JSONWriter extends NodeVisitor { objectStart("loc"); // source name - final Source src = getLexicalContext().getCurrentFunction().getSource(); + final Source src = lc.getCurrentFunction().getSource(); property("source", src.getName()); comma(); diff --git a/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java b/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java index 3ac50067ee5..2e2368b116a 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java +++ b/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java @@ -36,6 +36,7 @@ import jdk.nashorn.internal.ir.ForNode; import jdk.nashorn.internal.ir.FunctionNode; import jdk.nashorn.internal.ir.IfNode; import jdk.nashorn.internal.ir.LabelNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.SplitNode; import jdk.nashorn.internal.ir.Statement; @@ -53,7 +54,7 @@ import jdk.nashorn.internal.ir.visitor.NodeVisitor; * * see the flags --print-parse and --print-lower-parse */ -public final class PrintVisitor extends NodeVisitor { +public final class PrintVisitor extends NodeVisitor { /** Tab width */ private static final int TABWIDTH = 4; @@ -84,6 +85,7 @@ public final class PrintVisitor extends NodeVisitor { * @param printLineNumbers should line number nodes be included in the output? */ public PrintVisitor(final boolean printLineNumbers) { + super(new LexicalContext()); this.EOLN = System.lineSeparator(); this.sb = new StringBuilder(); this.printLineNumbers = printLineNumbers; diff --git a/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeOperatorVisitor.java b/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeOperatorVisitor.java index 2beba46ce4d..1791f92b4ff 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeOperatorVisitor.java +++ b/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeOperatorVisitor.java @@ -32,21 +32,15 @@ import jdk.nashorn.internal.ir.UnaryNode; /** * Like NodeVisitor but navigating further into operators. + * @param Lexical context class for this NodeOperatorVisitor */ -public class NodeOperatorVisitor extends NodeVisitor { - /** - * Constructor - */ - public NodeOperatorVisitor() { - super(); - } - +public class NodeOperatorVisitor extends NodeVisitor { /** * Constructor * * @param lc a custom lexical context */ - public NodeOperatorVisitor(final LexicalContext lc) { + public NodeOperatorVisitor(final T lc) { super(lc); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeVisitor.java b/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeVisitor.java index 8c807df73b9..d8a21a64295 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeVisitor.java +++ b/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeVisitor.java @@ -60,23 +60,18 @@ import jdk.nashorn.internal.ir.WithNode; /** * Visitor used to navigate the IR. + * @param lexical context class used by this visitor */ -public abstract class NodeVisitor { - private final LexicalContext lc; - - /** - * Constructor - */ - public NodeVisitor() { - this(new LexicalContext()); - } +public abstract class NodeVisitor { + /** lexical context in use */ + protected final T lc; /** * Constructor * * @param lc a custom lexical context */ - public NodeVisitor(final LexicalContext lc) { + public NodeVisitor(final T lc) { this.lc = lc; } @@ -84,7 +79,7 @@ public abstract class NodeVisitor { * Get the lexical context of this node visitor * @return lexical context */ - public LexicalContext getLexicalContext() { + public T getLexicalContext() { return lc; } diff --git a/nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java b/nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java index ebab47b65f0..d85b31cbae6 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java +++ b/nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java @@ -28,7 +28,6 @@ package jdk.nashorn.internal.objects; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Getter; import jdk.nashorn.internal.objects.annotations.ScriptClass; -import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptRuntime; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/DebugLogger.java b/nashorn/src/jdk/nashorn/internal/runtime/DebugLogger.java index dda24bbf04e..fa0dbede2db 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/DebugLogger.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/DebugLogger.java @@ -35,7 +35,6 @@ import jdk.nashorn.internal.runtime.options.Options; */ public final class DebugLogger { - @SuppressWarnings("NonConstantLogger") private final Logger logger; private final boolean isEnabled; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java index c791274e6d5..a3f4718b25b 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java @@ -43,6 +43,7 @@ import java.security.Permissions; import java.security.PrivilegedAction; import java.security.ProtectionDomain; import java.security.SecureClassLoader; + import jdk.internal.dynalink.beans.StaticClass; import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.Opcodes; @@ -58,6 +59,7 @@ import jdk.nashorn.internal.runtime.ScriptObject; * "class loader", it does not, in fact, extend {@code ClassLoader}, but rather uses them internally. Instances of this * class are normally created by {@link JavaAdapterBytecodeGenerator}. */ +@SuppressWarnings("javadoc") class JavaAdapterClassLoader extends JavaAdapterGeneratorBase { private static final Type PRIVILEGED_ACTION_TYPE = Type.getType(PrivilegedAction.class); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java index f3f51fd8d48..ecec63bcbad 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java @@ -39,6 +39,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; + import jdk.internal.dynalink.beans.StaticClass; import jdk.internal.dynalink.support.LinkRequestImpl; import jdk.nashorn.internal.objects.NativeJava; @@ -66,6 +67,7 @@ import jdk.nashorn.internal.runtime.ScriptObject; *

    */ +@SuppressWarnings("javadoc") public final class JavaAdapterFactory { /** * A mapping from an original Class object to AdapterInfo representing the adapter for the class it represents. diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterGeneratorBase.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterGeneratorBase.java index 67499cbc58a..ff33ba6ef72 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterGeneratorBase.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterGeneratorBase.java @@ -33,6 +33,7 @@ import jdk.nashorn.internal.runtime.ScriptObject; * Base class for both {@link JavaAdapterBytecodeGenerator} and {@link JavaAdapterClassLoader}, containing those * bytecode types, type names and method descriptor that are used by both. */ +@SuppressWarnings("javadoc") abstract class JavaAdapterGeneratorBase { static final Type CONTEXT_TYPE = Type.getType(Context.class); static final Type OBJECT_TYPE = Type.getType(Object.class); From bd53fa8370d6e4f318c939e6a51c6a9942a39b13 Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Thu, 23 May 2013 17:39:32 +0200 Subject: [PATCH 045/206] 8009576: Test returns ClassNotFoundException Small classpath fix and move tests into open Reviewed-by: mgerdin, zgu --- .../runtime/Metaspace/FragmentMetaspace.java | 64 ++++++ .../Metaspace/FragmentMetaspaceSimple.java | 69 ++++++ .../runtime/Metaspace/classes/test/Empty.java | 28 +++ .../testlibrary/GeneratedClassLoader.java | 202 ++++++++++++++++++ 4 files changed, 363 insertions(+) create mode 100644 hotspot/test/runtime/Metaspace/FragmentMetaspace.java create mode 100644 hotspot/test/runtime/Metaspace/FragmentMetaspaceSimple.java create mode 100644 hotspot/test/runtime/Metaspace/classes/test/Empty.java create mode 100644 hotspot/test/runtime/testlibrary/GeneratedClassLoader.java diff --git a/hotspot/test/runtime/Metaspace/FragmentMetaspace.java b/hotspot/test/runtime/Metaspace/FragmentMetaspace.java new file mode 100644 index 00000000000..5e1a7200493 --- /dev/null +++ b/hotspot/test/runtime/Metaspace/FragmentMetaspace.java @@ -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 + * @library /runtime/testlibrary + * @build GeneratedClassLoader + * @run main/othervm/timeout=200 FragmentMetaspace + */ + +import java.io.IOException; + +/** + * Test that tries to fragment the native memory used by class loaders. + * This test creates class loaders that load classes of increasing size for every + * iteration. By increasing the size of the class meta data needed for every iteration + * we stress the subsystem for allocating native memory for meta data. + */ +public class FragmentMetaspace { + + public static void main(String... args) { + runGrowing(Long.valueOf(System.getProperty("time", "80000"))); + // try to clean up and unload classes to decrease + // class verification time in debug vm + System.gc(); + } + + private static void runGrowing(long time) { + long startTime = System.currentTimeMillis(); + for (int i = 0; System.currentTimeMillis() < startTime + time; ++i) { + try { + GeneratedClassLoader gcl = new GeneratedClassLoader(); + + Class c = gcl.getGeneratedClasses(i, 100)[0]; + c.newInstance(); + c = null; + + gcl = null; + } catch (IOException|InstantiationException|IllegalAccessException ex) { + throw new RuntimeException(ex); + } + } + } +} diff --git a/hotspot/test/runtime/Metaspace/FragmentMetaspaceSimple.java b/hotspot/test/runtime/Metaspace/FragmentMetaspaceSimple.java new file mode 100644 index 00000000000..2e6f7b52c0e --- /dev/null +++ b/hotspot/test/runtime/Metaspace/FragmentMetaspaceSimple.java @@ -0,0 +1,69 @@ +/* + * 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 + * @library /runtime/testlibrary + * @library classes + * @build test.Empty ClassUnloadCommon + * @run main/othervm/timeout=200 FragmentMetaspaceSimple + */ + +import java.util.ArrayList; + +/** + * Test that tries to fragment the native memory used by class loaders. + * Keeps every other class loader alive in order to fragment the memory space + * used to store classes and meta data. Since the memory is probably allocated in + * chunks per class loader this will cause a lot of fragmentation if not handled + * properly since every other chunk will be unused. + */ +public class FragmentMetaspaceSimple { + public static void main(String... args) { + runSimple(Long.valueOf(System.getProperty("time", "80000"))); + System.gc(); + } + + private static void runSimple(long time) { + long startTime = System.currentTimeMillis(); + ArrayList cls = new ArrayList<>(); + for (int i = 0; System.currentTimeMillis() < startTime + time; ++i) { + ClassLoader ldr = ClassUnloadCommon.newClassLoader(); + if (i % 1000 == 0) { + cls.clear(); + } + // only keep every other class loader alive + if (i % 2 == 1) { + cls.add(ldr); + } + Class c = null; + try { + c = ldr.loadClass("test.Empty"); + } catch (ClassNotFoundException ex) { + throw new RuntimeException(ex); + } + c = null; + } + cls = null; + } +} diff --git a/hotspot/test/runtime/Metaspace/classes/test/Empty.java b/hotspot/test/runtime/Metaspace/classes/test/Empty.java new file mode 100644 index 00000000000..dc02e299af5 --- /dev/null +++ b/hotspot/test/runtime/Metaspace/classes/test/Empty.java @@ -0,0 +1,28 @@ +/* + * 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. + */ + +package test; + +public class Empty { +public String toString() { return "nothing"; } +} diff --git a/hotspot/test/runtime/testlibrary/GeneratedClassLoader.java b/hotspot/test/runtime/testlibrary/GeneratedClassLoader.java new file mode 100644 index 00000000000..84a1b7e157d --- /dev/null +++ b/hotspot/test/runtime/testlibrary/GeneratedClassLoader.java @@ -0,0 +1,202 @@ +/* + * 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.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import javax.tools.JavaCompiler; +import javax.tools.ToolProvider; + +/** + * A class loader that generates new classes. + * The generated classes are made by first emitting java sources with nested + * static classes, these are then compiled and the class files are read back. + * Some efforts are made to make the class instances unique and of not insignificant + * size. + */ +public class GeneratedClassLoader extends ClassLoader { + /** + * Holds a pair of class bytecodes and class name (for use with defineClass). + */ + private static class GeneratedClass { + public byte[] bytes; + public String name; + public GeneratedClass(byte[] bytes, String name) { + this.bytes = bytes; this.name = name; + } + } + + /** + * Used to uniquely name every class generated. + */ + private static int count = 0; + /** + * Used to enable/disable keeping the class files and java sources for + * the generated classes. + */ + private static boolean deleteFiles = Boolean.parseBoolean( + System.getProperty("GeneratedClassLoader.deleteFiles", "true")); + + private static String bigstr = + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + + "In facilisis scelerisque vehicula. Donec congue nisi a " + + "leo posuere placerat lobortis felis ultrices. Pellentesque " + + "habitant morbi tristique senectus et netus et malesuada " + + "fames ac turpis egestas. Nam tristique velit at felis " + + "iaculis at tempor sem vestibulum. Sed adipiscing lectus " + + "non mi molestie sagittis. Morbi eu purus urna. Nam tempor " + + "tristique massa eget semper. Mauris cursus, nulla et ornare " + + "vehicula, leo dolor scelerisque metus, sit amet rutrum erat " + + "sapien quis dui. Nullam eleifend risus et velit accumsan sed " + + "suscipit felis pulvinar. Nullam faucibus suscipit gravida. " + + "Pellentesque habitant morbi tristique senectus et netus et " + + "malesuada fames ac turpis egestas. Nullam ut massa augue, " + + "nec viverra mauris."; + + private static int getNextCount() { + return count++; + } + + ////// end statics + + private JavaCompiler javac; + private String nameBase; + + public GeneratedClassLoader() { + javac = ToolProvider.getSystemJavaCompiler(); + nameBase = "TestSimpleClass"; + } + + private long getBigValue(int which) { + // > 65536 is too large to encode in the bytecode + // so this will force us to emit a constant pool entry for this int + return (long)which + 65537; + } + + private String getBigString(int which) { + return bigstr + which; + } + + private String getClassName(int count) { + return nameBase + count; + } + + private String generateSource(int count, int sizeFactor, int numClasses) { + StringBuilder sb = new StringBuilder(); + sb.append("public class ").append(getClassName(count)).append("{\n"); + for (int j = 0; j < numClasses; ++j) { + sb.append("public static class ") + .append("Class") + .append(j) + .append("{\n"); + for (int i = 0; i < sizeFactor; ++i) { + int value = i; + sb.append("private long field") + .append(i).append(" = ") + .append(getBigValue(value++)) + .append(";\n"); + sb.append("public long method") + .append(i) + .append("() {\n"); + sb.append("return ") + .append(getBigValue(value++)) + .append(";"); + sb.append("}\n"); + sb.append("private String str").append(i) + .append(" = \"") + .append(getBigString(i)) + .append("\";"); + } + sb.append("\n}"); + } + sb.append("\n}"); + return sb.toString(); + } + + private GeneratedClass[] getGeneratedClass(int sizeFactor, int numClasses) throws IOException { + int uniqueCount = getNextCount(); + String src = generateSource(uniqueCount, sizeFactor, numClasses); + String className = getClassName(uniqueCount); + File file = new File(className + ".java"); + try (PrintWriter pw = new PrintWriter(new FileWriter(file))) { + pw.append(src); + pw.flush(); + } + int exitcode = javac.run(null, null, null, file.getCanonicalPath()); + if (exitcode != 0) { + throw new RuntimeException("javac failure when compiling: " + + file.getCanonicalPath()); + } else { + if (deleteFiles) { + file.delete(); + } + } + GeneratedClass[] gc = new GeneratedClass[numClasses]; + for (int i = 0; i < numClasses; ++i) { + String name = className + "$" + "Class" + i; + File classFile = new File(name + ".class"); + byte[] bytes; + try (DataInputStream dis = new DataInputStream(new FileInputStream(classFile))) { + bytes = new byte[dis.available()]; + dis.readFully(bytes); + } + if (deleteFiles) { + classFile.delete(); + } + gc[i] = new GeneratedClass(bytes, name); + } + if (deleteFiles) { + new File(className + ".class").delete(); + } + return gc; + } + + /** + * Generate a single class, compile it and load it. + * @param sizeFactor Fuzzy measure of how large the class should be. + * @return the Class instance. + * @throws IOException + */ + public Class generateClass(int sizeFactor) throws IOException { + return getGeneratedClasses(sizeFactor, 1)[0]; + } + + /** + * Generate several classes, compile and load them. + * @param sizeFactor Fuzzy measure of how large each class should be. + * @param numClasses The number of classes to create + * @return an array of the Class instances. + * @throws IOException + */ + public Class[] getGeneratedClasses(int sizeFactor, int numClasses) throws IOException { + GeneratedClass[] gc = getGeneratedClass(sizeFactor, numClasses); + Class[] classes = new Class[numClasses]; + for (int i = 0; i < numClasses; ++i) { + classes[i] = defineClass(gc[i].name, gc[i].bytes, 0 , gc[i].bytes.length); + } + return classes; + } +} From b2e43ed612c42a451c28028f9be07bcf65fa1249 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Thu, 23 May 2013 23:04:33 -0700 Subject: [PATCH 046/206] 8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes The fix of perf regression is to use method_idnum() for direct indexing into NMT Reviewed-by: twisti, kvn, coleenp, dholmes --- hotspot/src/share/vm/oops/instanceKlass.cpp | 19 +++++++++-- hotspot/src/share/vm/oops/instanceKlass.hpp | 3 +- hotspot/src/share/vm/prims/methodHandles.cpp | 34 +++++++------------- hotspot/src/share/vm/prims/methodHandles.hpp | 11 +++---- 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index b61f595424e..562adaae04a 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -2754,15 +2754,28 @@ nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_le return NULL; } -void InstanceKlass::add_member_name(Handle mem_name) { +void InstanceKlass::add_member_name(int index, Handle mem_name) { jweak mem_name_wref = JNIHandles::make_weak_global(mem_name); MutexLocker ml(MemberNameTable_lock); + assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds"); DEBUG_ONLY(No_Safepoint_Verifier nsv); if (_member_names == NULL) { - _member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(); + _member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(idnum_allocated_count()); } - _member_names->add_member_name(mem_name_wref); + _member_names->add_member_name(index, mem_name_wref); +} + +oop InstanceKlass::get_member_name(int index) { + MutexLocker ml(MemberNameTable_lock); + assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds"); + DEBUG_ONLY(No_Safepoint_Verifier nsv); + + if (_member_names == NULL) { + return NULL; + } + oop mem_name =_member_names->get_member_name(index); + return mem_name; } // ----------------------------------------------------------------------------------------------------- diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 1a370711fd7..e158cdf3cf4 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -1022,7 +1022,8 @@ public: // JSR-292 support MemberNameTable* member_names() { return _member_names; } void set_member_names(MemberNameTable* member_names) { _member_names = member_names; } - void add_member_name(Handle member_name); + void add_member_name(int index, Handle member_name); + oop get_member_name(int index); public: // JVMTI support diff --git a/hotspot/src/share/vm/prims/methodHandles.cpp b/hotspot/src/share/vm/prims/methodHandles.cpp index 58957eed067..bb9da0034e4 100644 --- a/hotspot/src/share/vm/prims/methodHandles.cpp +++ b/hotspot/src/share/vm/prims/methodHandles.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -232,7 +232,8 @@ oop MethodHandles::init_method_MemberName(Handle mname, Method* m, bool do_dispa // This is done eagerly, since it is readily available without // constructing any new objects. // TO DO: maybe intern mname_oop - m->method_holder()->add_member_name(mname); + m->method_holder()->add_member_name(m->method_idnum(), mname); + return mname(); } @@ -301,7 +302,6 @@ oop MethodHandles::init_field_MemberName(Handle mname, KlassHandle field_holder, // Although the fieldDescriptor::_index would also identify the field, // we do not use it, because it is harder to decode. // TO DO: maybe intern mname_oop - InstanceKlass::cast(field_holder())->add_member_name(mname); return mname(); } @@ -943,7 +943,8 @@ int MethodHandles::find_MemberNames(KlassHandle k, // MemberNameTable // -MemberNameTable::MemberNameTable() : GrowableArray(10, true) { +MemberNameTable::MemberNameTable(int methods_cnt) + : GrowableArray(methods_cnt, true) { assert_locked_or_safepoint(MemberNameTable_lock); } @@ -957,29 +958,18 @@ MemberNameTable::~MemberNameTable() { } } -// Return entry index if found, return -1 otherwise. -int MemberNameTable::find_member_name(oop mem_name) { +void MemberNameTable::add_member_name(int index, jweak mem_name_wref) { assert_locked_or_safepoint(MemberNameTable_lock); - int len = this->length(); - - for (int idx = 0; idx < len; idx++) { - jweak ref = this->at(idx); - oop entry = JNIHandles::resolve(ref); - if (entry == mem_name) { - return idx; - } - } - return -1; + this->at_put_grow(index, mem_name_wref); } -void MemberNameTable::add_member_name(jweak mem_name_wref) { +// Return a member name oop or NULL. +oop MemberNameTable::get_member_name(int index) { assert_locked_or_safepoint(MemberNameTable_lock); - oop mem_name = JNIHandles::resolve(mem_name_wref); - // Each member name may appear just once: add only if not found - if (find_member_name(mem_name) == -1) { - this->append(mem_name_wref); - } + jweak ref = this->at(index); + oop mem_name = JNIHandles::resolve(ref); + return mem_name; } #if INCLUDE_JVMTI diff --git a/hotspot/src/share/vm/prims/methodHandles.hpp b/hotspot/src/share/vm/prims/methodHandles.hpp index f01a3c9fc1b..50ce7af86ea 100644 --- a/hotspot/src/share/vm/prims/methodHandles.hpp +++ b/hotspot/src/share/vm/prims/methodHandles.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -219,7 +219,6 @@ public: } }; - //------------------------------------------------------------------------------ // MethodHandlesAdapterGenerator // @@ -233,13 +232,13 @@ public: //------------------------------------------------------------------------------ // MemberNameTable // + class MemberNameTable : public GrowableArray { public: - MemberNameTable(); + MemberNameTable(int methods_cnt); ~MemberNameTable(); - void add_member_name(jweak mem_name_ref); - private: - int find_member_name(oop mem_name); + void add_member_name(int index, jweak mem_name_ref); + oop get_member_name(int index); #if INCLUDE_JVMTI public: From cdf1276490361a4d1394edfc304da5a89fab9fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Fri, 24 May 2013 13:54:18 +0200 Subject: [PATCH 047/206] 8011630: JSON parsing performance issue Reviewed-by: lagergren, sundar --- .../internal/objects/NativeArguments.java | 5 + .../internal/runtime/AccessorProperty.java | 116 +++++++++++++--- .../internal/runtime/FindProperty.java | 19 +++ .../nashorn/internal/runtime/Property.java | 20 +++ .../internal/runtime/ScriptObject.java | 124 ++---------------- .../internal/runtime/SetMethodCreator.java | 9 +- .../runtime/UserAccessorProperty.java | 78 ++++++++++- 7 files changed, 231 insertions(+), 140 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeArguments.java b/nashorn/src/jdk/nashorn/internal/objects/NativeArguments.java index afc2b57e090..efab674b1df 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeArguments.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeArguments.java @@ -603,6 +603,11 @@ public final class NativeArguments extends ScriptObject { } } + @Override + public Object getLength() { + return length; + } + private Object getArgumentsLength() { return length; } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java b/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java index 38effdafd55..c3bfa697850 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java @@ -75,7 +75,23 @@ public class AccessorProperty extends Property { private static final MethodType[] ACCESSOR_GETTER_TYPES = new MethodType[NOOF_TYPES]; private static final MethodType[] ACCESSOR_SETTER_TYPES = new MethodType[NOOF_TYPES]; - private static final MethodHandle SPILLGETTER = MH.asType(MH.getter(MethodHandles.lookup(), ScriptObject.class, "spill", Object[].class), Lookup.GET_OBJECT_TYPE); + private static final MethodHandle SPILL_ELEMENT_GETTER; + private static final MethodHandle SPILL_ELEMENT_SETTER; + + private static final int SPILL_CACHE_SIZE = 8; + private static final MethodHandle[] SPILL_ACCESSORS = new MethodHandle[SPILL_CACHE_SIZE * 2]; + + static { + for (int i = 0; i < NOOF_TYPES; i++) { + final Type type = ACCESSOR_TYPES.get(i); + ACCESSOR_GETTER_TYPES[i] = MH.type(type.getTypeClass(), Object.class); + ACCESSOR_SETTER_TYPES[i] = MH.type(void.class, Object.class, type.getTypeClass()); + } + + final MethodHandle spillGetter = MH.getter(MethodHandles.lookup(), ScriptObject.class, "spill", Object[].class); + SPILL_ELEMENT_GETTER = MH.filterArguments(MH.arrayElementGetter(Object[].class), 0, spillGetter); + SPILL_ELEMENT_SETTER = MH.filterArguments(MH.arrayElementSetter(Object[].class), 0, spillGetter); + } /** Seed getter for the primitive version of this field (in -Dnashorn.fields.dual=true mode) */ private MethodHandle primitiveGetter; @@ -96,14 +112,6 @@ public class AccessorProperty extends Property { */ private Class currentType; - static { - for (int i = 0; i < NOOF_TYPES; i++) { - final Type type = ACCESSOR_TYPES.get(i); - ACCESSOR_GETTER_TYPES[i] = MH.type(type.getTypeClass(), Object.class); - ACCESSOR_SETTER_TYPES[i] = MH.type(void.class, Object.class, type.getTypeClass()); - } - } - /** * Delegate constructor. This is used when adding properties to the Global scope, which * is necessary for outermost levels in a script (the ScriptObject is represented by @@ -114,18 +122,30 @@ public class AccessorProperty extends Property { * @param delegate delegate script object to rebind receiver to */ public AccessorProperty(final AccessorProperty property, final ScriptObject delegate) { - this(property); + super(property); - this.getters = new MethodHandle[NOOF_TYPES]; - - this.primitiveGetter = bindTo(primitiveGetter, delegate); - this.primitiveSetter = bindTo(primitiveSetter, delegate); - this.objectGetter = bindTo(objectGetter, delegate); - this.objectSetter = bindTo(objectSetter, delegate); + this.primitiveGetter = bindTo(property.primitiveGetter, delegate); + this.primitiveSetter = bindTo(property.primitiveSetter, delegate); + this.objectGetter = bindTo(property.objectGetter, delegate); + this.objectSetter = bindTo(property.objectSetter, delegate); setCurrentType(property.getCurrentType()); } + /** + * Constructor for spill properties. Array getters and setters will be created on demand. + * + * @param key the property key + * @param flags the property flags + * @param slot spill slot + */ + public AccessorProperty(final String key, final int flags, final int slot) { + super(key, flags, slot); + assert (flags & IS_SPILL) == IS_SPILL; + + setCurrentType(Object.class); + } + /** * Constructor. Similar to the constructor with both primitive getters and setters, the difference * here being that only one getter and setter (setter is optional for non writable fields) is given @@ -267,8 +287,41 @@ public class AccessorProperty extends Property { return new AccessorProperty(this); } + @Override + protected void setObjectValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict) { + if (isSpill()) { + self.spill[getSlot()] = value; + } else { + try { + getSetter(Object.class, self.getMap()).invokeExact((Object)self, value); + } catch (final Error|RuntimeException e) { + throw e; + } catch (final Throwable e) { + throw new RuntimeException(e); + } + } + } + + @Override + protected Object getObjectValue(final ScriptObject self, final ScriptObject owner) { + if (isSpill()) { + return self.spill[getSlot()]; + } else { + try { + return getGetter(Object.class).invokeExact((Object)self); + } catch (final Error|RuntimeException e) { + throw e; + } catch (final Throwable e) { + throw new RuntimeException(e); + } + } + } + @Override public MethodHandle getGetter(final Class type) { + if (isSpill() && objectGetter == null) { + objectGetter = getSpillGetter(); + } final int i = getAccessorTypeIndex(type); if (getters[i] == null) { getters[i] = debug( @@ -284,7 +337,7 @@ public class AccessorProperty extends Property { "get"); } - return isSpill() ? MH.filterArguments(getters[i], 0, SPILLGETTER) : getters[i]; + return getters[i]; } private Property getWiderProperty(final Class type) { @@ -313,6 +366,9 @@ public class AccessorProperty extends Property { } private MethodHandle generateSetter(final Class forType, final Class type) { + if (isSpill() && objectSetter == null) { + objectSetter = getSpillSetter(); + } MethodHandle mh = createSetter(forType, type, primitiveSetter, objectSetter); mh = MH.asType(mh, ACCESSOR_SETTER_TYPES[getAccessorTypeIndex(type)]); //has to be the case for invokeexact to work in ScriptObject mh = debug(mh, currentType, type, "set"); @@ -343,7 +399,7 @@ public class AccessorProperty extends Property { mh = generateSetter(forType, type); } - return isSpill() ? MH.filterArguments(mh, 0, SPILLGETTER) : mh; + return mh; } @Override @@ -363,6 +419,30 @@ public class AccessorProperty extends Property { setCurrentType(newType); } + private MethodHandle getSpillGetter() { + final int slot = getSlot(); + MethodHandle getter = slot < SPILL_CACHE_SIZE ? SPILL_ACCESSORS[slot * 2] : null; + if (getter == null) { + getter = MH.asType(MH.insertArguments(SPILL_ELEMENT_GETTER, 1, slot), Lookup.GET_OBJECT_TYPE); + if (slot < SPILL_CACHE_SIZE) { + SPILL_ACCESSORS[slot * 2] = getter; + } + } + return getter; + } + + private MethodHandle getSpillSetter() { + final int slot = getSlot(); + MethodHandle setter = slot < SPILL_CACHE_SIZE ? SPILL_ACCESSORS[slot * 2 + 1] : null; + if (setter == null) { + setter = MH.asType(MH.insertArguments(SPILL_ELEMENT_SETTER, 1, slot), Lookup.SET_OBJECT_TYPE); + if (slot < SPILL_CACHE_SIZE) { + SPILL_ACCESSORS[slot * 2 + 1] = setter; + } + } + return setter; + } + private static void finest(final String str) { if (DEBUG_FIELDS) { LOG.finest(str); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/FindProperty.java b/nashorn/src/jdk/nashorn/internal/runtime/FindProperty.java index 903d1d5d524..16165fe9caa 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/FindProperty.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/FindProperty.java @@ -153,5 +153,24 @@ public final class FindProperty { return prototype.isScope(); } + /** + * Get the property value from self as object. + * + * @return the property value + */ + public Object getObjectValue() { + return property.getObjectValue(getGetterReceiver(), getOwner()); + } + + /** + * Set the property value in self. + * + * @param value the new value + * @param strict strict flag + */ + public void setObjectValue(final Object value, final boolean strict) { + property.setObjectValue(getSetterReceiver(), getOwner(), value, strict); + } + } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Property.java b/nashorn/src/jdk/nashorn/internal/runtime/Property.java index 585fc4b3113..6441b8c4f41 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Property.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Property.java @@ -351,6 +351,26 @@ public abstract class Property { return slot; } + /** + * Set the value of this property in {@code owner}. This allows to bypass creation of the + * setter MethodHandle for spill and user accessor properties. + * + * @param self the this object + * @param owner the owner object + * @param value the new property value + */ + protected abstract void setObjectValue(ScriptObject self, ScriptObject owner, Object value, boolean strict); + + /** + * Set the Object value of this property from {@code owner}. This allows to bypass creation of the + * getter MethodHandle for spill and user accessor properties. + * + * @param self the this object + * @param owner the owner object + * @return the property value + */ + protected abstract Object getObjectValue(ScriptObject self, ScriptObject owner); + /** * Abstract method for retrieving the setter for the property. We do not know * anything about the internal representation when we request the setter, we only diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java index 61cce7b127a..cf89c545f98 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java @@ -25,7 +25,6 @@ package jdk.nashorn.internal.runtime; -import static jdk.nashorn.internal.codegen.CompilerConstants.staticCall; import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCall; import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup; import static jdk.nashorn.internal.lookup.Lookup.MH; @@ -151,17 +150,6 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr /** Method handle for setting the user accessors of a ScriptObject */ public static final Call SET_USER_ACCESSORS = virtualCall(ScriptObject.class, "setUserAccessors", void.class, String.class, ScriptFunction.class, ScriptFunction.class); - /** Method handle for getter for {@link UserAccessorProperty}, given a slot */ - static final Call USER_ACCESSOR_GETTER = staticCall(MethodHandles.lookup(), ScriptObject.class, "userAccessorGetter", Object.class, ScriptObject.class, int.class, Object.class); - - /** Method handle for setter for {@link UserAccessorProperty}, given a slot */ - static final Call USER_ACCESSOR_SETTER = staticCall(MethodHandles.lookup(), ScriptObject.class, "userAccessorSetter", void.class, ScriptObject.class, int.class, String.class, Object.class, Object.class); - - private static final MethodHandle INVOKE_UA_GETTER = Bootstrap.createDynamicInvoker("dyn:call", Object.class, - Object.class, Object.class); - private static final MethodHandle INVOKE_UA_SETTER = Bootstrap.createDynamicInvoker("dyn:call", void.class, - Object.class, Object.class, Object.class); - /** * Constructor */ @@ -699,17 +687,9 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr * @return New property. */ public final Property addOwnProperty(final String key, final int propertyFlags, final Object value) { - final MethodHandle setter = addSpill(key, propertyFlags); - - try { - setter.invokeExact((Object)this, value); - } catch (final Error|RuntimeException e) { - throw e; - } catch (final Throwable e) { - throw new RuntimeException(e); - } - - return getMap().findProperty(key); + final Property property = addSpillProperty(key, propertyFlags); + property.setObjectValue(this, this, value, false); + return property; } /** @@ -744,15 +724,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr // Erase the property field value with undefined. If the property is defined // by user-defined accessors, we don't want to call the setter!! if (!(property instanceof UserAccessorProperty)) { - try { - // make the property value to be undefined - //TODO specproperties - property.getSetter(Object.class, getMap()).invokeExact((Object)this, (Object)UNDEFINED); - } catch (final RuntimeException | Error e) { - throw e; - } catch (final Throwable t) { - throw new RuntimeException(t); - } + property.setObjectValue(this, this, UNDEFINED, false); } } @@ -948,18 +920,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr * @return the value of the property */ protected static Object getObjectValue(final FindProperty find) { - final MethodHandle getter = find.getGetter(Object.class); - if (getter != null) { - try { - return getter.invokeExact((Object)find.getGetterReceiver()); - } catch (final Error|RuntimeException e) { - throw e; - } catch (final Throwable e) { - throw new RuntimeException(e); - } - } - - return UNDEFINED; + return find.getObjectValue(); } /** @@ -2087,11 +2048,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr property = addOwnProperty(property); } else { int i = getMap().getSpillLength(); - MethodHandle getter = MH.arrayElementGetter(Object[].class); - MethodHandle setter = MH.arrayElementSetter(Object[].class); - getter = MH.asType(MH.insertArguments(getter, 1, i), Lookup.GET_OBJECT_TYPE); - setter = MH.asType(MH.insertArguments(setter, 1, i), Lookup.SET_OBJECT_TYPE); - property = new AccessorProperty(key, propertyFlags | Property.IS_SPILL, i, getter, setter); + property = new AccessorProperty(key, propertyFlags | Property.IS_SPILL, i); notifyPropertyAdded(this, property); property = addOwnProperty(property); i = property.getSlot(); @@ -2115,20 +2072,15 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr /** * Add a spill entry for the given key. - * @param key Property key. - * @param propertyFlags Property flags. + * @param key Property key. * @return Setter method handle. */ - private MethodHandle addSpill(final String key, final int propertyFlags) { - final Property spillProperty = addSpillProperty(key, propertyFlags); + MethodHandle addSpill(final String key) { + final Property spillProperty = addSpillProperty(key, 0); final Class type = Object.class; return spillProperty.getSetter(type, getMap()); //TODO specfields } - MethodHandle addSpill(final String key) { - return addSpill(key, 0); - } - /** * Make sure arguments are paired correctly, with respect to more parameters than declared, * fewer parameters than declared and other things that JavaScript allows. This might involve @@ -2659,14 +2611,8 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return; } - try { - final MethodHandle setter = f.getSetter(Object.class, strict); //TODO specfields - setter.invokeExact((Object)f.getSetterReceiver(), value); - } catch (final Error|RuntimeException e) { - throw e; - } catch (final Throwable e) { - throw new RuntimeException(e); - } + f.setObjectValue(value, strict); + } else if (!isExtensible()) { if (strict) { throw typeError("object.non.extensible", key, ScriptRuntime.safeToString(this)); @@ -2677,13 +2623,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr } private void spill(final String key, final Object value) { - try { - addSpill(key).invokeExact((Object)this, value); - } catch (final Error|RuntimeException e) { - throw e; - } catch (final Throwable e) { - throw new RuntimeException(e); - } + addSpillProperty(key, 0).setObjectValue(this, this, value, false); } @@ -3217,46 +3157,6 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return (index < 0 || (index >= spill.length)) ? null : spill[index]; } - // User defined getter and setter are always called by "dyn:call". Note that the user - // getter/setter may be inherited. If so, proto is bound during lookup. In either - // inherited or self case, slot is also bound during lookup. Actual ScriptFunction - // to be called is retrieved everytime and applied. - @SuppressWarnings("unused") - private static Object userAccessorGetter(final ScriptObject proto, final int slot, final Object self) { - final ScriptObject container = (proto != null) ? proto : (ScriptObject)self; - final Object func = container.getSpill(slot); - - if (func instanceof ScriptFunction) { - try { - return INVOKE_UA_GETTER.invokeExact(func, self); - } catch(final Error|RuntimeException t) { - throw t; - } catch(final Throwable t) { - throw new RuntimeException(t); - } - } - - return UNDEFINED; - } - - @SuppressWarnings("unused") - private static void userAccessorSetter(final ScriptObject proto, final int slot, final String name, final Object self, final Object value) { - final ScriptObject container = (proto != null) ? proto : (ScriptObject)self; - final Object func = container.getSpill(slot); - - if (func instanceof ScriptFunction) { - try { - INVOKE_UA_SETTER.invokeExact(func, self, value); - } catch(final Error|RuntimeException t) { - throw t; - } catch(final Throwable t) { - throw new RuntimeException(t); - } - } else if (name != null) { - throw typeError("property.has.no.setter", name, ScriptRuntime.safeToString(self)); - } - } - private static MethodHandle findOwnMH(final String name, final Class rtype, final Class... types) { final Class own = ScriptObject.class; final MethodType mt = MH.type(rtype, types); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/SetMethodCreator.java b/nashorn/src/jdk/nashorn/internal/runtime/SetMethodCreator.java index 5ff321fc9a0..a6dfce0f5fd 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/SetMethodCreator.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/SetMethodCreator.java @@ -183,17 +183,10 @@ final class SetMethodCreator { private SetMethod createNewSpillPropertySetter() { final int nextSpill = getMap().getSpillLength(); - final Property property = createSpillProperty(nextSpill); + final Property property = new AccessorProperty(getName(), Property.IS_SPILL, nextSpill); return new SetMethod(createSpillMethodHandle(nextSpill, property), property); } - private Property createSpillProperty(final int nextSpill) { - final MethodHandle getter = MH.asType(MH.insertArguments(MH.arrayElementGetter(Object[].class), 1, nextSpill), Lookup.GET_OBJECT_TYPE); - final MethodHandle setter = MH.asType(MH.insertArguments(MH.arrayElementSetter(Object[].class), 1, nextSpill), Lookup.SET_OBJECT_TYPE); - - return new AccessorProperty(getName(), Property.IS_SPILL, nextSpill, getter, setter); - } - private MethodHandle createSpillMethodHandle(final int nextSpill, Property property) { final PropertyMap oldMap = getMap(); final PropertyMap newMap = getNewMap(property); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java b/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java index 75c285a6fc8..fac505ceff5 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java @@ -26,7 +26,15 @@ package jdk.nashorn.internal.runtime; import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; + +import jdk.nashorn.internal.codegen.CompilerConstants; import jdk.nashorn.internal.lookup.Lookup; +import jdk.nashorn.internal.runtime.linker.Bootstrap; + +import static jdk.nashorn.internal.codegen.CompilerConstants.staticCall; +import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; +import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; /** * Property with user defined getters/setters. Actual getter and setter @@ -51,6 +59,22 @@ public final class UserAccessorProperty extends Property { /** User defined setter function slot. */ private final int setterSlot; + /** Getter method handle */ + private final static CompilerConstants.Call USER_ACCESSOR_GETTER = staticCall(MethodHandles.lookup(), UserAccessorProperty.class, + "userAccessorGetter", Object.class, ScriptObject.class, int.class, Object.class); + + /** Setter method handle */ + private final static CompilerConstants.Call USER_ACCESSOR_SETTER = staticCall(MethodHandles.lookup(), UserAccessorProperty.class, + "userAccessorSetter", void.class, ScriptObject.class, int.class, String.class, Object.class, Object.class); + + /** Dynamic invoker for getter */ + private static final MethodHandle INVOKE_UA_GETTER = Bootstrap.createDynamicInvoker("dyn:call", Object.class, + Object.class, Object.class); + + /** Dynamic invoker for setter */ + private static final MethodHandle INVOKE_UA_SETTER = Bootstrap.createDynamicInvoker("dyn:call", void.class, + Object.class, Object.class, Object.class); + /** * Constructor * @@ -133,9 +157,19 @@ public final class UserAccessorProperty extends Property { return setterSlot > -1; } + @Override + protected Object getObjectValue(final ScriptObject self, final ScriptObject owner) { + return userAccessorGetter(owner, getGetterSlot(), self); + } + + @Override + protected void setObjectValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict) { + userAccessorSetter(owner, getSetterSlot(), strict ? getKey() : null, self, value); + } + @Override public MethodHandle getGetter(final Class type) { - return Lookup.filterReturnType(ScriptObject.USER_ACCESSOR_GETTER.methodHandle(), type); + return Lookup.filterReturnType(USER_ACCESSOR_GETTER.methodHandle(), type); } @Override @@ -146,7 +180,7 @@ public final class UserAccessorProperty extends Property { @Override public MethodHandle getSetter(final Class type, final PropertyMap currentMap) { - return ScriptObject.USER_ACCESSOR_SETTER.methodHandle(); + return USER_ACCESSOR_SETTER.methodHandle(); } @Override @@ -155,4 +189,44 @@ public final class UserAccessorProperty extends Property { return (value instanceof ScriptFunction) ? (ScriptFunction) value : null; } + // User defined getter and setter are always called by "dyn:call". Note that the user + // getter/setter may be inherited. If so, proto is bound during lookup. In either + // inherited or self case, slot is also bound during lookup. Actual ScriptFunction + // to be called is retrieved everytime and applied. + @SuppressWarnings("unused") + static Object userAccessorGetter(final ScriptObject proto, final int slot, final Object self) { + final ScriptObject container = (proto != null) ? proto : (ScriptObject)self; + final Object func = container.getSpill(slot); + + if (func instanceof ScriptFunction) { + try { + return INVOKE_UA_GETTER.invokeExact(func, self); + } catch(final Error|RuntimeException t) { + throw t; + } catch(final Throwable t) { + throw new RuntimeException(t); + } + } + + return UNDEFINED; + } + + @SuppressWarnings("unused") + static void userAccessorSetter(final ScriptObject proto, final int slot, final String name, final Object self, final Object value) { + final ScriptObject container = (proto != null) ? proto : (ScriptObject)self; + final Object func = container.getSpill(slot); + + if (func instanceof ScriptFunction) { + try { + INVOKE_UA_SETTER.invokeExact(func, self, value); + } catch(final Error|RuntimeException t) { + throw t; + } catch(final Throwable t) { + throw new RuntimeException(t); + } + } else if (name != null) { + throw typeError("property.has.no.setter", name, ScriptRuntime.safeToString(self)); + } + } + } From f86162c90c62fe002c7760f1d1afe03812cdcd4d Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Fri, 24 May 2013 18:39:25 +0530 Subject: [PATCH 048/206] 8015354: JSON.parse should not use [[Put]] but use [[DefineOwnProperty]] instead Reviewed-by: lagergren, hannesw --- .../internal/objects/NativeFloat32Array.java | 3 ++ .../internal/objects/NativeFloat64Array.java | 3 ++ .../internal/objects/NativeInt16Array.java | 3 ++ .../internal/objects/NativeInt32Array.java | 3 ++ .../internal/objects/NativeInt8Array.java | 3 ++ .../internal/objects/NativeUint16Array.java | 3 ++ .../internal/objects/NativeUint32Array.java | 3 ++ .../internal/objects/NativeUint8Array.java | 3 ++ .../objects/NativeUint8ClampedArray.java | 3 ++ .../internal/runtime/JSONFunctions.java | 25 ++++++++-- .../nashorn/internal/runtime/Property.java | 2 + nashorn/test/script/basic/JDK-8015354.js | 46 +++++++++++++++++++ 12 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8015354.js diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java index 33d2d9ecc5d..d59a4d6fdb9 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java @@ -40,6 +40,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Float32Array") public final class NativeFloat32Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) public static final int BYTES_PER_ELEMENT = 4; diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java index ba6bffe8c38..0f10a867d81 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java @@ -40,6 +40,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Float64Array") public final class NativeFloat64Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) public static final int BYTES_PER_ELEMENT = 8; diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java index 9afaf3a7ea0..d6c5349efd5 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java @@ -39,6 +39,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Int16Array") public final class NativeInt16Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) public static final int BYTES_PER_ELEMENT = 2; diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java index 199d223d25d..a814eb61de1 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java @@ -39,6 +39,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Int32Array") public final class NativeInt32Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) public static final int BYTES_PER_ELEMENT = 4; diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java index 25e86c23d35..ec43bfc8e18 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java @@ -39,6 +39,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Int8Array") public final class NativeInt8Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) public static final int BYTES_PER_ELEMENT = 1; diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java index ec5e99d3718..13ce347461e 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java @@ -39,6 +39,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Uint16Array") public final class NativeUint16Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) public static final int BYTES_PER_ELEMENT = 2; diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java index d8a3f5240f4..fb45c2821be 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java @@ -40,6 +40,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Uint32Array") public final class NativeUint32Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) public static final int BYTES_PER_ELEMENT = 4; diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java index d62818a912b..6cebcdb9c5f 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java @@ -39,6 +39,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Uint8Array") public final class NativeUint8Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) public static final int BYTES_PER_ELEMENT = 1; diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java index 7eb3e650714..de171caa8a4 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java @@ -40,6 +40,9 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData; */ @ScriptClass("Uint8ClampedArray") public final class NativeUint8ClampedArray extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) public static final int BYTES_PER_ELEMENT = 1; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/JSONFunctions.java b/nashorn/src/jdk/nashorn/internal/runtime/JSONFunctions.java index 6106a314da2..ed4d8653425 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/JSONFunctions.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/JSONFunctions.java @@ -36,6 +36,8 @@ import jdk.nashorn.internal.ir.UnaryNode; import jdk.nashorn.internal.parser.JSONParser; import jdk.nashorn.internal.parser.TokenType; import jdk.nashorn.internal.runtime.linker.Bootstrap; +import static jdk.nashorn.internal.runtime.arrays.ArrayIndex.getArrayIndexNoThrow; +import static jdk.nashorn.internal.runtime.arrays.ArrayIndex.isValidArrayIndex; /** * Utilities used by "JSON" object implementation. @@ -94,7 +96,7 @@ public final class JSONFunctions { if (reviver instanceof ScriptFunction) { assert global instanceof GlobalObject; final ScriptObject root = ((GlobalObject)global).newObject(); - root.set("", unfiltered, root.isStrictContext()); + root.addOwnProperty("", Property.WRITABLE_ENUMERABLE_CONFIGURABLE, unfiltered); return walk(root, "", (ScriptFunction)reviver); } return unfiltered; @@ -115,7 +117,7 @@ public final class JSONFunctions { if (newElement == ScriptRuntime.UNDEFINED) { valueObj.delete(key, strict); } else { - valueObj.set(key, newElement, strict); + setPropertyValue(valueObj, key, newElement, strict); } } } @@ -175,7 +177,9 @@ public final class JSONFunctions { final PropertyNode pNode = (PropertyNode) elem; final Node valueNode = pNode.getValue(); - object.set(pNode.getKeyName(), convertNode(global, valueNode), strict); + final String name = pNode.getKeyName(); + final Object value = convertNode(global, valueNode); + setPropertyValue(object, name, value, strict); } return object; @@ -188,6 +192,21 @@ public final class JSONFunctions { } } + // add a new property if does not exist already, or else set old property + private static void setPropertyValue(final ScriptObject sobj, final String name, final Object value, final boolean strict) { + final int index = getArrayIndexNoThrow(name); + if (isValidArrayIndex(index)) { + // array index key + sobj.defineOwnProperty(index, value); + } else if (sobj.getMap().findProperty(name) != null) { + // pre-existing non-inherited property, call set + sobj.set(name, value, strict); + } else { + // add new property + sobj.addOwnProperty(name, Property.WRITABLE_ENUMERABLE_CONFIGURABLE, value); + } + } + // does the given IR node represent a numeric array? private static boolean isNumericArray(final Node[] values) { for (final Node node : values) { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Property.java b/nashorn/src/jdk/nashorn/internal/runtime/Property.java index 6441b8c4f41..433bc2c3048 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Property.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Property.java @@ -52,6 +52,8 @@ public abstract class Property { * we can use leave flag byte initialized with (the default) zero value. */ + public static final int WRITABLE_ENUMERABLE_CONFIGURABLE = 0b0000_0000_0000; + /** ECMA 8.6.1 - Is this property not writable? */ public static final int NOT_WRITABLE = 0b0000_0000_0001; diff --git a/nashorn/test/script/basic/JDK-8015354.js b/nashorn/test/script/basic/JDK-8015354.js new file mode 100644 index 00000000000..3cbe676e8b9 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015354.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8015354: JSON.parse should not use [[Put]] but use [[DefineOwnProperty]] instead + * + * @test + * @run + */ + +Object.defineProperty(Object.prototype, + "", { + set: function(v) { + throw "set called"; + } +}); + +JSON.parse('{}',function(){}); + +Object.defineProperty(Object.prototype, + "foo",{ + set: function(v) { + throw "set called"; + } +}); +JSON.parse('{"foo": 1}'); From 372fabc4763c2f59ce2fbe4045b9c15fdd44102d Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 24 May 2013 15:26:57 +0100 Subject: [PATCH 049/206] 8014643: Parser regression in JDK 8 when compiling super.x Fixed latent bug in JavacParser.analyzeParens() Reviewed-by: jjg, vromero --- .../sun/tools/javac/parser/JavacParser.java | 11 ++++- .../tools/javac/parser/8014643/T8014643.java | 41 +++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 langtools/test/tools/javac/parser/8014643/T8014643.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java index bdd79d04392..5b5ba0bb3f3 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -1535,11 +1535,18 @@ public class JavacParser implements Parser { outer: for (int lookahead = 0 ; ; lookahead++) { TokenKind tk = S.token(lookahead).kind; switch (tk) { - case EXTENDS: case SUPER: case COMMA: + case COMMA: type = true; - case QUES: case DOT: case AMP: + case EXTENDS: case SUPER: case DOT: case AMP: //skip break; + case QUES: + if (peekToken(lookahead, EXTENDS) || + peekToken(lookahead, SUPER)) { + //wildcards + type = true; + } + break; case BYTE: case SHORT: case INT: case LONG: case FLOAT: case DOUBLE: case BOOLEAN: case CHAR: if (peekToken(lookahead, RPAREN)) { diff --git a/langtools/test/tools/javac/parser/8014643/T8014643.java b/langtools/test/tools/javac/parser/8014643/T8014643.java new file mode 100644 index 00000000000..ab4eaf2c99c --- /dev/null +++ b/langtools/test/tools/javac/parser/8014643/T8014643.java @@ -0,0 +1,41 @@ +/* + * 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 8014643 + * @summary Parser regression in JDK 8 when compiling super.x + * @compile T8014643.java + */ +class T8014643 { + + static class A { + int b = 1; + } + + static class B extends A { + int b = 12; + + int m() { return (super.b); } + } +} From 9d588c1a23d9eb6d779c052e9f5c68efc7216226 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 24 May 2013 15:27:12 +0100 Subject: [PATCH 050/206] 8014649: Regression: bug in Resolve.resolveOperator Missing curly braces causes Resolve.findMethod to be called spuriously Reviewed-by: jjg, vromero --- .../com/sun/tools/javac/comp/Resolve.java | 32 +++++---- .../tools/javac/resolve/ResolveHarness.java | 49 +++++++++++-- .../resolve/tests/PrimitiveBinopOverload.java | 71 +++++++++++++++++++ 3 files changed, 134 insertions(+), 18 deletions(-) create mode 100644 langtools/test/tools/javac/resolve/tests/PrimitiveBinopOverload.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index de949a7a243..09b1d4c92f2 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -1343,7 +1343,7 @@ public class Resolve { try { Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes, allowBoxing, useVarargs, types.noWarnings); - if (!operator) + if (!operator || verboseResolutionMode.contains(VerboseResolutionMode.PREDEF)) currentResolutionContext.addApplicableCandidate(sym, mt); } catch (InapplicableMethodException ex) { if (!operator) @@ -2500,17 +2500,21 @@ public class Resolve { try { currentResolutionContext = new MethodResolutionContext(); Name name = treeinfo.operatorName(optag); - env.info.pendingResolutionPhase = currentResolutionContext.step = BASIC; - Symbol sym = findMethod(env, syms.predefClass.type, name, argtypes, - null, false, false, true); - if (boxingEnabled && sym.kind >= WRONG_MTHS) - env.info.pendingResolutionPhase = currentResolutionContext.step = BOX; - sym = findMethod(env, syms.predefClass.type, name, argtypes, - null, true, false, true); - return accessMethod(sym, pos, env.enclClass.sym.type, name, + return lookupMethod(env, pos, syms.predefClass, currentResolutionContext, + new BasicLookupHelper(name, syms.predefClass.type, argtypes, null, BOX) { + @Override + Symbol lookup(Env env, MethodResolutionPhase phase) { + return findMethod(env, site, name, argtypes, typeargtypes, + phase.isBoxingRequired(), + phase.isVarargsRequired(), true); + } + @Override + Symbol access(Env env, DiagnosticPosition pos, Symbol location, Symbol sym) { + return accessMethod(sym, pos, env.enclClass.sym.type, name, false, argtypes, null); - } - finally { + } + }); + } finally { currentResolutionContext = prevResolutionContext; } } @@ -2673,7 +2677,11 @@ public class Resolve { abstract class BasicLookupHelper extends LookupHelper { BasicLookupHelper(Name name, Type site, List argtypes, List typeargtypes) { - super(name, site, argtypes, typeargtypes, MethodResolutionPhase.VARARITY); + this(name, site, argtypes, typeargtypes, MethodResolutionPhase.VARARITY); + } + + BasicLookupHelper(Name name, Type site, List argtypes, List typeargtypes, MethodResolutionPhase maxPhase) { + super(name, site, argtypes, typeargtypes, maxPhase); } @Override diff --git a/langtools/test/tools/javac/resolve/ResolveHarness.java b/langtools/test/tools/javac/resolve/ResolveHarness.java index b9998f05eeb..8db063cdf09 100644 --- a/langtools/test/tools/javac/resolve/ResolveHarness.java +++ b/langtools/test/tools/javac/resolve/ResolveHarness.java @@ -43,6 +43,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.annotation.processing.AbstractProcessor; @@ -85,6 +86,7 @@ public class ResolveHarness implements javax.tools.DiagnosticListener declaredKeys = new HashSet<>(); List> diags = new ArrayList<>(); List seenCandidates = new ArrayList<>(); + Map predefTranslationMap = new HashMap<>(); protected ResolveHarness(JavaFileObject jfo) { this.jfo = jfo; @@ -93,12 +95,36 @@ public class ResolveHarness implements javax.tools.DiagnosticListener>", "_rshift"); + predefTranslationMap.put("<<<", "_lshiftshift"); + predefTranslationMap.put(">>>", "_rshiftshift"); + predefTranslationMap.put("<", "_lt"); + predefTranslationMap.put(">", "_gt"); + predefTranslationMap.put("<=", "_lteq"); + predefTranslationMap.put(">=", "_gteq"); + predefTranslationMap.put("==", "_eq"); + predefTranslationMap.put("!=", "_neq"); + predefTranslationMap.put("&&", "_andand"); + predefTranslationMap.put("||", "_oror"); } protected void check() throws Exception { String[] options = { "-XDshouldStopPolicy=ATTR", - "-XDverboseResolution=success,failure,applicable,inapplicable,deferred-inference" + "-XDverboseResolution=success,failure,applicable,inapplicable,deferred-inference,predef" }; AbstractProcessor[] processors = { new ResolveCandidateFinder(), null }; @@ -223,7 +249,8 @@ public class ResolveHarness implements javax.tools.DiagnosticListener diagnostic) { Element siteSym = getSiteSym(diagnostic); - if (siteSym.getAnnotation(TraceResolve.class) == null) { + if (siteSym.getSimpleName().length() != 0 && + siteSym.getAnnotation(TraceResolve.class) == null) { return; } int candidateIdx = 0; @@ -307,7 +334,7 @@ public class ResolveHarness implements javax.tools.DiagnosticListener."); + String replacedName = predefTranslationMap.get(e.getSimpleName().toString()); + buf.append(e.toString().replace(e.getSimpleName().toString(), replacedName)); + } else if (e.getSimpleName().toString().startsWith("_")) { + buf.append("."); buf.append(e.toString()); - e = e.getEnclosingElement(); + } else { + while (e != null) { + buf.append(e.toString()); + e = e.getEnclosingElement(); + } + buf.append(jfo.getName()); } - buf.append(jfo.getName()); return buf.toString(); } diff --git a/langtools/test/tools/javac/resolve/tests/PrimitiveBinopOverload.java b/langtools/test/tools/javac/resolve/tests/PrimitiveBinopOverload.java new file mode 100644 index 00000000000..a66da7e8670 --- /dev/null +++ b/langtools/test/tools/javac/resolve/tests/PrimitiveBinopOverload.java @@ -0,0 +1,71 @@ +/* + * 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. + */ + +@TraceResolve +class PrimitiveBinopOverload { + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + int _plus(int x, int y) { return -1; } + @Candidate(applicable=Phase.BASIC) + long _plus(long x, long y) { return -1; } + @Candidate(applicable=Phase.BASIC) + float _plus(float x, float y) { return -1; } + @Candidate(applicable=Phase.BASIC) + double _plus(double x, double y) { return -1; } + //not a candidate + Object _plus(Object x, Object y) { return -1; } + + @Candidate(applicable= { Phase.BASIC, Phase.BOX }, mostSpecific=true) + int _minus(int x, int y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + long _minus(long x, long y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + float _minus(float x, float y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + double _minus(double x, double y) { return -1; } + + @Candidate(applicable= { Phase.BASIC, Phase.BOX }, mostSpecific=true) + int _mul(int x, int y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + long _mul(long x, long y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + float _mul(float x, float y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + double _mul(double x, double y) { return -1; } + + @Candidate(applicable= { Phase.BASIC, Phase.BOX }, mostSpecific=true) + int _div(int x, int y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + long _div(long x, long y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + float _div(float x, float y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + double _div(double x, double y) { return -1; } + + { + int i1 = 1 + 1; + int i2 = 5 - new Integer(3); + int i3 = new Integer(5) * 3; + int i4 = new Integer(6) / new Integer(2); + } +} From d176f2abdf9b99693e80996dc4742faee1d820be Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 24 May 2013 15:27:27 +0100 Subject: [PATCH 051/206] 8014494: javac crashes when varargs element of a method reference is inferred from the context Varargs element is not refreshed after type-inference Reviewed-by: jjg, vromero --- .../com/sun/tools/javac/comp/Attr.java | 2 +- .../com/sun/tools/javac/comp/Check.java | 16 ++++++- .../test/tools/javac/lambda/TargetType73.java | 47 +++++++++++++++++++ 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 langtools/test/tools/javac/lambda/TargetType73.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index bff462f8f29..98195d2622a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -3732,7 +3732,7 @@ public class Attr extends JCTree.Visitor { noteWarner); return chk.checkMethod(owntype, sym, env, argtrees, argtypes, env.info.lastResolveVarargs(), - noteWarner.hasNonSilentLint(LintCategory.UNCHECKED)); + noteWarner.hasNonSilentLint(LintCategory.UNCHECKED), resultInfo.checkContext.inferenceContext()); } catch (Infer.InferenceException ex) { //invalid target type - propagate exception outwards or report error //depending on the current check context diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index cd550d6edaf..dad29a3a016 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -853,7 +853,8 @@ public class Check { final List argtrees, List argtypes, boolean useVarargs, - boolean unchecked) { + boolean unchecked, + InferenceContext inferenceContext) { // System.out.println("call : " + env.tree); // System.out.println("method : " + owntype); // System.out.println("actuals: " + argtypes); @@ -917,7 +918,7 @@ public class Check { argtype); } if (!((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types)) { - TreeInfo.setVarargsElement(env.tree, types.elemtype(argtype)); + setVarargsElement(env, types.elemtype(argtype), inferenceContext); } } PolyKind pkind = (sym.type.hasTag(FORALL) && @@ -927,6 +928,17 @@ public class Check { return owntype; } //where + private void setVarargsElement(final Env env, final Type elemtype, InferenceContext inferenceContext) { + if (inferenceContext.free(elemtype)) { + inferenceContext.addFreeTypeListener(List.of(elemtype), new FreeTypeListener() { + public void typesInferred(InferenceContext inferenceContext) { + setVarargsElement(env, inferenceContext.asInstType(elemtype), inferenceContext); + } + }); + } + TreeInfo.setVarargsElement(env.tree, elemtype); + } + private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) { if (types.isConvertible(actual, formal, warn)) return; diff --git a/langtools/test/tools/javac/lambda/TargetType73.java b/langtools/test/tools/javac/lambda/TargetType73.java new file mode 100644 index 00000000000..36e5684387d --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType73.java @@ -0,0 +1,47 @@ +/* + * 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 8014494 + * @summary javac crashes when varargs element of a method reference is inferred from the context + * @compile TargetType73.java + */ +import java.util.List; + +class TargetType73 { + + interface Function { + Y m(X x); + } + + static void test() { + m(TargetType73::g); + } + + public static List g(T... a) { + return null; + } + + public static void m(Function zipper) { } +} From ddea5b012c37425c1e8d0c97f01c400d733807d0 Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Fri, 24 May 2013 09:35:10 -0700 Subject: [PATCH 052/206] 8015305: new hotspot build - hs25-b35 Reviewed-by: jcoomes --- hotspot/make/hotspot_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/make/hotspot_version b/hotspot/make/hotspot_version index db74b20d81b..815215f44ec 100644 --- a/hotspot/make/hotspot_version +++ b/hotspot/make/hotspot_version @@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2013 HS_MAJOR_VER=25 HS_MINOR_VER=0 -HS_BUILD_NUMBER=34 +HS_BUILD_NUMBER=35 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 From 5bf7dac8d724820cbf61c2e4f41c9d30e9159ab3 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Fri, 24 May 2013 23:27:52 +0530 Subject: [PATCH 053/206] 8015351: Nashorn shell does not start with Turkish locale Reviewed-by: jlaskey --- nashorn/make/project.properties | 6 +++++- .../nashorn/internal/runtime/options/OptionTemplate.java | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties index 9ed8125e14a..839d7486c72 100644 --- a/nashorn/make/project.properties +++ b/nashorn/make/project.properties @@ -214,9 +214,13 @@ test.src.dir=test/src run.test.xmx=3G run.test.xms=2G +run.test.user.language=tr +run.test.user.country=TR + # -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMethods # add '-Dtest.js.outofprocess' to run each test in a new sub-process -run.test.jvmargs.main=-server -Xmx${run.test.xmx} -XX:+TieredCompilation -ea -Dfile.encoding=UTF-8 +run.test.jvmargs.main=-server -Xmx${run.test.xmx} -XX:+TieredCompilation -ea -Dfile.encoding=UTF-8 -Duser.language=${run.test.user.language} -Duser.country=${run.test.user.country} + #-XX:+HeapDumpOnOutOfMemoryError -XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M run.test.jvmargs.octane.main=-Xms${run.test.xms} ${run.test.jvmargs.main} diff --git a/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java b/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java index 16ff04eaa41..30e0401e62e 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java @@ -25,6 +25,7 @@ package jdk.nashorn.internal.runtime.options; +import java.util.Locale; import java.util.TimeZone; import jdk.nashorn.internal.runtime.QuotedStringTokenizer; @@ -263,7 +264,7 @@ public class OptionTemplate implements Comparable { this.params = arg; break; case "type": - this.type = arg.toLowerCase(); + this.type = arg.toLowerCase(Locale.ROOT); break; case "default": this.defaultValue = arg; From b4854e299c08c660d2b29188ade282db80ab768d Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Fri, 24 May 2013 11:26:17 -0700 Subject: [PATCH 054/206] 8014836: Have GenericDeclaration extend AnnotatedElement Reviewed-by: jfranck --- .../language/model/CoreReflectionFactory.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/langtools/src/share/sample/language/model/CoreReflectionFactory.java b/langtools/src/share/sample/language/model/CoreReflectionFactory.java index e51cff74ee0..033765f2667 100644 --- a/langtools/src/share/sample/language/model/CoreReflectionFactory.java +++ b/langtools/src/share/sample/language/model/CoreReflectionFactory.java @@ -439,15 +439,11 @@ public class CoreReflectionFactory { ReflectionElement getGenericElement(); // Functionality specific to the specialization - - // Conceptually should have an override for getSource - // returning GenericDeclaration, but GenericDeclaration - // doesn't currently implement AnnotatedElement. -// /** -// * {@inheritDoc} -// */ -// @Override -// java.lang.reflect.GenericDeclaration getSource(); + /** + * {@inheritDoc} + */ + @Override + java.lang.reflect.TypeVariable getSource(); } /** @@ -1296,8 +1292,8 @@ public class CoreReflectionFactory { } @Override - public AnnotatedElement getSource() { - return (AnnotatedElement)source; + public java.lang.reflect.TypeVariable getSource() { + return sourceTypeVar; } protected java.lang.reflect.TypeVariable getSourceTypeVar() { From 7cb20773ad93f884d0398a4f11a3dd80089a02fc Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Fri, 24 May 2013 17:19:56 -0700 Subject: [PATCH 055/206] 8015265: revise the fix for 8007037 Reviewed-by: sspitsyn, dholmes, dcubed --- hotspot/src/share/vm/oops/constantPool.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/oops/constantPool.cpp b/hotspot/src/share/vm/oops/constantPool.cpp index 5c5ae945bda..fe1d7340e47 100644 --- a/hotspot/src/share/vm/oops/constantPool.cpp +++ b/hotspot/src/share/vm/oops/constantPool.cpp @@ -1063,9 +1063,10 @@ bool ConstantPool::compare_entry_to(int index1, constantPoolHandle cp2, int k2 = cp2->invoke_dynamic_name_and_type_ref_index_at(index2); int i1 = invoke_dynamic_bootstrap_specifier_index(index1); int i2 = cp2->invoke_dynamic_bootstrap_specifier_index(index2); - bool match = compare_entry_to(k1, cp2, k2, CHECK_false) && - compare_operand_to(i1, cp2, i2, CHECK_false); - return match; + // separate statements and variables because CHECK_false is used + bool match_entry = compare_entry_to(k1, cp2, k2, CHECK_false); + bool match_operand = compare_operand_to(i1, cp2, i2, CHECK_false); + return (match_entry && match_operand); } break; case JVM_CONSTANT_String: From fb0022c7b1d6a9f313451fe311aaed8e62b10583 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Fri, 24 May 2013 17:36:12 -0700 Subject: [PATCH 056/206] 8013945: CMS fatal error: must own lock MemberNameTable_lock The "delete mnt" needs to grab MemberNameTable_lock if !SafepointSynchronize::is_at_safepoint() Reviewed-by: sla, mgerdin, dholmes, jmasa --- hotspot/src/share/vm/oops/instanceKlass.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 562adaae04a..84f1cdd3e6d 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -2320,10 +2320,15 @@ void InstanceKlass::release_C_heap_structures() { FreeHeap(jmeths); } - MemberNameTable* mnt = member_names(); - if (mnt != NULL) { - delete mnt; - set_member_names(NULL); + // Deallocate MemberNameTable + { + Mutex* lock_or_null = SafepointSynchronize::is_at_safepoint() ? NULL : MemberNameTable_lock; + MutexLockerEx ml(lock_or_null, Mutex::_no_safepoint_check_flag); + MemberNameTable* mnt = member_names(); + if (mnt != NULL) { + delete mnt; + set_member_names(NULL); + } } int* indices = methods_cached_itable_indices_acquire(); From 6e76fe0cf24b111e99bcd4cf6efcd1284493eda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Mon, 27 May 2013 12:26:39 +0200 Subject: [PATCH 057/206] 8015348: RegExp("[") results in StackOverflowError Reviewed-by: sundar, attila --- .../runtime/regexp/RegExpScanner.java | 3 ++ nashorn/test/script/basic/JDK-8015348.js | 35 +++++++++++++++++++ .../test/script/basic/JDK-8015348.js.EXPECTED | 1 + 3 files changed, 39 insertions(+) create mode 100644 nashorn/test/script/basic/JDK-8015348.js create mode 100644 nashorn/test/script/basic/JDK-8015348.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java index 956a99d7cf4..52829fac099 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java @@ -868,6 +868,9 @@ final class RegExpScanner extends Scanner { * \ ClassEscape */ private boolean classAtomNoDash() { + if (atEOF()) { + return false; + } final int startIn = position; final int startOut = sb.length(); diff --git a/nashorn/test/script/basic/JDK-8015348.js b/nashorn/test/script/basic/JDK-8015348.js new file mode 100644 index 00000000000..77ff6031c56 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015348.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8015348: RegExp("[") results in StackOverflowError + * + * @test + * @run + */ + +try { + new RegExp('['); +} catch (error) { + print(error.name); +} diff --git a/nashorn/test/script/basic/JDK-8015348.js.EXPECTED b/nashorn/test/script/basic/JDK-8015348.js.EXPECTED new file mode 100644 index 00000000000..8729fc43437 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015348.js.EXPECTED @@ -0,0 +1 @@ +SyntaxError From 2ccd92e927b867586bc145495ed924c8eb85f676 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Mon, 27 May 2013 15:22:59 +0200 Subject: [PATCH 058/206] 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty Split SystemDictionary and ClassLoaderDataGraph root processing to help load balancing. Reviewed-by: tschatzl, johnc --- .../gc_implementation/parallelScavenge/pcTasks.cpp | 3 +++ .../gc_implementation/parallelScavenge/pcTasks.hpp | 3 ++- .../parallelScavenge/psParallelCompact.cpp | 1 + .../parallelScavenge/psScavenge.cpp | 1 + .../gc_implementation/parallelScavenge/psTasks.cpp | 13 +++++++------ .../gc_implementation/parallelScavenge/psTasks.hpp | 7 ++++--- hotspot/src/share/vm/memory/sharedHeap.cpp | 11 +++++++++-- 7 files changed, 27 insertions(+), 12 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp index ed91fe2588e..fa3cf7bccdc 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp @@ -120,6 +120,9 @@ void MarkFromRootsTask::do_it(GCTaskManager* manager, uint which) { case system_dictionary: SystemDictionary::always_strong_oops_do(&mark_and_push_closure); + break; + + case class_loader_data: ClassLoaderDataGraph::always_strong_oops_do(&mark_and_push_closure, &follow_klass_closure, true); break; diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp index c79bc7c3a14..f966ccf23e2 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp @@ -98,7 +98,8 @@ class MarkFromRootsTask : public GCTask { management = 6, jvmti = 7, system_dictionary = 8, - code_cache = 9 + class_loader_data = 9, + code_cache = 10 }; private: RootType _root_type; diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp index d85f5d3e486..3e649ddf702 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @@ -2338,6 +2338,7 @@ void PSParallelCompact::marking_phase(ParCompactionManager* cm, q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::flat_profiler)); q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::management)); q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::system_dictionary)); + q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::class_loader_data)); q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::jvmti)); q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::code_cache)); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp index 2a718e4bf6d..72d2df4b91f 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp @@ -408,6 +408,7 @@ bool PSScavenge::invoke_no_policy() { q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::flat_profiler)); q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::management)); q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::system_dictionary)); + q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::class_loader_data)); q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::jvmti)); q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::code_cache)); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp index ccad48f358b..00e466a3ea4 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp @@ -79,15 +79,16 @@ void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) { break; case system_dictionary: - { SystemDictionary::oops_do(&roots_closure); - - // Move this to another root_type? - PSScavengeKlassClosure klass_closure(pm); - ClassLoaderDataGraph::oops_do(&roots_closure, &klass_closure, false); - } break; + case class_loader_data: + { + PSScavengeKlassClosure klass_closure(pm); + ClassLoaderDataGraph::oops_do(&roots_closure, &klass_closure, false); + } + break; + case management: Management::oops_do(&roots_closure); break; diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.hpp index 7769fddf7c4..7ae1f8a0c28 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.hpp @@ -59,9 +59,10 @@ class ScavengeRootsTask : public GCTask { object_synchronizer = 4, flat_profiler = 5, system_dictionary = 6, - management = 7, - jvmti = 8, - code_cache = 9 + class_loader_data = 7, + management = 8, + jvmti = 9, + code_cache = 10 }; private: RootType _root_type; diff --git a/hotspot/src/share/vm/memory/sharedHeap.cpp b/hotspot/src/share/vm/memory/sharedHeap.cpp index edc1a670a11..1dfccd0b519 100644 --- a/hotspot/src/share/vm/memory/sharedHeap.cpp +++ b/hotspot/src/share/vm/memory/sharedHeap.cpp @@ -45,6 +45,7 @@ enum SH_process_strong_roots_tasks { SH_PS_FlatProfiler_oops_do, SH_PS_Management_oops_do, SH_PS_SystemDictionary_oops_do, + SH_PS_ClassLoaderDataGraph_oops_do, SH_PS_jvmti_oops_do, SH_PS_StringTable_oops_do, SH_PS_CodeCache_oops_do, @@ -173,15 +174,21 @@ void SharedHeap::process_strong_roots(bool activate_scope, if (!_process_strong_tasks->is_task_claimed(SH_PS_SystemDictionary_oops_do)) { if (so & SO_AllClasses) { SystemDictionary::oops_do(roots); - ClassLoaderDataGraph::oops_do(roots, klass_closure, !is_scavenging); } else if (so & SO_SystemClasses) { SystemDictionary::always_strong_oops_do(roots); - ClassLoaderDataGraph::always_strong_oops_do(roots, klass_closure, !is_scavenging); } else { fatal("We should always have selected either SO_AllClasses or SO_SystemClasses"); } } + if (!_process_strong_tasks->is_task_claimed(SH_PS_ClassLoaderDataGraph_oops_do)) { + if (so & SO_AllClasses) { + ClassLoaderDataGraph::oops_do(roots, klass_closure, !is_scavenging); + } else if (so & SO_SystemClasses) { + ClassLoaderDataGraph::always_strong_oops_do(roots, klass_closure, !is_scavenging); + } + } + if (!_process_strong_tasks->is_task_claimed(SH_PS_StringTable_oops_do)) { if (so & SO_Strings) { StringTable::oops_do(roots); From 8b7d3c5d3b514a63b877ad26ececc6bff6415cb8 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Mon, 27 May 2013 12:56:34 +0200 Subject: [PATCH 059/206] 8015428: Remove unused CDS support from StringTable The string in StringTable is not used by CDS anymore. Remove the unnecessary code in preparation for 8015422: Large performance hit when the StringTable is walked twice in Parallel Scavenge Reviewed-by: pliden, tschatzl, coleenp --- .../src/share/vm/classfile/symbolTable.cpp | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/hotspot/src/share/vm/classfile/symbolTable.cpp b/hotspot/src/share/vm/classfile/symbolTable.cpp index 5fbd184a421..f4590c62fb5 100644 --- a/hotspot/src/share/vm/classfile/symbolTable.cpp +++ b/hotspot/src/share/vm/classfile/symbolTable.cpp @@ -745,41 +745,28 @@ void StringTable::unlink(BoolObjectClosure* is_alive) { HashtableEntry** p = the_table()->bucket_addr(i); HashtableEntry* entry = the_table()->bucket(i); while (entry != NULL) { - // Shared entries are normally at the end of the bucket and if we run into - // a shared entry, then there is nothing more to remove. However, if we - // have rehashed the table, then the shared entries are no longer at the - // end of the bucket. - if (entry->is_shared() && !use_alternate_hashcode()) { - break; - } - assert(entry->literal() != NULL, "just checking"); - if (entry->is_shared() || is_alive->do_object_b(entry->literal())) { + assert(!entry->is_shared(), "CDS not used for the StringTable"); + + if (is_alive->do_object_b(entry->literal())) { p = entry->next_addr(); } else { *p = entry->next(); the_table()->free_entry(entry); } - entry = (HashtableEntry*)HashtableEntry::make_ptr(*p); + entry = *p; } } } void StringTable::oops_do(OopClosure* f) { for (int i = 0; i < the_table()->table_size(); ++i) { - HashtableEntry** p = the_table()->bucket_addr(i); HashtableEntry* entry = the_table()->bucket(i); while (entry != NULL) { + assert(!entry->is_shared(), "CDS not used for the StringTable"); + f->do_oop((oop*)entry->literal_addr()); - // Did the closure remove the literal from the table? - if (entry->literal() == NULL) { - assert(!entry->is_shared(), "immutable hashtable entry?"); - *p = entry->next(); - the_table()->free_entry(entry); - } else { - p = entry->next_addr(); - } - entry = (HashtableEntry*)HashtableEntry::make_ptr(*p); + entry = entry->next(); } } } From c13149ab8d83abe24a1bb16bf446554f114b6ac3 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Mon, 27 May 2013 12:58:42 +0200 Subject: [PATCH 060/206] 8015422: Large performance hit when the StringTable is walked twice in Parallel Scavenge Combine the calls to StringTable::unlink and StringTable::oops_do in Parallel Scavenge. Reviewed-by: pliden, coleenp --- hotspot/src/share/vm/classfile/symbolTable.cpp | 5 ++++- hotspot/src/share/vm/classfile/symbolTable.hpp | 5 ++++- .../vm/gc_implementation/parallelScavenge/psScavenge.cpp | 8 +++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/hotspot/src/share/vm/classfile/symbolTable.cpp b/hotspot/src/share/vm/classfile/symbolTable.cpp index f4590c62fb5..c78ea2d3576 100644 --- a/hotspot/src/share/vm/classfile/symbolTable.cpp +++ b/hotspot/src/share/vm/classfile/symbolTable.cpp @@ -737,7 +737,7 @@ oop StringTable::intern(const char* utf8_string, TRAPS) { return result; } -void StringTable::unlink(BoolObjectClosure* is_alive) { +void StringTable::unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f) { // Readers of the table are unlocked, so we should only be removing // entries at a safepoint. assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); @@ -748,6 +748,9 @@ void StringTable::unlink(BoolObjectClosure* is_alive) { assert(!entry->is_shared(), "CDS not used for the StringTable"); if (is_alive->do_object_b(entry->literal())) { + if (f != NULL) { + f->do_oop((oop*)entry->literal_addr()); + } p = entry->next_addr(); } else { *p = entry->next(); diff --git a/hotspot/src/share/vm/classfile/symbolTable.hpp b/hotspot/src/share/vm/classfile/symbolTable.hpp index a2896382f63..4701e74b553 100644 --- a/hotspot/src/share/vm/classfile/symbolTable.hpp +++ b/hotspot/src/share/vm/classfile/symbolTable.hpp @@ -272,7 +272,10 @@ public: // GC support // Delete pointers to otherwise-unreachable objects. - static void unlink(BoolObjectClosure* cl); + static void unlink_or_oops_do(BoolObjectClosure* cl, OopClosure* f); + static void unlink(BoolObjectClosure* cl) { + unlink_or_oops_do(cl, NULL); + } // Invoke "f->do_oop" on the locations of all oops in the table. static void oops_do(OopClosure* f); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp index 72d2df4b91f..f209a802b3d 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp @@ -450,11 +450,9 @@ bool PSScavenge::invoke_no_policy() { reference_processor()->enqueue_discovered_references(NULL); } - // Unlink any dead interned Strings - StringTable::unlink(&_is_alive_closure); - // Process the remaining live ones - PSScavengeRootsClosure root_closure(promotion_manager); - StringTable::oops_do(&root_closure); + // Unlink any dead interned Strings and process the remaining live ones. + PSScavengeRootsClosure root_closure(promotion_manager); + StringTable::unlink_or_oops_do(&_is_alive_closure, &root_closure); // Finally, flush the promotion_manager's labs, and deallocate its stacks. PSPromotionManager::post_scavenge(); From a34fd412c5243585c79d53c541be94d927e6dd10 Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Mon, 27 May 2013 13:11:13 +0200 Subject: [PATCH 061/206] 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose Reviewed-by: jlaskey, attila --- nashorn/make/build-benchmark.xml | 91 ++++---- .../internal/runtime/AccessorProperty.java | 16 +- .../nashorn/internal/runtime/Property.java | 2 + .../runtime/UserAccessorProperty.java | 2 - .../script/basic/compile-octane.js.EXPECTED | 52 ++--- nashorn/test/script/basic/run-octane.js | 213 +++++++++--------- 6 files changed, 177 insertions(+), 199 deletions(-) diff --git a/nashorn/make/build-benchmark.xml b/nashorn/make/build-benchmark.xml index d28de93df79..47064e24d35 100644 --- a/nashorn/make/build-benchmark.xml +++ b/nashorn/make/build-benchmark.xml @@ -32,250 +32,263 @@
    + - + - + - + + - + - + - + + - + - + - + + - + - + - + + - + - + - + + - + - + - + + - + - + - + + - + - + - + + - + - + - + + - + - + - + + - + - + - + + - + - + - + + - + - + - + diff --git a/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java b/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java index c3bfa697850..13e9e1ce3bd 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java @@ -306,14 +306,14 @@ public class AccessorProperty extends Property { protected Object getObjectValue(final ScriptObject self, final ScriptObject owner) { if (isSpill()) { return self.spill[getSlot()]; - } else { - try { - return getGetter(Object.class).invokeExact((Object)self); - } catch (final Error|RuntimeException e) { - throw e; - } catch (final Throwable e) { - throw new RuntimeException(e); - } + } + + try { + return getGetter(Object.class).invokeExact((Object)self); + } catch (final Error|RuntimeException e) { + throw e; + } catch (final Throwable e) { + throw new RuntimeException(e); } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Property.java b/nashorn/src/jdk/nashorn/internal/runtime/Property.java index 433bc2c3048..a5e46016a00 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Property.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Property.java @@ -52,6 +52,7 @@ public abstract class Property { * we can use leave flag byte initialized with (the default) zero value. */ + /** Mask for property being both writable, enumerable and configurable */ public static final int WRITABLE_ENUMERABLE_CONFIGURABLE = 0b0000_0000_0000; /** ECMA 8.6.1 - Is this property not writable? */ @@ -360,6 +361,7 @@ public abstract class Property { * @param self the this object * @param owner the owner object * @param value the new property value + * @param strict is this a strict setter? */ protected abstract void setObjectValue(ScriptObject self, ScriptObject owner, Object value, boolean strict); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java b/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java index fac505ceff5..5159e6537b0 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java @@ -193,7 +193,6 @@ public final class UserAccessorProperty extends Property { // getter/setter may be inherited. If so, proto is bound during lookup. In either // inherited or self case, slot is also bound during lookup. Actual ScriptFunction // to be called is retrieved everytime and applied. - @SuppressWarnings("unused") static Object userAccessorGetter(final ScriptObject proto, final int slot, final Object self) { final ScriptObject container = (proto != null) ? proto : (ScriptObject)self; final Object func = container.getSpill(slot); @@ -211,7 +210,6 @@ public final class UserAccessorProperty extends Property { return UNDEFINED; } - @SuppressWarnings("unused") static void userAccessorSetter(final ScriptObject proto, final int slot, final String name, final Object self, final Object value) { final ScriptObject container = (proto != null) ? proto : (ScriptObject)self; final Object func = container.getSpill(slot); diff --git a/nashorn/test/script/basic/compile-octane.js.EXPECTED b/nashorn/test/script/basic/compile-octane.js.EXPECTED index 39f866c2d17..153524c70b4 100644 --- a/nashorn/test/script/basic/compile-octane.js.EXPECTED +++ b/nashorn/test/script/basic/compile-octane.js.EXPECTED @@ -1,39 +1,13 @@ -Compiling... box2d.js -Compiled OK: box2d.js - -Compiling... code-load.js -Compiled OK: code-load.js - -Compiling... crypto.js -Compiled OK: crypto.js - -Compiling... deltablue.js -Compiled OK: deltablue.js - -Compiling... earley-boyer.js -Compiled OK: earley-boyer.js - -Compiling... gbemu.js -Compiled OK: gbemu.js - -Compiling... mandreel.js -Compiled OK: mandreel.js - -Compiling... navier-stokes.js -Compiled OK: navier-stokes.js - -Compiling... pdfjs.js -Compiled OK: pdfjs.js - -Compiling... raytrace.js -Compiled OK: raytrace.js - -Compiling... regexp.js -Compiled OK: regexp.js - -Compiling... richards.js -Compiled OK: richards.js - -Compiling... splay.js -Compiled OK: splay.js - +Compiled OK: box2d +Compiled OK: code-load +Compiled OK: crypto +Compiled OK: deltablue +Compiled OK: earley-boyer +Compiled OK: gbemu +Compiled OK: mandreel +Compiled OK: navier-stokes +Compiled OK: pdfjs +Compiled OK: raytrace +Compiled OK: regexp +Compiled OK: richards +Compiled OK: splay diff --git a/nashorn/test/script/basic/run-octane.js b/nashorn/test/script/basic/run-octane.js index 315451cbee8..5739000a991 100644 --- a/nashorn/test/script/basic/run-octane.js +++ b/nashorn/test/script/basic/run-octane.js @@ -26,36 +26,20 @@ */ var tests = [ - "box2d.js", - "code-load.js", - "crypto.js", - "deltablue.js", - "earley-boyer.js", - "gbemu.js", - "mandreel.js", - "navier-stokes.js", - "pdfjs.js", - "raytrace.js", - "regexp.js", - "richards.js", - "splay.js" + {file:"box2d",suite:"Box2DBenchmark"}, + {file:"code-load",suite:"CodeLoad"}, + {file:"crypto",suite:"Crypto"}, + {file:"deltablue",suite:"DeltaBlue"}, + {file:"earley-boyer", suite:"EarleyBoyer"}, + {file:"gbemu", suite:"GameboyBenchmark"}, + {file:"mandreel", suite:"MandreelBenchmark"}, + {file:"navier-stokes", suite:"NavierStokes"}, + {file:"pdfjs", suite:"PdfJS"}, + {file:"raytrace", suite:"RayTrace"}, + {file:"regexp", suite:"RegExpSuite"}, + {file:"richards", suite:"Richards"}, + {file:"splay", suite:"Splay"} ]; - -// hack, teardown breaks things defined in the global space, making it impossible -// to do multiple consecutive benchmark runs with the same harness. I think it's a bug -// that the setup and teardown aren't each others constructor and destructor but rather -// that the benchmarks rely on partial global state. For shame, Octane! -var ignoreTeardown = [ - { name: "box2d.js" }, - { name: "gbemu.js" }, -]; - - -//TODO mandreel can be compiled as a test, but not run multiple times unless modified to not have global state -var compileOnly = { - "mandreel.js" : true -}; - var dir = (typeof(__DIR__) == 'undefined') ? "test/script/basic/" : __DIR__; // TODO: why is this path hard coded when it's defined in project properties? @@ -71,110 +55,96 @@ function endsWith(str, suffix) { } function should_compile_only(name) { - return (typeof compile_only !== 'undefined') || compileOnly[name] === true; + return (typeof compile_only !== 'undefined') } function run_one_benchmark(arg, iters) { - var file_name; - var file = arg.split('/'); - if (file.length == 1) { - file = arg.split('\\'); - } - - //trim off trailing path separators - while (file[file.length - 1].indexOf(".js") == -1) { - file.pop(); - } - file_name = file[file.length - 1]; - + var file = (arg.file + ".js").split('/'); + + file_name = path + file[file.length - 1]; + var compile_and_return = should_compile_only(file_name); if (compile_and_return) { if (typeof compile_only === 'undefined') { //for a run, skip compile onlies, don't even compile them return; } - print("Compiling... " + file_name); } - - load(path + 'base.js'); - load(arg); + + print_verbose("Loading... " + file_name); + load(file_name); if (compile_and_return) { - print("Compiled OK: " + file_name); - print(""); + print_always("Compiled OK: " + arg.file); return; } var success = true; - var hiscore = 0; - var loscore = 10e8; var current_name; - function PrintResult(name, result) { - current_name = name; - } - - function PrintError(name, error) { - current_name = name; - PrintResult(name, error); - success = false; - } - - function PrintScore(score) { - if (success) { - if (+score >= hiscore) { - hiscore = +score; - } - if (+score <= loscore) { - loscore = +score; - } - } - - if (verbose) { - print("Score: " + score); - } - } - if (iters == undefined) { iters = numberOfIterations; } else { numberOfIterations = iters; } - - print(runtime + ": running " + file_name + "..."); - - for (var i = 0; i < numberOfIterations; i++) { - var callbacks = - { NotifyResult: PrintResult, - NotifyError: PrintError, - NotifyScore: PrintScore }; - - for (j in ignoreTeardown) { - var ignore = ignoreTeardown[j]; - if (endsWith(arg, ignore.name)) { - var teardownOverride = ignore.teardown; - if (!teardownOverride) { - teardownOverride = function() {}; - } - - for (k in BenchmarkSuite.suites) { - var benchmarks = BenchmarkSuite.suites[k].benchmarks; - for (l in benchmarks) { - benchmarks[l].TearDown = teardownOverride; - } - } - break; - } - } - - BenchmarkSuite.RunSuites(callbacks); - } - var start = "Score: "; - if (runtime != "") { - start = runtime + ": "; - } - print(start + current_name + ' (version ' + BenchmarkSuite.version + '): ' + loscore + '-' + hiscore); + var benchmarks = eval(arg.suite + ".benchmarks"); + for (var x = 0; x < benchmarks.length ; x++) { + benchmarks[x].Setup(); + } + print_verbose("Running '" + arg.file + "' for " + iters + " iterations of no less than " + min_time + " seconds (" + runtime + ")"); + + var scores = []; + + var min_time_ms = min_time * 1000; + var len = benchmarks.length; + + for (var it = 0; it < iters + 1; it++) { + //every iteration must take a minimum of 10 secs + var ops = 0; + var elapsed = 0; + var start = new Date; + do { + for (var i = 0; i < len; i++) { + benchmarks[i].run(); + } + ops += len; + elapsed = new Date - start; + } while (elapsed < min_time * 1000); + + var score = ops / elapsed * 1000 * 60; + scores.push(score); + var name = it == 0 ? "warmup" : "iteration " + it; + print_verbose("[" + arg.file + "] " + name + " finished " + score.toFixed(0) + " ops/minute"); + } + for (var x = 0; x < benchmarks.length ; x++) { + benchmarks[x].TearDown(); + } + + var min_score = 1e9; + var max_score = 0; + var mean_score = 0; + for (var x = 1; x < iters + 1 ; x++) { + mean_score += scores[x]; + min_score = Math.min(min_score, scores[x]); + max_score = Math.max(max_score, scores[x]); + } + mean_score /= iters; + var res = "[" + arg.file + "] " + mean_score.toFixed(0); + if (verbose) { + res += " ops/minute (" + min_score.toFixed(0) + "-" + max_score.toFixed(0) + "), warmup=" + scores[0].toFixed(0); + } + print_always(res); +} + +function print_always(x) { + print(x); +} + +function print_verbose(x) { + if (verbose) { + print(x); + } } function run_suite(tests, iters) { @@ -211,6 +181,7 @@ if (new_args.length != 0) { var tests_found = []; var iters = undefined; +var min_time = 5; for (var i = 0; i < args.length; i++) { arg = args[i]; @@ -220,21 +191,41 @@ for (var i = 0; i < args.length; i++) { runtime = args[++i]; } else if (arg == "--verbose") { verbose = true; + } else if (arg == "--min-time") { + min_time = +args[++i]; } else if (arg == "") { continue; //skip } else { - tests_found.push(arg); + var found = false; + for (j in tests) { + if (tests[j].file === arg) { + tests_found.push(tests[j]); + found = true; + break; + } + } + if (!found) { + var str = "unknown test name: '" + arg + "' -- valid names are: "; + for (j in tests) { + if (j != 0) { + str += ", "; + } + str += "'" + tests[j].file + "'"; + } + throw str; + } } } if (tests_found.length == 0) { for (i in tests) { - tests_found.push(path + tests[i]); + tests_found.push(tests[i]); } } tests_found.sort(); +load(path + 'base.js'); run_suite(tests_found, iters); From fb25dcbb05044910c9e497c5f857ccf58bad369e Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Mon, 27 May 2013 13:44:14 +0100 Subject: [PATCH 062/206] 7030476: Fix conflicting use of JCTree/JCExpression Reviewed-by: mcimadamore --- .../share/classes/com/sun/tools/javac/comp/Lower.java | 2 +- .../share/classes/com/sun/tools/javac/tree/JCTree.java | 10 +++++----- .../classes/com/sun/tools/javac/tree/TreeCopier.java | 2 +- .../classes/com/sun/tools/javac/tree/TreeMaker.java | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java index 7ed28941fb7..98ee76968d2 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java @@ -2002,7 +2002,7 @@ public class Lower extends TreeTranslator { JCStatement rethrow; if (target.hasInitCause()) { // rethrow = "throw new NoClassDefFoundError().initCause(e); - JCTree throwExpr = + JCExpression throwExpr = makeCall(makeNewClass(syms.noClassDefFoundErrorType, List.nil()), names.initCause, diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java index 1ab8051279b..191dda07adf 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java @@ -700,7 +700,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { public List getTypeParameters() { return typarams; } - public JCTree getExtendsClause() { return extending; } + public JCExpression getExtendsClause() { return extending; } public List getImplementsClause() { return implementing; } @@ -1175,7 +1175,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { return v.visitTry(this, d); } @Override - public List getResources() { + public List getResources() { return resources; } @Override @@ -1392,8 +1392,8 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { */ public static class JCThrow extends JCStatement implements ThrowTree { public JCExpression expr; - protected JCThrow(JCTree expr) { - this.expr = (JCExpression)expr; + protected JCThrow(JCExpression expr) { + this.expr = expr; } @Override public void accept(Visitor v) { v.visitThrow(this); } @@ -2466,7 +2466,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { JCBreak Break(Name label); JCContinue Continue(Name label); JCReturn Return(JCExpression expr); - JCThrow Throw(JCTree expr); + JCThrow Throw(JCExpression expr); JCAssert Assert(JCExpression cond, JCExpression detail); JCMethodInvocation Apply(List typeargs, JCExpression fn, diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java index a06fa349156..aa2ce423b4b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java @@ -340,7 +340,7 @@ public class TreeCopier

    implements TreeVisitor { public JCTree visitThrow(ThrowTree node, P p) { JCThrow t = (JCThrow) node; - JCTree expr = copy(t.expr, p); + JCExpression expr = copy(t.expr, p); return M.at(t.pos).Throw(expr); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java index c2757c7d05d..e0b74340b77 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java @@ -332,7 +332,7 @@ public class TreeMaker implements JCTree.Factory { return tree; } - public JCThrow Throw(JCTree expr) { + public JCThrow Throw(JCExpression expr) { JCThrow tree = new JCThrow(expr); tree.pos = pos; return tree; From bca9af88dac3cabdbf4ebdd203a9d803fb0c6a87 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Mon, 27 May 2013 20:41:34 +0530 Subject: [PATCH 063/206] =?UTF-8?q?8015352:=20"i".toUpperCase()=20=3D>=20c?= =?UTF-8?q?urrently=20returns=20"=C4=B0",=20but=20should=20be=20"I"=20(wit?= =?UTF-8?q?h=20Turkish=20locale)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: jlaskey, lagergren --- .../internal/objects/NativeString.java | 5 +- .../internal/runtime/ScriptEnvironment.java | 13 ++++-- .../runtime/options/OptionTemplate.java | 3 ++ .../internal/runtime/options/Options.java | 2 + .../runtime/resources/Options.properties | 9 ++++ nashorn/test/script/basic/JDK-8015352.js | 46 +++++++++++++++++++ 6 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8015352.js diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeString.java b/nashorn/src/jdk/nashorn/internal/objects/NativeString.java index 2715d4f4cde..adbef5cb633 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeString.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeString.java @@ -38,6 +38,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.linker.GuardedInvocation; import jdk.internal.dynalink.linker.LinkRequest; @@ -997,7 +998,7 @@ public final class NativeString extends ScriptObject { */ @Function(attributes = Attribute.NOT_ENUMERABLE) public static Object toLowerCase(final Object self) { - return checkObjectToString(self).toLowerCase(); + return checkObjectToString(self).toLowerCase(Locale.ROOT); } /** @@ -1017,7 +1018,7 @@ public final class NativeString extends ScriptObject { */ @Function(attributes = Attribute.NOT_ENUMERABLE) public static Object toUpperCase(final Object self) { - return checkObjectToString(self).toUpperCase(); + return checkObjectToString(self).toUpperCase(Locale.ROOT); } /** diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java index c1c25b3eecc..2ca897db98a 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java @@ -262,14 +262,19 @@ public final class ScriptEnvironment { } this._callsite_flags = callSiteFlags; - final Option option = options.get("timezone"); - if (option != null) { - this._timezone = (TimeZone)option.getValue(); + final Option timezoneOption = options.get("timezone"); + if (timezoneOption != null) { + this._timezone = (TimeZone)timezoneOption.getValue(); } else { this._timezone = TimeZone.getDefault(); } - this._locale = Locale.getDefault(); + final Option localeOption = options.get("locale"); + if (localeOption != null) { + this._locale = (Locale)localeOption.getValue(); + } else { + this._locale = Locale.getDefault(); + } } /** diff --git a/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java b/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java index 30e0401e62e..62dcbb8d3f0 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java @@ -152,6 +152,9 @@ public class OptionTemplate implements Comparable { case "timezone": this.defaultValue = TimeZone.getDefault().getID(); break; + case "locale": + this.defaultValue = Locale.getDefault().toLanguageTag(); + break; default: break; } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java b/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java index 52864a6652a..737c56b4b1a 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java @@ -499,6 +499,8 @@ public final class Options { case "timezone": // default value "TimeZone.getDefault()" return new Option<>(TimeZone.getTimeZone(value)); + case "locale": + return new Option<>(Locale.forLanguageTag(value)); case "keyvalues": return new KeyValueOption(value); case "log": diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties b/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties index 59e971917eb..4dd6df6f75c 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties @@ -332,6 +332,15 @@ nashorn.option.timezone = { \ type=TimeZone \ } +nashorn.option.locale = { \ + name="--locale", \ + short_name="-l", \ + is_undocumented=true, \ + params="", \ + desc="Set Locale for script execution.", \ + type=Locale \ +} + nashorn.option.trace.callsites = { \ name="--trace-callsites", \ short_name="-tcs", \ diff --git a/nashorn/test/script/basic/JDK-8015352.js b/nashorn/test/script/basic/JDK-8015352.js new file mode 100644 index 00000000000..b40e6461049 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015352.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8015352: "i".toUpperCase() => currently returns "İ", but should be "I" (with Turkish locale) + * + * @test + * @option --locale=tr-TR + * @run + */ + +if ("i".toUpperCase() != "I") { + fail("'i'.toUpperCase() is not 'I'"); +} + +if ("i".toUpperCase() == "i".toLocaleUpperCase()) { + fail("'i'.toUpperCase() == 'i'.toLocaleUpperCase()"); +} + +if ("I".toLowerCase() != "i") { + fail("'I'.toLowerCase() is not 'i'"); +} + +if ("I".toLowerCase() == "I".toLocaleLowerCase()) { + fail("'i'.toLowerCase() == 'i'.toLocaleLowerCase()"); +} From d1cfaae2c635890d2978cdba76f7dd61dc5aedba Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Mon, 27 May 2013 17:57:07 +0200 Subject: [PATCH 064/206] 8015447: Octane harness fixes for rhino and entire test runs: ant octane, ant octane-v8, ant octane-rhino Reviewed-by: sundar, jlaskey --- nashorn/make/build-benchmark.xml | 15 ++--- nashorn/test/script/basic/run-octane.js | 85 ++++++++++++++----------- 2 files changed, 55 insertions(+), 45 deletions(-) diff --git a/nashorn/make/build-benchmark.xml b/nashorn/make/build-benchmark.xml index 47064e24d35..f1ce180a844 100644 --- a/nashorn/make/build-benchmark.xml +++ b/nashorn/make/build-benchmark.xml @@ -24,14 +24,13 @@ - - - - + + + + + + - @@ -320,7 +319,7 @@ - + diff --git a/nashorn/test/script/basic/run-octane.js b/nashorn/test/script/basic/run-octane.js index 5739000a991..b730040e4c5 100644 --- a/nashorn/test/script/basic/run-octane.js +++ b/nashorn/test/script/basic/run-octane.js @@ -89,47 +89,57 @@ function run_one_benchmark(arg, iters) { } var benchmarks = eval(arg.suite + ".benchmarks"); - for (var x = 0; x < benchmarks.length ; x++) { - benchmarks[x].Setup(); - } - print_verbose("Running '" + arg.file + "' for " + iters + " iterations of no less than " + min_time + " seconds (" + runtime + ")"); - - var scores = []; - - var min_time_ms = min_time * 1000; - var len = benchmarks.length; - - for (var it = 0; it < iters + 1; it++) { - //every iteration must take a minimum of 10 secs - var ops = 0; - var elapsed = 0; - var start = new Date; - do { - for (var i = 0; i < len; i++) { - benchmarks[i].run(); - } - ops += len; - elapsed = new Date - start; - } while (elapsed < min_time * 1000); - - var score = ops / elapsed * 1000 * 60; - scores.push(score); - var name = it == 0 ? "warmup" : "iteration " + it; - print_verbose("[" + arg.file + "] " + name + " finished " + score.toFixed(0) + " ops/minute"); - } - for (var x = 0; x < benchmarks.length ; x++) { - benchmarks[x].TearDown(); - } - var min_score = 1e9; var max_score = 0; var mean_score = 0; - for (var x = 1; x < iters + 1 ; x++) { - mean_score += scores[x]; - min_score = Math.min(min_score, scores[x]); - max_score = Math.max(max_score, scores[x]); + + try { + for (var x = 0; x < benchmarks.length ; x++) { + benchmarks[x].Setup(); + } + print_verbose("Running '" + arg.file + "' for " + iters + " iterations of no less than " + min_time + " seconds (" + runtime + ")"); + + var scores = []; + + var min_time_ms = min_time * 1000; + var len = benchmarks.length; + + for (var it = 0; it < iters + 1; it++) { + //every iteration must take a minimum of 10 secs + var ops = 0; + var elapsed = 0; + var start = new Date; + do { + for (var i = 0; i < len; i++) { + benchmarks[i].run(); + } + ops += len; + elapsed = new Date - start; + } while (elapsed < min_time * 1000); + + var score = ops / elapsed * 1000 * 60; + scores.push(score); + var name = it == 0 ? "warmup" : "iteration " + it; + print_verbose("[" + arg.file + "] " + name + " finished " + score.toFixed(0) + " ops/minute"); + } + + for (var x = 0; x < benchmarks.length ; x++) { + benchmarks[x].TearDown(); + } + + for (var x = 1; x < iters + 1 ; x++) { + mean_score += scores[x]; + min_score = Math.min(min_score, scores[x]); + max_score = Math.max(max_score, scores[x]); + } + mean_score /= iters; + + } catch (e) { + print_always("*** Aborted and setting score to zero. Reason: " + e); + mean_score = min_score = max_score = 0; + scores = [0]; } - mean_score /= iters; + var res = "[" + arg.file + "] " + mean_score.toFixed(0); if (verbose) { res += " ops/minute (" + min_score.toFixed(0) + "-" + max_score.toFixed(0) + "), warmup=" + scores[0].toFixed(0); @@ -156,6 +166,7 @@ function run_suite(tests, iters) { runtime = "command line"; var args = []; + if (typeof $ARGS !== 'undefined') { args = $ARGS; } else if (typeof arguments !== 'undefined' && arguments.length != 0) { From 375e12feb95368849df2e8ec48c13608aff1a605 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 27 May 2013 12:49:08 -0700 Subject: [PATCH 065/206] 8015270: @Contended: fix multiple issues in the layout code Field count handling fixed, has_nonstatic_fields invariant fixed, oop map overrun fixed; new asserts Reviewed-by: kvn, dcubed, coleenp --- .../share/vm/classfile/classFileParser.cpp | 64 ++++--- .../test/runtime/contended/HasNonStatic.java | 75 ++++++++ hotspot/test/runtime/contended/OopMaps.java | 164 ++++++++++++++++++ 3 files changed, 283 insertions(+), 20 deletions(-) create mode 100644 hotspot/test/runtime/contended/HasNonStatic.java create mode 100644 hotspot/test/runtime/contended/OopMaps.java diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 8aa15736447..263409f15d8 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -3152,7 +3152,6 @@ void ClassFileParser::layout_fields(Handle class_loader, } } } - int contended_count = nonstatic_contended_count; // Calculate the starting byte offsets @@ -3177,35 +3176,52 @@ void ClassFileParser::layout_fields(Handle class_loader, next_nonstatic_field_offset = nonstatic_fields_start; + bool is_contended_class = parsed_annotations->is_contended(); + // Class is contended, pad before all the fields - if (parsed_annotations->is_contended()) { + if (is_contended_class) { next_nonstatic_field_offset += ContendedPaddingWidth; } - // Compute the non-contended fields count + // Compute the non-contended fields count. + // The packing code below relies on these counts to determine if some field + // can be squeezed into the alignment gap. Contended fields are obviously + // exempt from that. unsigned int nonstatic_double_count = fac->count[NONSTATIC_DOUBLE] - fac_contended.count[NONSTATIC_DOUBLE]; unsigned int nonstatic_word_count = fac->count[NONSTATIC_WORD] - fac_contended.count[NONSTATIC_WORD]; unsigned int nonstatic_short_count = fac->count[NONSTATIC_SHORT] - fac_contended.count[NONSTATIC_SHORT]; unsigned int nonstatic_byte_count = fac->count[NONSTATIC_BYTE] - fac_contended.count[NONSTATIC_BYTE]; unsigned int nonstatic_oop_count = fac->count[NONSTATIC_OOP] - fac_contended.count[NONSTATIC_OOP]; + // Total non-static fields count, including every contended field + unsigned int nonstatic_fields_count = fac->count[NONSTATIC_DOUBLE] + fac->count[NONSTATIC_WORD] + + fac->count[NONSTATIC_SHORT] + fac->count[NONSTATIC_BYTE] + + fac->count[NONSTATIC_OOP]; + bool super_has_nonstatic_fields = (_super_klass() != NULL && _super_klass->has_nonstatic_fields()); - bool has_nonstatic_fields = super_has_nonstatic_fields || - ((nonstatic_double_count + nonstatic_word_count + - nonstatic_short_count + nonstatic_byte_count + - nonstatic_oop_count) != 0); + bool has_nonstatic_fields = super_has_nonstatic_fields || (nonstatic_fields_count != 0); // Prepare list of oops for oop map generation. + // + // "offset" and "count" lists are describing the set of contiguous oop + // regions. offset[i] is the start of the i-th region, which then has + // count[i] oops following. Before we know how many regions are required, + // we pessimistically allocate the maps to fit all the oops into the + // distinct regions. + // + // TODO: We add +1 to always allocate non-zero resource arrays; we need + // to figure out if we still need to do this. int* nonstatic_oop_offsets; unsigned int* nonstatic_oop_counts; unsigned int nonstatic_oop_map_count = 0; + unsigned int max_nonstatic_oop_maps = fac->count[NONSTATIC_OOP] + 1; nonstatic_oop_offsets = NEW_RESOURCE_ARRAY_IN_THREAD( - THREAD, int, nonstatic_oop_count + 1); + THREAD, int, max_nonstatic_oop_maps); nonstatic_oop_counts = NEW_RESOURCE_ARRAY_IN_THREAD( - THREAD, unsigned int, nonstatic_oop_count + 1); + THREAD, unsigned int, max_nonstatic_oop_maps); first_nonstatic_oop_offset = 0; // will be set for first oop field @@ -3392,9 +3408,11 @@ void ClassFileParser::layout_fields(Handle class_loader, int(nonstatic_oop_counts[nonstatic_oop_map_count - 1]) * heapOopSize ) { // Extend current oop map + assert(nonstatic_oop_map_count - 1 < max_nonstatic_oop_maps, "range check"); nonstatic_oop_counts[nonstatic_oop_map_count - 1] += 1; } else { // Create new oop map + assert(nonstatic_oop_map_count < max_nonstatic_oop_maps, "range check"); nonstatic_oop_offsets[nonstatic_oop_map_count] = real_offset; nonstatic_oop_counts [nonstatic_oop_map_count] = 1; nonstatic_oop_map_count += 1; @@ -3452,12 +3470,10 @@ void ClassFileParser::layout_fields(Handle class_loader, // // Additionally, this should not break alignment for the fields, so we round the alignment up // for each field. - if (contended_count > 0) { + if (nonstatic_contended_count > 0) { // if there is at least one contended field, we need to have pre-padding for them - if (nonstatic_contended_count > 0) { - next_nonstatic_padded_offset += ContendedPaddingWidth; - } + next_nonstatic_padded_offset += ContendedPaddingWidth; // collect all contended groups BitMap bm(_cp->size()); @@ -3518,6 +3534,7 @@ void ClassFileParser::layout_fields(Handle class_loader, next_nonstatic_padded_offset += heapOopSize; // Create new oop map + assert(nonstatic_oop_map_count < max_nonstatic_oop_maps, "range check"); nonstatic_oop_offsets[nonstatic_oop_map_count] = real_offset; nonstatic_oop_counts [nonstatic_oop_map_count] = 1; nonstatic_oop_map_count += 1; @@ -3554,18 +3571,17 @@ void ClassFileParser::layout_fields(Handle class_loader, // handle static fields } - // Size of instances - int notaligned_offset = next_nonstatic_padded_offset; - // Entire class is contended, pad in the back. // This helps to alleviate memory contention effects for subclass fields // and/or adjacent object. - if (parsed_annotations->is_contended()) { - notaligned_offset += ContendedPaddingWidth; + if (is_contended_class) { + next_nonstatic_padded_offset += ContendedPaddingWidth; } - int nonstatic_fields_end = align_size_up(notaligned_offset, heapOopSize); - int instance_end = align_size_up(notaligned_offset, wordSize); + int notaligned_nonstatic_fields_end = next_nonstatic_padded_offset; + + int nonstatic_fields_end = align_size_up(notaligned_nonstatic_fields_end, heapOopSize); + int instance_end = align_size_up(notaligned_nonstatic_fields_end, wordSize); int static_fields_end = align_size_up(next_static_byte_offset, wordSize); int static_field_size = (static_fields_end - @@ -3579,6 +3595,14 @@ void ClassFileParser::layout_fields(Handle class_loader, (instanceOopDesc::base_offset_in_bytes() + nonstatic_field_size*heapOopSize), wordSize) / wordSize), "consistent layout helper value"); + // Invariant: nonstatic_field end/start should only change if there are + // nonstatic fields in the class, or if the class is contended. We compare + // against the non-aligned value, so that end alignment will not fail the + // assert without actually having the fields. + assert((notaligned_nonstatic_fields_end == nonstatic_fields_start) || + is_contended_class || + (nonstatic_fields_count > 0), "double-check nonstatic start/end"); + // Number of non-static oop map blocks allocated at end of klass. const unsigned int total_oop_map_count = compute_oop_map_count(_super_klass, nonstatic_oop_map_count, diff --git a/hotspot/test/runtime/contended/HasNonStatic.java b/hotspot/test/runtime/contended/HasNonStatic.java new file mode 100644 index 00000000000..6792adf6abb --- /dev/null +++ b/hotspot/test/runtime/contended/HasNonStatic.java @@ -0,0 +1,75 @@ +/* + * 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.io.BufferedReader; +import java.io.InputStreamReader; +import java.lang.Class; +import java.lang.String; +import java.lang.System; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CyclicBarrier; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import sun.misc.Unsafe; +import sun.misc.Contended; + +/* + * @test + * @bug 8015270 + * @summary \@Contended: fix multiple issues in the layout code + * + * @run main/othervm -XX:-RestrictContended HasNonStatic + */ +public class HasNonStatic { + + public static void main(String[] args) throws Exception { + R1 r1 = new R1(); + R2 r2 = new R2(); + R3 r3 = new R3(); + R4 r4 = new R4(); + } + + public static class R1 { + @Contended + Object o; + } + + @Contended + public static class R2 { + Object o; + } + + @Contended + public static class R3 { + } + + public static class R4 extends R3 { + } + +} + diff --git a/hotspot/test/runtime/contended/OopMaps.java b/hotspot/test/runtime/contended/OopMaps.java new file mode 100644 index 00000000000..b8dfbba416b --- /dev/null +++ b/hotspot/test/runtime/contended/OopMaps.java @@ -0,0 +1,164 @@ +/* + * 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.io.BufferedReader; +import java.io.InputStreamReader; +import java.lang.Class; +import java.lang.String; +import java.lang.System; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CyclicBarrier; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import sun.misc.Unsafe; +import sun.misc.Contended; + +/* + * @test + * @bug 8015270 + * @summary \@Contended: fix multiple issues in the layout code + * + * @run main/othervm -XX:-RestrictContended OopMaps + */ +public class OopMaps { + + public static void main(String[] args) throws Exception { + Object o01 = new Object(); + Object o02 = new Object(); + Object o03 = new Object(); + Object o04 = new Object(); + Object o05 = new Object(); + Object o06 = new Object(); + Object o07 = new Object(); + Object o08 = new Object(); + Object o09 = new Object(); + Object o10 = new Object(); + Object o11 = new Object(); + Object o12 = new Object(); + Object o13 = new Object(); + Object o14 = new Object(); + + final int COUNT = 100000; + R1[] rs = new R1[COUNT]; + + for (int i = 0; i < COUNT; i++) { + R1 r1 = new R1(); + r1.o01 = o01; + r1.o02 = o02; + r1.o03 = o03; + r1.o04 = o04; + r1.o05 = o05; + r1.o06 = o06; + r1.o07 = o07; + r1.o08 = o08; + r1.o09 = o09; + r1.o10 = o10; + r1.o11 = o11; + r1.o12 = o12; + r1.o13 = o13; + r1.o14 = o14; + r1.i1 = 1; + r1.i2 = 2; + r1.i3 = 3; + r1.i4 = 4; + rs[i] = r1; + } + + System.gc(); + + for (int i = 0; i < COUNT; i++) { + R1 r1 = rs[i]; + if (r1.o01 != o01) throw new Error("Test Error: o01"); + if (r1.o02 != o02) throw new Error("Test Error: o02"); + if (r1.o03 != o03) throw new Error("Test Error: o03"); + if (r1.o04 != o04) throw new Error("Test Error: o04"); + if (r1.o05 != o05) throw new Error("Test Error: o05"); + if (r1.o06 != o06) throw new Error("Test Error: o06"); + if (r1.o07 != o07) throw new Error("Test Error: o07"); + if (r1.o08 != o08) throw new Error("Test Error: o08"); + if (r1.o09 != o09) throw new Error("Test Error: o09"); + if (r1.o10 != o10) throw new Error("Test Error: o10"); + if (r1.o11 != o11) throw new Error("Test Error: o11"); + if (r1.o12 != o12) throw new Error("Test Error: o12"); + if (r1.o13 != o13) throw new Error("Test Error: o13"); + if (r1.o14 != o14) throw new Error("Test Error: o14"); + if (r1.i1 != 1) throw new Error("Test Error: i1"); + if (r1.i2 != 2) throw new Error("Test Error: i2"); + if (r1.i3 != 3) throw new Error("Test Error: i3"); + if (r1.i4 != 4) throw new Error("Test Error: i4"); + } + } + + public static class R0 { + int i1; + int i2; + + Object o01; + Object o02; + + @Contended + Object o03; + + @Contended + Object o04; + + @Contended + Object o05; + + @Contended + Object o06; + + @Contended + Object o07; + } + + public static class R1 extends R0 { + int i3; + int i4; + + Object o08; + Object o09; + + @Contended + Object o10; + + @Contended + Object o11; + + @Contended + Object o12; + + @Contended + Object o13; + + @Contended + Object o14; + } + +} + From de314e391b4d8865a049810bc570ddf9c39795e5 Mon Sep 17 00:00:00 2001 From: John Coomes Date: Thu, 30 May 2013 13:04:51 -0700 Subject: [PATCH 066/206] 6725714: par compact - add a table to speed up bitmap searches Reviewed-by: jmasa, tschatzl --- .../parallelScavenge/parallelScavengeHeap.hpp | 2 +- .../parallelScavenge/psParallelCompact.cpp | 202 ++++++++++++++---- .../parallelScavenge/psParallelCompact.hpp | 157 +++++++++++++- 3 files changed, 309 insertions(+), 52 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp index c0933fe16c6..98e9c0435ab 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp @@ -116,7 +116,7 @@ class ParallelScavengeHeap : public CollectedHeap { // The alignment used for eden and survivors within the young gen // and for boundary between young gen and old gen. - size_t intra_heap_alignment() const { return 64 * K; } + size_t intra_heap_alignment() const { return 64 * K * HeapWordSize; } size_t capacity() const; size_t used() const; diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp index 3e649ddf702..be437f3272f 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @@ -59,13 +59,25 @@ #include // All sizes are in HeapWords. -const size_t ParallelCompactData::Log2RegionSize = 9; // 512 words +const size_t ParallelCompactData::Log2RegionSize = 16; // 64K words const size_t ParallelCompactData::RegionSize = (size_t)1 << Log2RegionSize; const size_t ParallelCompactData::RegionSizeBytes = RegionSize << LogHeapWordSize; const size_t ParallelCompactData::RegionSizeOffsetMask = RegionSize - 1; const size_t ParallelCompactData::RegionAddrOffsetMask = RegionSizeBytes - 1; -const size_t ParallelCompactData::RegionAddrMask = ~RegionAddrOffsetMask; +const size_t ParallelCompactData::RegionAddrMask = ~RegionAddrOffsetMask; + +const size_t ParallelCompactData::Log2BlockSize = 7; // 128 words +const size_t ParallelCompactData::BlockSize = (size_t)1 << Log2BlockSize; +const size_t ParallelCompactData::BlockSizeBytes = + BlockSize << LogHeapWordSize; +const size_t ParallelCompactData::BlockSizeOffsetMask = BlockSize - 1; +const size_t ParallelCompactData::BlockAddrOffsetMask = BlockSizeBytes - 1; +const size_t ParallelCompactData::BlockAddrMask = ~BlockAddrOffsetMask; + +const size_t ParallelCompactData::BlocksPerRegion = RegionSize / BlockSize; +const size_t ParallelCompactData::Log2BlocksPerRegion = + Log2RegionSize - Log2BlockSize; const ParallelCompactData::RegionData::region_sz_t ParallelCompactData::RegionData::dc_shift = 27; @@ -359,6 +371,10 @@ ParallelCompactData::ParallelCompactData() _reserved_byte_size = 0; _region_data = 0; _region_count = 0; + + _block_vspace = 0; + _block_data = 0; + _block_count = 0; } bool ParallelCompactData::initialize(MemRegion covered_region) @@ -372,8 +388,7 @@ bool ParallelCompactData::initialize(MemRegion covered_region) assert((region_size & RegionSizeOffsetMask) == 0, "region size not a multiple of RegionSize"); - bool result = initialize_region_data(region_size); - + bool result = initialize_region_data(region_size) && initialize_block_data(); return result; } @@ -418,17 +433,36 @@ bool ParallelCompactData::initialize_region_data(size_t region_size) return false; } +bool ParallelCompactData::initialize_block_data() +{ + assert(_region_count != 0, "region data must be initialized first"); + const size_t count = _region_count << Log2BlocksPerRegion; + _block_vspace = create_vspace(count, sizeof(BlockData)); + if (_block_vspace != 0) { + _block_data = (BlockData*)_block_vspace->reserved_low_addr(); + _block_count = count; + return true; + } + return false; +} + void ParallelCompactData::clear() { memset(_region_data, 0, _region_vspace->committed_size()); + memset(_block_data, 0, _block_vspace->committed_size()); } void ParallelCompactData::clear_range(size_t beg_region, size_t end_region) { assert(beg_region <= _region_count, "beg_region out of range"); assert(end_region <= _region_count, "end_region out of range"); + assert(RegionSize % BlockSize == 0, "RegionSize not a multiple of BlockSize"); const size_t region_cnt = end_region - beg_region; memset(_region_data + beg_region, 0, region_cnt * sizeof(RegionData)); + + const size_t beg_block = beg_region * BlocksPerRegion; + const size_t block_cnt = region_cnt * BlocksPerRegion; + memset(_block_data + beg_block, 0, block_cnt * sizeof(BlockData)); } HeapWord* ParallelCompactData::partial_obj_end(size_t region_idx) const @@ -707,49 +741,48 @@ bool ParallelCompactData::summarize(SplitInfo& split_info, HeapWord* ParallelCompactData::calc_new_pointer(HeapWord* addr) { assert(addr != NULL, "Should detect NULL oop earlier"); - assert(PSParallelCompact::gc_heap()->is_in(addr), "addr not in heap"); -#ifdef ASSERT - if (PSParallelCompact::mark_bitmap()->is_unmarked(addr)) { - gclog_or_tty->print_cr("calc_new_pointer:: addr " PTR_FORMAT, addr); - } -#endif - assert(PSParallelCompact::mark_bitmap()->is_marked(addr), "obj not marked"); + assert(PSParallelCompact::gc_heap()->is_in(addr), "not in heap"); + assert(PSParallelCompact::mark_bitmap()->is_marked(addr), "not marked"); // Region covering the object. - size_t region_index = addr_to_region_idx(addr); - const RegionData* const region_ptr = region(region_index); - HeapWord* const region_addr = region_align_down(addr); - - assert(addr < region_addr + RegionSize, "Region does not cover object"); - assert(addr_to_region_ptr(region_addr) == region_ptr, "sanity check"); - + RegionData* const region_ptr = addr_to_region_ptr(addr); HeapWord* result = region_ptr->destination(); - // If all the data in the region is live, then the new location of the object - // can be calculated from the destination of the region plus the offset of the - // object in the region. + // If the entire Region is live, the new location is region->destination + the + // offset of the object within in the Region. + + // Run some performance tests to determine if this special case pays off. It + // is worth it for pointers into the dense prefix. If the optimization to + // avoid pointer updates in regions that only point to the dense prefix is + // ever implemented, this should be revisited. if (region_ptr->data_size() == RegionSize) { - result += pointer_delta(addr, region_addr); - DEBUG_ONLY(PSParallelCompact::check_new_location(addr, result);) + result += region_offset(addr); return result; } - // The new location of the object is - // region destination + - // size of the partial object extending onto the region + - // sizes of the live objects in the Region that are to the left of addr - const size_t partial_obj_size = region_ptr->partial_obj_size(); - HeapWord* const search_start = region_addr + partial_obj_size; + // Otherwise, the new location is region->destination + block offset + the + // number of live words in the Block that are (a) to the left of addr and (b) + // due to objects that start in the Block. + + // Fill in the block table if necessary. This is unsynchronized, so multiple + // threads may fill the block table for a region (harmless, since it is + // idempotent). + if (!region_ptr->blocks_filled()) { + PSParallelCompact::fill_blocks(addr_to_region_idx(addr)); + region_ptr->set_blocks_filled(); + } + + HeapWord* const search_start = block_align_down(addr); + const size_t block_offset = addr_to_block_ptr(addr)->offset(); const ParMarkBitMap* bitmap = PSParallelCompact::mark_bitmap(); - size_t live_to_left = bitmap->live_words_in_range(search_start, oop(addr)); - - result += partial_obj_size + live_to_left; - DEBUG_ONLY(PSParallelCompact::check_new_location(addr, result);) + const size_t live = bitmap->live_words_in_range(search_start, oop(addr)); + result += block_offset + live; + DEBUG_ONLY(PSParallelCompact::check_new_location(addr, result)); return result; } -#ifdef ASSERT +#ifdef ASSERT void ParallelCompactData::verify_clear(const PSVirtualSpace* vspace) { const size_t* const beg = (const size_t*)vspace->committed_low_addr(); @@ -762,16 +795,10 @@ void ParallelCompactData::verify_clear(const PSVirtualSpace* vspace) void ParallelCompactData::verify_clear() { verify_clear(_region_vspace); + verify_clear(_block_vspace); } #endif // #ifdef ASSERT -#ifdef NOT_PRODUCT -ParallelCompactData::RegionData* debug_region(size_t region_index) { - ParallelCompactData& sd = PSParallelCompact::summary_data(); - return sd.region(region_index); -} -#endif - elapsedTimer PSParallelCompact::_accumulated_time; unsigned int PSParallelCompact::_total_invocations = 0; unsigned int PSParallelCompact::_maximum_compaction_gc_num = 0; @@ -1961,11 +1988,6 @@ void PSParallelCompact::invoke(bool maximum_heap_compaction) { maximum_heap_compaction); } -bool ParallelCompactData::region_contains(size_t region_index, HeapWord* addr) { - size_t addr_region_index = addr_to_region_idx(addr); - return region_index == addr_region_index; -} - // This method contains no policy. You should probably // be calling invoke() instead. bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) { @@ -2627,6 +2649,41 @@ void PSParallelCompact::enqueue_region_stealing_tasks( } } +#ifdef ASSERT +// Write a histogram of the number of times the block table was filled for a +// region. +void PSParallelCompact::write_block_fill_histogram(outputStream* const out) +{ + if (!TraceParallelOldGCCompactionPhase) return; + + typedef ParallelCompactData::RegionData rd_t; + ParallelCompactData& sd = summary_data(); + + for (unsigned int id = old_space_id; id < last_space_id; ++id) { + MutableSpace* const spc = _space_info[id].space(); + if (spc->bottom() != spc->top()) { + const rd_t* const beg = sd.addr_to_region_ptr(spc->bottom()); + HeapWord* const top_aligned_up = sd.region_align_up(spc->top()); + const rd_t* const end = sd.addr_to_region_ptr(top_aligned_up); + + size_t histo[5] = { 0, 0, 0, 0, 0 }; + const size_t histo_len = sizeof(histo) / sizeof(size_t); + const size_t region_cnt = pointer_delta(end, beg, sizeof(rd_t)); + + for (const rd_t* cur = beg; cur < end; ++cur) { + ++histo[MIN2(cur->blocks_filled_count(), histo_len - 1)]; + } + out->print("%u %-4s" SIZE_FORMAT_W(5), id, space_names[id], region_cnt); + for (size_t i = 0; i < histo_len; ++i) { + out->print(" " SIZE_FORMAT_W(5) " %5.1f%%", + histo[i], 100.0 * histo[i] / region_cnt); + } + out->cr(); + } + } +} +#endif // #ifdef ASSERT + void PSParallelCompact::compact() { // trace("5"); TraceTime tm("compaction phase", print_phases(), true, gclog_or_tty); @@ -2666,6 +2723,8 @@ void PSParallelCompact::compact() { update_deferred_objects(cm, SpaceId(id)); } } + + DEBUG_ONLY(write_block_fill_histogram(gclog_or_tty)); } #ifdef ASSERT @@ -3130,6 +3189,57 @@ void PSParallelCompact::fill_region(ParCompactionManager* cm, size_t region_idx) } while (true); } +void PSParallelCompact::fill_blocks(size_t region_idx) +{ + // Fill in the block table elements for the specified region. Each block + // table element holds the number of live words in the region that are to the + // left of the first object that starts in the block. Thus only blocks in + // which an object starts need to be filled. + // + // The algorithm scans the section of the bitmap that corresponds to the + // region, keeping a running total of the live words. When an object start is + // found, if it's the first to start in the block that contains it, the + // current total is written to the block table element. + const size_t Log2BlockSize = ParallelCompactData::Log2BlockSize; + const size_t Log2RegionSize = ParallelCompactData::Log2RegionSize; + const size_t RegionSize = ParallelCompactData::RegionSize; + + ParallelCompactData& sd = summary_data(); + const size_t partial_obj_size = sd.region(region_idx)->partial_obj_size(); + if (partial_obj_size >= RegionSize) { + return; // No objects start in this region. + } + + // Ensure the first loop iteration decides that the block has changed. + size_t cur_block = sd.block_count(); + + const ParMarkBitMap* const bitmap = mark_bitmap(); + + const size_t Log2BitsPerBlock = Log2BlockSize - LogMinObjAlignment; + assert((size_t)1 << Log2BitsPerBlock == + bitmap->words_to_bits(ParallelCompactData::BlockSize), "sanity"); + + size_t beg_bit = bitmap->words_to_bits(region_idx << Log2RegionSize); + const size_t range_end = beg_bit + bitmap->words_to_bits(RegionSize); + size_t live_bits = bitmap->words_to_bits(partial_obj_size); + beg_bit = bitmap->find_obj_beg(beg_bit + live_bits, range_end); + while (beg_bit < range_end) { + const size_t new_block = beg_bit >> Log2BitsPerBlock; + if (new_block != cur_block) { + cur_block = new_block; + sd.block(cur_block)->set_offset(bitmap->bits_to_words(live_bits)); + } + + const size_t end_bit = bitmap->find_obj_end(beg_bit, range_end); + if (end_bit < range_end - 1) { + live_bits += end_bit - beg_bit + 1; + beg_bit = bitmap->find_obj_beg(end_bit + 1, range_end); + } else { + return; + } + } +} + void PSParallelCompact::move_and_update(ParCompactionManager* cm, SpaceId space_id) { const MutableSpace* sp = space(space_id); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp index 79cd3f8933b..c3a00c7e232 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp @@ -220,6 +220,17 @@ public: // Mask for the bits in a pointer to get the address of the start of a region. static const size_t RegionAddrMask; + static const size_t Log2BlockSize; + static const size_t BlockSize; + static const size_t BlockSizeBytes; + + static const size_t BlockSizeOffsetMask; + static const size_t BlockAddrOffsetMask; + static const size_t BlockAddrMask; + + static const size_t BlocksPerRegion; + static const size_t Log2BlocksPerRegion; + class RegionData { public: @@ -272,6 +283,12 @@ public: inline uint destination_count() const; inline uint destination_count_raw() const; + // Whether the block table for this region has been filled. + inline bool blocks_filled() const; + + // Number of times the block table was filled. + DEBUG_ONLY(inline size_t blocks_filled_count() const;) + // The location of the java heap data that corresponds to this region. inline HeapWord* data_location() const; @@ -296,6 +313,7 @@ public: void set_partial_obj_size(size_t words) { _partial_obj_size = (region_sz_t) words; } + inline void set_blocks_filled(); inline void set_destination_count(uint count); inline void set_live_obj_size(size_t words); @@ -328,7 +346,11 @@ public: HeapWord* _partial_obj_addr; region_sz_t _partial_obj_size; region_sz_t volatile _dc_and_los; + bool _blocks_filled; + #ifdef ASSERT + size_t _blocks_filled_count; // Number of block table fills. + // These enable optimizations that are only partially implemented. Use // debug builds to prevent the code fragments from breaking. HeapWord* _data_location; @@ -337,11 +359,26 @@ public: #ifdef ASSERT public: - uint _pushed; // 0 until region is pushed onto a worker's stack + uint _pushed; // 0 until region is pushed onto a stack private: #endif }; + // "Blocks" allow shorter sections of the bitmap to be searched. Each Block + // holds an offset, which is the amount of live data in the Region to the left + // of the first live object that starts in the Block. + class BlockData + { + public: + typedef unsigned short int blk_ofs_t; + + blk_ofs_t offset() const { return _offset; } + void set_offset(size_t val) { _offset = (blk_ofs_t)val; } + + private: + blk_ofs_t _offset; + }; + public: ParallelCompactData(); bool initialize(MemRegion covered_region); @@ -353,8 +390,9 @@ public: inline RegionData* region(size_t region_idx) const; inline size_t region(const RegionData* const region_ptr) const; - // Returns true if the given address is contained within the region - bool region_contains(size_t region_index, HeapWord* addr); + size_t block_count() const { return _block_count; } + inline BlockData* block(size_t block_idx) const; + inline size_t block(const BlockData* block_ptr) const; void add_obj(HeapWord* addr, size_t len); void add_obj(oop p, size_t len) { add_obj((HeapWord*)p, len); } @@ -394,11 +432,24 @@ public: inline HeapWord* region_align_up(HeapWord* addr) const; inline bool is_region_aligned(HeapWord* addr) const; + // Analogous to region_offset() for blocks. + size_t block_offset(const HeapWord* addr) const; + size_t addr_to_block_idx(const HeapWord* addr) const; + size_t addr_to_block_idx(const oop obj) const { + return addr_to_block_idx((HeapWord*) obj); + } + inline BlockData* addr_to_block_ptr(const HeapWord* addr) const; + inline HeapWord* block_to_addr(size_t block) const; + inline size_t region_to_block_idx(size_t region) const; + + inline HeapWord* block_align_down(HeapWord* addr) const; + inline HeapWord* block_align_up(HeapWord* addr) const; + inline bool is_block_aligned(HeapWord* addr) const; + // Return the address one past the end of the partial object. HeapWord* partial_obj_end(size_t region_idx) const; - // Return the new location of the object p after the - // the compaction. + // Return the location of the object after compaction. HeapWord* calc_new_pointer(HeapWord* addr); HeapWord* calc_new_pointer(oop p) { @@ -411,6 +462,7 @@ public: #endif // #ifdef ASSERT private: + bool initialize_block_data(); bool initialize_region_data(size_t region_size); PSVirtualSpace* create_vspace(size_t count, size_t element_size); @@ -424,6 +476,10 @@ private: size_t _reserved_byte_size; RegionData* _region_data; size_t _region_count; + + PSVirtualSpace* _block_vspace; + BlockData* _block_data; + size_t _block_count; }; inline uint @@ -438,6 +494,28 @@ ParallelCompactData::RegionData::destination_count() const return destination_count_raw() >> dc_shift; } +inline bool +ParallelCompactData::RegionData::blocks_filled() const +{ + return _blocks_filled; +} + +#ifdef ASSERT +inline size_t +ParallelCompactData::RegionData::blocks_filled_count() const +{ + return _blocks_filled_count; +} +#endif // #ifdef ASSERT + +inline void +ParallelCompactData::RegionData::set_blocks_filled() +{ + _blocks_filled = true; + // Debug builds count the number of times the table was filled. + DEBUG_ONLY(Atomic::inc_ptr(&_blocks_filled_count)); +} + inline void ParallelCompactData::RegionData::set_destination_count(uint count) { @@ -532,6 +610,12 @@ ParallelCompactData::region(const RegionData* const region_ptr) const return pointer_delta(region_ptr, _region_data, sizeof(RegionData)); } +inline ParallelCompactData::BlockData* +ParallelCompactData::block(size_t n) const { + assert(n < block_count(), "bad arg"); + return _block_data + n; +} + inline size_t ParallelCompactData::region_offset(const HeapWord* addr) const { @@ -598,6 +682,63 @@ ParallelCompactData::is_region_aligned(HeapWord* addr) const return region_offset(addr) == 0; } +inline size_t +ParallelCompactData::block_offset(const HeapWord* addr) const +{ + assert(addr >= _region_start, "bad addr"); + assert(addr <= _region_end, "bad addr"); + return (size_t(addr) & BlockAddrOffsetMask) >> LogHeapWordSize; +} + +inline size_t +ParallelCompactData::addr_to_block_idx(const HeapWord* addr) const +{ + assert(addr >= _region_start, "bad addr"); + assert(addr <= _region_end, "bad addr"); + return pointer_delta(addr, _region_start) >> Log2BlockSize; +} + +inline ParallelCompactData::BlockData* +ParallelCompactData::addr_to_block_ptr(const HeapWord* addr) const +{ + return block(addr_to_block_idx(addr)); +} + +inline HeapWord* +ParallelCompactData::block_to_addr(size_t block) const +{ + assert(block < _block_count, "block out of range"); + return _region_start + (block << Log2BlockSize); +} + +inline size_t +ParallelCompactData::region_to_block_idx(size_t region) const +{ + return region << Log2BlocksPerRegion; +} + +inline HeapWord* +ParallelCompactData::block_align_down(HeapWord* addr) const +{ + assert(addr >= _region_start, "bad addr"); + assert(addr < _region_end + RegionSize, "bad addr"); + return (HeapWord*)(size_t(addr) & BlockAddrMask); +} + +inline HeapWord* +ParallelCompactData::block_align_up(HeapWord* addr) const +{ + assert(addr >= _region_start, "bad addr"); + assert(addr <= _region_end, "bad addr"); + return block_align_down(addr + BlockSizeOffsetMask); +} + +inline bool +ParallelCompactData::is_block_aligned(HeapWord* addr) const +{ + return block_offset(addr) == 0; +} + // Abstract closure for use with ParMarkBitMap::iterate(), which will invoke the // do_addr() method. // @@ -775,6 +916,7 @@ class PSParallelCompact : AllStatic { // Convenient access to type names. typedef ParMarkBitMap::idx_t idx_t; typedef ParallelCompactData::RegionData RegionData; + typedef ParallelCompactData::BlockData BlockData; typedef enum { old_space_id, eden_space_id, @@ -962,6 +1104,8 @@ class PSParallelCompact : AllStatic { // Adjust addresses in roots. Does not adjust addresses in heap. static void adjust_roots(); + DEBUG_ONLY(static void write_block_fill_histogram(outputStream* const out);) + // Move objects to new locations. static void compact_perm(ParCompactionManager* cm); static void compact(); @@ -1128,6 +1272,9 @@ class PSParallelCompact : AllStatic { fill_region(cm, region); } + // Fill in the block table for the specified region. + static void fill_blocks(size_t region_idx); + // Update the deferred objects in the space. static void update_deferred_objects(ParCompactionManager* cm, SpaceId id); From c39235c3779e48cc4d8c6ef147ab7af307d00faa Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Thu, 30 May 2013 10:58:16 +0200 Subject: [PATCH 067/206] 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops Compare compressed oops to a compressed young gen boundary instead of uncompressing the oops before doing the young gen boundary check. Reviewed-by: brutisso, jmasa --- .../psPromotionManager.inline.hpp | 2 +- .../parallelScavenge/psScavenge.cpp | 5 ++- .../parallelScavenge/psScavenge.hpp | 42 ++++++++++++------- .../parallelScavenge/psScavenge.inline.hpp | 8 ++-- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp index 8822a481b3d..96cd4cec706 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp @@ -42,7 +42,7 @@ inline void PSPromotionManager::claim_or_forward_internal_depth(T* p) { if (o->is_forwarded()) { o = o->forwardee(); // Card mark - if (PSScavenge::is_obj_in_young((HeapWord*) o)) { + if (PSScavenge::is_obj_in_young(o)) { PSScavenge::card_table()->inline_write_ref_field_gc(p, o); } oopDesc::encode_store_heap_oop_not_null(p, o); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp index f209a802b3d..96a679a6654 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp @@ -61,6 +61,7 @@ CardTableExtension* PSScavenge::_card_table = NULL; bool PSScavenge::_survivor_overflow = false; uint PSScavenge::_tenuring_threshold = 0; HeapWord* PSScavenge::_young_generation_boundary = NULL; +uintptr_t PSScavenge::_young_generation_boundary_compressed = 0; elapsedTimer PSScavenge::_accumulated_time; Stack PSScavenge::_preserved_mark_stack; Stack PSScavenge::_preserved_oop_stack; @@ -71,7 +72,7 @@ bool PSScavenge::_promotion_failed = false; class PSIsAliveClosure: public BoolObjectClosure { public: bool do_object_b(oop p) { - return (!PSScavenge::is_obj_in_young((HeapWord*) p)) || p->is_forwarded(); + return (!PSScavenge::is_obj_in_young(p)) || p->is_forwarded(); } }; @@ -815,7 +816,7 @@ void PSScavenge::initialize() { // Set boundary between young_gen and old_gen assert(old_gen->reserved().end() <= young_gen->eden_space()->bottom(), "old above young"); - _young_generation_boundary = young_gen->eden_space()->bottom(); + set_young_generation_boundary(young_gen->eden_space()->bottom()); // Initialize ref handling object for scavenging. MemRegion mr = young_gen->reserved(); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp index 43e59ac9cfb..7523f5bf603 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp @@ -62,19 +62,22 @@ class PSScavenge: AllStatic { protected: // Flags/counters - static ReferenceProcessor* _ref_processor; // Reference processor for scavenging. - static PSIsAliveClosure _is_alive_closure; // Closure used for reference processing - static CardTableExtension* _card_table; // We cache the card table for fast access. - static bool _survivor_overflow; // Overflow this collection - static uint _tenuring_threshold; // tenuring threshold for next scavenge - static elapsedTimer _accumulated_time; // total time spent on scavenge - static HeapWord* _young_generation_boundary; // The lowest address possible for the young_gen. - // This is used to decide if an oop should be scavenged, - // cards should be marked, etc. + static ReferenceProcessor* _ref_processor; // Reference processor for scavenging. + static PSIsAliveClosure _is_alive_closure; // Closure used for reference processing + static CardTableExtension* _card_table; // We cache the card table for fast access. + static bool _survivor_overflow; // Overflow this collection + static uint _tenuring_threshold; // tenuring threshold for next scavenge + static elapsedTimer _accumulated_time; // total time spent on scavenge + // The lowest address possible for the young_gen. + // This is used to decide if an oop should be scavenged, + // cards should be marked, etc. + static HeapWord* _young_generation_boundary; + // Used to optimize compressed oops young gen boundary checking. + static uintptr_t _young_generation_boundary_compressed; static Stack _preserved_mark_stack; // List of marks to be restored after failed promotion static Stack _preserved_oop_stack; // List of oops that need their mark restored. - static CollectorCounters* _counters; // collector performance counters - static bool _promotion_failed; + static CollectorCounters* _counters; // collector performance counters + static bool _promotion_failed; static void clean_up_failed_promotion(); @@ -112,6 +115,9 @@ class PSScavenge: AllStatic { // boundary moves, _young_generation_boundary must be reset static void set_young_generation_boundary(HeapWord* v) { _young_generation_boundary = v; + if (UseCompressedOops) { + _young_generation_boundary_compressed = (uintptr_t)oopDesc::encode_heap_oop((oop)v); + } } // Called by parallelScavengeHeap to init the tenuring threshold @@ -140,11 +146,19 @@ class PSScavenge: AllStatic { static void copy_and_push_safe_barrier_from_klass(PSPromotionManager* pm, oop* p); // Is an object in the young generation - // This assumes that the HeapWord argument is in the heap, + // This assumes that the 'o' is in the heap, // so it only checks one side of the complete predicate. + + inline static bool is_obj_in_young(oop o) { + return (HeapWord*)o >= _young_generation_boundary; + } + + inline static bool is_obj_in_young(narrowOop o) { + return (uintptr_t)o >= _young_generation_boundary_compressed; + } + inline static bool is_obj_in_young(HeapWord* o) { - const bool result = (o >= _young_generation_boundary); - return result; + return o >= _young_generation_boundary; } }; diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp index de015e8eb3d..e67dedf98d4 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp @@ -39,9 +39,7 @@ inline void PSScavenge::save_to_space_top_before_gc() { template inline bool PSScavenge::should_scavenge(T* p) { T heap_oop = oopDesc::load_heap_oop(p); - if (oopDesc::is_null(heap_oop)) return false; - oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); - return PSScavenge::is_obj_in_young((HeapWord*)obj); + return PSScavenge::is_obj_in_young(heap_oop); } template @@ -94,7 +92,7 @@ inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm, // or from metadata. if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) && Universe::heap()->is_in_reserved(p)) { - if (PSScavenge::is_obj_in_young((HeapWord*)new_obj)) { + if (PSScavenge::is_obj_in_young(new_obj)) { card_table()->inline_write_ref_field_gc(p, new_obj); } } @@ -147,7 +145,7 @@ class PSScavengeFromKlassClosure: public OopClosure { } oopDesc::encode_store_heap_oop_not_null(p, new_obj); - if (PSScavenge::is_obj_in_young((HeapWord*)new_obj)) { + if (PSScavenge::is_obj_in_young(new_obj)) { do_klass_barrier(); } } From 54964edefa5660b8252626d3e506d7b092718b73 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Tue, 28 May 2013 09:32:06 +0200 Subject: [PATCH 068/206] 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen Fixed the output of G1SummarizeRSetStats: too small datatype for the number of concurrently processed cards, added concurrent remembered set thread time retrieval for Linux and Windows (BSD uses os::elapsedTime() now), and other cleanup. The information presented during VM operation is now relative to the previous output, not always cumulative if G1SummarizeRSetStatsPeriod > 0. At VM exit, the code prints a cumulative summary. Reviewed-by: johnc, jwilhelm --- hotspot/make/excludeSrc.make | 2 +- hotspot/src/os/bsd/vm/os_bsd.cpp | 4 +- hotspot/src/os/linux/vm/os_linux.cpp | 22 +- hotspot/src/os/windows/vm/os_windows.cpp | 18 +- .../g1/concurrentG1Refine.cpp | 12 + .../g1/concurrentG1Refine.hpp | 9 +- .../gc_implementation/g1/g1CollectedHeap.cpp | 14 +- .../vm/gc_implementation/g1/g1RemSet.cpp | 102 ++------- .../vm/gc_implementation/g1/g1RemSet.hpp | 17 +- .../gc_implementation/g1/g1RemSetSummary.cpp | 205 ++++++++++++++++++ .../gc_implementation/g1/g1RemSetSummary.hpp | 118 ++++++++++ .../test/gc/g1/TestSummarizeRSetStats.java | 164 ++++++++++++++ 12 files changed, 585 insertions(+), 102 deletions(-) create mode 100644 hotspot/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp create mode 100644 hotspot/src/share/vm/gc_implementation/g1/g1RemSetSummary.hpp create mode 100644 hotspot/test/gc/g1/TestSummarizeRSetStats.java diff --git a/hotspot/make/excludeSrc.make b/hotspot/make/excludeSrc.make index df9bc302165..2ce60e0a656 100644 --- a/hotspot/make/excludeSrc.make +++ b/hotspot/make/excludeSrc.make @@ -87,7 +87,7 @@ ifeq ($(INCLUDE_ALL_GCS), false) g1BlockOffsetTable.cpp g1CardCounts.cpp g1CollectedHeap.cpp g1CollectorPolicy.cpp \ g1ErgoVerbose.cpp g1GCPhaseTimes.cpp g1HRPrinter.cpp g1HotCardCache.cpp g1Log.cpp \ g1MMUTracker.cpp g1MarkSweep.cpp g1MemoryPool.cpp g1MonitoringSupport.cpp \ - g1RemSet.cpp g1SATBCardTableModRefBS.cpp g1_globals.cpp heapRegion.cpp \ + g1RemSet.cpp g1RemSetSummary.cpp g1SATBCardTableModRefBS.cpp g1_globals.cpp heapRegion.cpp \ heapRegionRemSet.cpp heapRegionSeq.cpp heapRegionSet.cpp heapRegionSets.cpp \ ptrQueue.cpp satbQueue.cpp sparsePRT.cpp survRateGroup.cpp vm_operations_g1.cpp \ adjoiningGenerations.cpp adjoiningVirtualSpaces.cpp asPSOldGen.cpp asPSYoungGen.cpp \ diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index f0b32196f5d..220a5e74655 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -935,10 +935,10 @@ jlong os::elapsed_frequency() { return (1000 * 1000); } -// XXX: For now, code this as if BSD does not support vtime. -bool os::supports_vtime() { return false; } +bool os::supports_vtime() { return true; } bool os::enable_vtime() { return false; } bool os::vtime_enabled() { return false; } + double os::elapsedVTime() { // better than nothing, but not much return elapsedTime(); diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 4ca47019569..dbf30c48178 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -101,6 +101,12 @@ # include # include +// if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling +// getrusage() is prepared to handle the associated failure. +#ifndef RUSAGE_THREAD +#define RUSAGE_THREAD (1) /* only the calling thread */ +#endif + #define MAX_PATH (2 * K) // for timer info max values which include all bits @@ -1336,15 +1342,19 @@ jlong os::elapsed_frequency() { return (1000 * 1000); } -// For now, we say that linux does not support vtime. I have no idea -// whether it can actually be made to (DLD, 9/13/05). - -bool os::supports_vtime() { return false; } +bool os::supports_vtime() { return true; } bool os::enable_vtime() { return false; } bool os::vtime_enabled() { return false; } + double os::elapsedVTime() { - // better than nothing, but not much - return elapsedTime(); + struct rusage usage; + int retval = getrusage(RUSAGE_THREAD, &usage); + if (retval == 0) { + return (double) (usage.ru_utime.tv_sec + usage.ru_stime.tv_sec) + (double) (usage.ru_utime.tv_usec + usage.ru_stime.tv_usec) / (1000 * 1000); + } else { + // better than nothing, but not much + return elapsedTime(); + } } jlong os::javaTimeMillis() { diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 275dc3b809a..33ebe5987a1 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -813,15 +813,21 @@ FILETIME java_to_windows_time(jlong l) { return result; } -// For now, we say that Windows does not support vtime. I have no idea -// whether it can actually be made to (DLD, 9/13/05). - -bool os::supports_vtime() { return false; } +bool os::supports_vtime() { return true; } bool os::enable_vtime() { return false; } bool os::vtime_enabled() { return false; } + double os::elapsedVTime() { - // better than nothing, but not much - return elapsedTime(); + FILETIME created; + FILETIME exited; + FILETIME kernel; + FILETIME user; + if (GetThreadTimes(GetCurrentThread(), &created, &exited, &kernel, &user) != 0) { + // the resolution of windows_to_java_time() should be sufficient (ms) + return (double) (windows_to_java_time(kernel) + windows_to_java_time(user)) / MILLIUNITS; + } else { + return elapsedTime(); + } } jlong os::javaTimeMillis() { diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp index 5f049209e29..f0b4da8a885 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp @@ -114,6 +114,14 @@ void ConcurrentG1Refine::threads_do(ThreadClosure *tc) { } } +void ConcurrentG1Refine::worker_threads_do(ThreadClosure * tc) { + if (_threads != NULL) { + for (int i = 0; i < worker_thread_num(); i++) { + tc->do_thread(_threads[i]); + } + } +} + int ConcurrentG1Refine::thread_num() { int n_threads = (G1ConcRefinementThreads > 0) ? G1ConcRefinementThreads : ParallelGCThreads; @@ -126,3 +134,7 @@ void ConcurrentG1Refine::print_worker_threads_on(outputStream* st) const { st->cr(); } } + +ConcurrentG1RefineThread * ConcurrentG1Refine::sampling_thread() const { + return _threads[worker_thread_num()]; +} diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp index 46e6622eee7..3dc7c62423b 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp @@ -35,6 +35,7 @@ class ConcurrentG1RefineThread; class G1CollectedHeap; class G1HotCardCache; class G1RemSet; +class DirtyCardQueue; class ConcurrentG1Refine: public CHeapObj { ConcurrentG1RefineThread** _threads; @@ -78,9 +79,15 @@ class ConcurrentG1Refine: public CHeapObj { void reinitialize_threads(); - // Iterate over the conc refine threads + // Iterate over all concurrent refinement threads void threads_do(ThreadClosure *tc); + // Iterate over all worker refinement threads + void worker_threads_do(ThreadClosure * tc); + + // The RS sampling thread + ConcurrentG1RefineThread * sampling_thread() const; + static int thread_num(); void print_worker_threads_on(outputStream* st) const; diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index c95cf0a0452..aff2d5da607 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -3539,6 +3539,14 @@ void G1CollectedHeap::gc_prologue(bool full /* Ignored */) { } void G1CollectedHeap::gc_epilogue(bool full /* Ignored */) { + + if (G1SummarizeRSetStats && + (G1SummarizeRSetStatsPeriod > 0) && + // we are at the end of the GC. Total collections has already been increased. + ((total_collections() - 1) % G1SummarizeRSetStatsPeriod == 0)) { + g1_rem_set()->print_periodic_summary_info(); + } + // FIXME: what is this about? // I'm ignoring the "fill_newgen()" call if "alloc_event_enabled" // is set. @@ -4093,12 +4101,6 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { g1mm()->update_sizes(); } - if (G1SummarizeRSetStats && - (G1SummarizeRSetStatsPeriod > 0) && - (total_collections() % G1SummarizeRSetStatsPeriod == 0)) { - g1_rem_set()->print_summary_info(); - } - // It should now be safe to tell the concurrent mark thread to start // without its logging output interfering with the logging output // that came from the pause. diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp index d527a3fc61d..ae4c6b63510 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp @@ -34,6 +34,7 @@ #include "gc_implementation/g1/g1OopClosures.inline.hpp" #include "gc_implementation/g1/g1RemSet.inline.hpp" #include "gc_implementation/g1/heapRegionSeq.inline.hpp" +#include "gc_implementation/g1/heapRegionRemSet.hpp" #include "memory/iterator.hpp" #include "oops/oop.inline.hpp" #include "utilities/intHisto.hpp" @@ -73,7 +74,8 @@ G1RemSet::G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs) _ct_bs(ct_bs), _g1p(_g1->g1_policy()), _cg1r(g1->concurrent_g1_refine()), _cset_rs_update_cl(NULL), - _cards_scanned(NULL), _total_cards_scanned(0) + _cards_scanned(NULL), _total_cards_scanned(0), + _prev_period_summary() { _seq_task = new SubTasksDone(NumSeqTasks); guarantee(n_workers() > 0, "There should be some workers"); @@ -81,6 +83,7 @@ G1RemSet::G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs) for (uint i = 0; i < n_workers(); i++) { _cset_rs_update_cl[i] = NULL; } + _prev_period_summary.initialize(this, n_workers()); } G1RemSet::~G1RemSet() { @@ -697,47 +700,29 @@ bool G1RemSet::refine_card(jbyte* card_ptr, int worker_i, return has_refs_into_cset; } -class HRRSStatsIter: public HeapRegionClosure { - size_t _occupied; - size_t _total_mem_sz; - size_t _max_mem_sz; - HeapRegion* _max_mem_sz_region; -public: - HRRSStatsIter() : - _occupied(0), - _total_mem_sz(0), - _max_mem_sz(0), - _max_mem_sz_region(NULL) - {} +void G1RemSet::print_periodic_summary_info() { + G1RemSetSummary current; + current.initialize(this, n_workers()); - bool doHeapRegion(HeapRegion* r) { - if (r->continuesHumongous()) return false; - size_t mem_sz = r->rem_set()->mem_size(); - if (mem_sz > _max_mem_sz) { - _max_mem_sz = mem_sz; - _max_mem_sz_region = r; - } - _total_mem_sz += mem_sz; - size_t occ = r->rem_set()->occupied(); - _occupied += occ; - return false; - } - size_t total_mem_sz() { return _total_mem_sz; } - size_t max_mem_sz() { return _max_mem_sz; } - size_t occupied() { return _occupied; } - HeapRegion* max_mem_sz_region() { return _max_mem_sz_region; } -}; + _prev_period_summary.subtract_from(¤t); + print_summary_info(&_prev_period_summary); -class PrintRSThreadVTimeClosure : public ThreadClosure { -public: - virtual void do_thread(Thread *t) { - ConcurrentG1RefineThread* crt = (ConcurrentG1RefineThread*) t; - gclog_or_tty->print(" %5.2f", crt->vtime_accum()); - } -}; + _prev_period_summary.set(¤t); +} void G1RemSet::print_summary_info() { - G1CollectedHeap* g1 = G1CollectedHeap::heap(); + G1RemSetSummary current; + current.initialize(this, n_workers()); + + print_summary_info(¤t, " Cumulative RS summary"); +} + +void G1RemSet::print_summary_info(G1RemSetSummary * summary, const char * header) { + assert(summary != NULL, "just checking"); + + if (header != NULL) { + gclog_or_tty->print_cr("%s", header); + } #if CARD_REPEAT_HISTO gclog_or_tty->print_cr("\nG1 card_repeat count histogram: "); @@ -745,46 +730,7 @@ void G1RemSet::print_summary_info() { card_repeat_count.print_on(gclog_or_tty); #endif - gclog_or_tty->print_cr("\n Concurrent RS processed %d cards", - _conc_refine_cards); - DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); - jint tot_processed_buffers = - dcqs.processed_buffers_mut() + dcqs.processed_buffers_rs_thread(); - gclog_or_tty->print_cr(" Of %d completed buffers:", tot_processed_buffers); - gclog_or_tty->print_cr(" %8d (%5.1f%%) by conc RS threads.", - dcqs.processed_buffers_rs_thread(), - 100.0*(float)dcqs.processed_buffers_rs_thread()/ - (float)tot_processed_buffers); - gclog_or_tty->print_cr(" %8d (%5.1f%%) by mutator threads.", - dcqs.processed_buffers_mut(), - 100.0*(float)dcqs.processed_buffers_mut()/ - (float)tot_processed_buffers); - gclog_or_tty->print_cr(" Conc RS threads times(s)"); - PrintRSThreadVTimeClosure p; - gclog_or_tty->print(" "); - g1->concurrent_g1_refine()->threads_do(&p); - gclog_or_tty->print_cr(""); - - HRRSStatsIter blk; - g1->heap_region_iterate(&blk); - gclog_or_tty->print_cr(" Total heap region rem set sizes = "SIZE_FORMAT"K." - " Max = "SIZE_FORMAT"K.", - blk.total_mem_sz()/K, blk.max_mem_sz()/K); - gclog_or_tty->print_cr(" Static structures = "SIZE_FORMAT"K," - " free_lists = "SIZE_FORMAT"K.", - HeapRegionRemSet::static_mem_size() / K, - HeapRegionRemSet::fl_mem_size() / K); - gclog_or_tty->print_cr(" "SIZE_FORMAT" occupied cards represented.", - blk.occupied()); - HeapRegion* max_mem_sz_region = blk.max_mem_sz_region(); - HeapRegionRemSet* rem_set = max_mem_sz_region->rem_set(); - gclog_or_tty->print_cr(" Max size region = "HR_FORMAT", " - "size = "SIZE_FORMAT "K, occupied = "SIZE_FORMAT"K.", - HR_FORMAT_PARAMS(max_mem_sz_region), - (rem_set->mem_size() + K - 1)/K, - (rem_set->occupied() + K - 1)/K); - gclog_or_tty->print_cr(" Did %d coarsenings.", - HeapRegionRemSet::n_coarsenings()); + summary->print_on(gclog_or_tty); } void G1RemSet::prepare_for_verify() { diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp index 7444ae819fc..954381f9138 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp @@ -25,6 +25,8 @@ #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSET_HPP #define SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSET_HPP +#include "gc_implementation/g1/g1RemSetSummary.hpp" + // A G1RemSet provides ways of iterating over pointers into a selected // collection set. @@ -37,9 +39,11 @@ class ConcurrentG1Refine; // so that they can be used to update the individual region remsets. class G1RemSet: public CHeapObj { +private: + G1RemSetSummary _prev_period_summary; protected: G1CollectedHeap* _g1; - unsigned _conc_refine_cards; + size_t _conc_refine_cards; uint n_workers(); protected: @@ -66,6 +70,8 @@ protected: // references into the collection set. OopsInHeapRegionClosure** _cset_rs_update_cl; + // Print the given summary info + virtual void print_summary_info(G1RemSetSummary * summary, const char * header = NULL); public: // This is called to reset dual hash tables after the gc pause // is finished and the initial hash table is no longer being @@ -123,11 +129,18 @@ public: int worker_i, bool check_for_refs_into_cset); - // Print any relevant summary info. + // Print accumulated summary info from the start of the VM. virtual void print_summary_info(); + // Print accumulated summary info from the last time called. + virtual void print_periodic_summary_info(); + // Prepare remembered set for verification. virtual void prepare_for_verify(); + + size_t conc_refine_cards() const { + return _conc_refine_cards; + } }; class CountNonCleanMemRegionClosure: public MemRegionClosure { diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp new file mode 100644 index 00000000000..13acd1b0da8 --- /dev/null +++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp @@ -0,0 +1,205 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "gc_implementation/g1/concurrentG1Refine.hpp" +#include "gc_implementation/g1/concurrentG1RefineThread.hpp" +#include "gc_implementation/g1/heapRegion.hpp" +#include "gc_implementation/g1/g1CollectedHeap.inline.hpp" +#include "gc_implementation/g1/g1RemSet.inline.hpp" +#include "gc_implementation/g1/g1RemSetSummary.hpp" +#include "gc_implementation/g1/heapRegionRemSet.hpp" +#include "runtime/thread.inline.hpp" + +class GetRSThreadVTimeClosure : public ThreadClosure { +private: + G1RemSetSummary* _summary; + uint _counter; + +public: + GetRSThreadVTimeClosure(G1RemSetSummary * summary) : ThreadClosure(), _summary(summary), _counter(0) { + assert(_summary != NULL, "just checking"); + } + + virtual void do_thread(Thread* t) { + ConcurrentG1RefineThread* crt = (ConcurrentG1RefineThread*) t; + _summary->set_rs_thread_vtime(_counter, crt->vtime_accum()); + _counter++; + } +}; + +void G1RemSetSummary::update() { + _num_refined_cards = remset()->conc_refine_cards(); + DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); + _num_processed_buf_mutator = dcqs.processed_buffers_mut(); + _num_processed_buf_rs_threads = dcqs.processed_buffers_rs_thread(); + + _num_coarsenings = HeapRegionRemSet::n_coarsenings(); + + ConcurrentG1Refine * cg1r = G1CollectedHeap::heap()->concurrent_g1_refine(); + if (_rs_threads_vtimes != NULL) { + GetRSThreadVTimeClosure p(this); + cg1r->worker_threads_do(&p); + } + set_sampling_thread_vtime(cg1r->sampling_thread()->vtime_accum()); +} + +void G1RemSetSummary::set_rs_thread_vtime(uint thread, double value) { + assert(_rs_threads_vtimes != NULL, "just checking"); + assert(thread < _num_vtimes, "just checking"); + _rs_threads_vtimes[thread] = value; +} + +double G1RemSetSummary::rs_thread_vtime(uint thread) const { + assert(_rs_threads_vtimes != NULL, "just checking"); + assert(thread < _num_vtimes, "just checking"); + return _rs_threads_vtimes[thread]; +} + +void G1RemSetSummary::initialize(G1RemSet* remset, uint num_workers) { + assert(_rs_threads_vtimes == NULL, "just checking"); + assert(remset != NULL, "just checking"); + + _remset = remset; + _num_vtimes = num_workers; + _rs_threads_vtimes = NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC); + memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes); + + update(); +} + +void G1RemSetSummary::set(G1RemSetSummary* other) { + assert(other != NULL, "just checking"); + assert(remset() == other->remset(), "just checking"); + assert(_num_vtimes == other->_num_vtimes, "just checking"); + + _num_refined_cards = other->num_concurrent_refined_cards(); + + _num_processed_buf_mutator = other->num_processed_buf_mutator(); + _num_processed_buf_rs_threads = other->num_processed_buf_rs_threads(); + + _num_coarsenings = other->_num_coarsenings; + + memcpy(_rs_threads_vtimes, other->_rs_threads_vtimes, sizeof(double) * _num_vtimes); + + set_sampling_thread_vtime(other->sampling_thread_vtime()); +} + +void G1RemSetSummary::subtract_from(G1RemSetSummary* other) { + assert(other != NULL, "just checking"); + assert(remset() == other->remset(), "just checking"); + assert(_num_vtimes == other->_num_vtimes, "just checking"); + + _num_refined_cards = other->num_concurrent_refined_cards() - _num_refined_cards; + + _num_processed_buf_mutator = other->num_processed_buf_mutator() - _num_processed_buf_mutator; + _num_processed_buf_rs_threads = other->num_processed_buf_rs_threads() - _num_processed_buf_rs_threads; + + _num_coarsenings = other->num_coarsenings() - _num_coarsenings; + + for (uint i = 0; i < _num_vtimes; i++) { + set_rs_thread_vtime(i, other->rs_thread_vtime(i) - rs_thread_vtime(i)); + } + + _sampling_thread_vtime = other->sampling_thread_vtime() - _sampling_thread_vtime; +} + +class HRRSStatsIter: public HeapRegionClosure { + size_t _occupied; + size_t _total_mem_sz; + size_t _max_mem_sz; + HeapRegion* _max_mem_sz_region; +public: + HRRSStatsIter() : + _occupied(0), + _total_mem_sz(0), + _max_mem_sz(0), + _max_mem_sz_region(NULL) + {} + + bool doHeapRegion(HeapRegion* r) { + size_t mem_sz = r->rem_set()->mem_size(); + if (mem_sz > _max_mem_sz) { + _max_mem_sz = mem_sz; + _max_mem_sz_region = r; + } + _total_mem_sz += mem_sz; + size_t occ = r->rem_set()->occupied(); + _occupied += occ; + return false; + } + size_t total_mem_sz() { return _total_mem_sz; } + size_t max_mem_sz() { return _max_mem_sz; } + size_t occupied() { return _occupied; } + HeapRegion* max_mem_sz_region() { return _max_mem_sz_region; } +}; + +double calc_percentage(size_t numerator, size_t denominator) { + if (denominator != 0) { + return (double)numerator / denominator * 100.0; + } else { + return 0.0f; + } +} + +void G1RemSetSummary::print_on(outputStream* out) { + out->print_cr("\n Concurrent RS processed "SIZE_FORMAT" cards", + num_concurrent_refined_cards()); + out->print_cr(" Of %d completed buffers:", num_processed_buf_total()); + out->print_cr(" %8d (%5.1f%%) by concurrent RS threads.", + num_processed_buf_total(), + calc_percentage(num_processed_buf_rs_threads(), num_processed_buf_total())); + out->print_cr(" %8d (%5.1f%%) by mutator threads.", + num_processed_buf_mutator(), + calc_percentage(num_processed_buf_mutator(), num_processed_buf_total())); + out->print_cr(" Concurrent RS threads times (s)"); + out->print(" "); + for (uint i = 0; i < _num_vtimes; i++) { + out->print(" %5.2f", rs_thread_vtime(i)); + } + out->cr(); + out->print_cr(" Concurrent sampling threads times (s)"); + out->print_cr(" %5.2f", sampling_thread_vtime()); + + HRRSStatsIter blk; + G1CollectedHeap::heap()->heap_region_iterate(&blk); + out->print_cr(" Total heap region rem set sizes = "SIZE_FORMAT"K." + " Max = "SIZE_FORMAT"K.", + blk.total_mem_sz()/K, blk.max_mem_sz()/K); + out->print_cr(" Static structures = "SIZE_FORMAT"K," + " free_lists = "SIZE_FORMAT"K.", + HeapRegionRemSet::static_mem_size() / K, + HeapRegionRemSet::fl_mem_size() / K); + out->print_cr(" "SIZE_FORMAT" occupied cards represented.", + blk.occupied()); + HeapRegion* max_mem_sz_region = blk.max_mem_sz_region(); + HeapRegionRemSet* rem_set = max_mem_sz_region->rem_set(); + out->print_cr(" Max size region = "HR_FORMAT", " + "size = "SIZE_FORMAT "K, occupied = "SIZE_FORMAT"K.", + HR_FORMAT_PARAMS(max_mem_sz_region), + (rem_set->mem_size() + K - 1)/K, + (rem_set->occupied() + K - 1)/K); + + out->print_cr(" Did %d coarsenings.", num_coarsenings()); +} diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1RemSetSummary.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1RemSetSummary.hpp new file mode 100644 index 00000000000..7f5f377637a --- /dev/null +++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSetSummary.hpp @@ -0,0 +1,118 @@ +/* + * 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. + * + */ + +#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSETSUMMARY_HPP +#define SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSETSUMMARY_HPP + +#include "utilities/ostream.hpp" + +class G1RemSet; + +// A G1RemSetSummary manages statistical information about the G1RemSet + +class G1RemSetSummary VALUE_OBJ_CLASS_SPEC { +private: + friend class GetRSThreadVTimeClosure; + + G1RemSet* _remset; + + G1RemSet* remset() const { + return _remset; + } + + size_t _num_refined_cards; + size_t _num_processed_buf_mutator; + size_t _num_processed_buf_rs_threads; + + size_t _num_coarsenings; + + double* _rs_threads_vtimes; + size_t _num_vtimes; + + double _sampling_thread_vtime; + + void set_rs_thread_vtime(uint thread, double value); + void set_sampling_thread_vtime(double value) { + _sampling_thread_vtime = value; + } + + void free_and_null() { + if (_rs_threads_vtimes) { + FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes, mtGC); + _rs_threads_vtimes = NULL; + _num_vtimes = 0; + } + } + + // update this summary with current data from various places + void update(); + +public: + G1RemSetSummary() : _remset(NULL), _num_refined_cards(0), + _num_processed_buf_mutator(0), _num_processed_buf_rs_threads(0), _num_coarsenings(0), + _rs_threads_vtimes(NULL), _num_vtimes(0), _sampling_thread_vtime(0.0f) { + } + + ~G1RemSetSummary() { + free_and_null(); + } + + // set the counters in this summary to the values of the others + void set(G1RemSetSummary* other); + // subtract all counters from the other summary, and set them in the current + void subtract_from(G1RemSetSummary* other); + + // initialize and get the first sampling + void initialize(G1RemSet* remset, uint num_workers); + + void print_on(outputStream* out); + + double rs_thread_vtime(uint thread) const; + + double sampling_thread_vtime() const { + return _sampling_thread_vtime; + } + + size_t num_concurrent_refined_cards() const { + return _num_refined_cards; + } + + size_t num_processed_buf_mutator() const { + return _num_processed_buf_mutator; + } + + size_t num_processed_buf_rs_threads() const { + return _num_processed_buf_rs_threads; + } + + size_t num_processed_buf_total() const { + return num_processed_buf_mutator() + num_processed_buf_rs_threads(); + } + + size_t num_coarsenings() const { + return _num_coarsenings; + } +}; + +#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSETSUMMARY_HPP diff --git a/hotspot/test/gc/g1/TestSummarizeRSetStats.java b/hotspot/test/gc/g1/TestSummarizeRSetStats.java new file mode 100644 index 00000000000..1990d4c6f39 --- /dev/null +++ b/hotspot/test/gc/g1/TestSummarizeRSetStats.java @@ -0,0 +1,164 @@ +/* + * 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 TestSummarizeRSetStats.java + * @bug 8013895 + * @library /testlibrary + * @build TestSummarizeRSetStats + * @summary Verify output of -XX:+G1SummarizeRSetStats + * @run main TestSummarizeRSetStats + * + * Test the output of G1SummarizeRSetStats in conjunction with G1SummarizeRSetStatsPeriod. + */ + +import com.oracle.java.testlibrary.*; +import java.lang.Thread; +import java.util.ArrayList; +import java.util.Arrays; + +class RunSystemGCs { + // 4M size, both are directly allocated into the old gen + static Object[] largeObject1 = new Object[1024 * 1024]; + static Object[] largeObject2 = new Object[1024 * 1024]; + + static int[] temp; + + public static void main(String[] args) { + // create some cross-references between these objects + for (int i = 0; i < largeObject1.length; i++) { + largeObject1[i] = largeObject2; + } + + for (int i = 0; i < largeObject2.length; i++) { + largeObject2[i] = largeObject1; + } + + int numGCs = Integer.parseInt(args[0]); + + if (numGCs > 0) { + // try to force a minor collection: the young gen is 4M, the + // amount of data allocated below is roughly that (4*1024*1024 + + // some header data) + for (int i = 0; i < 1024 ; i++) { + temp = new int[1024]; + } + } + + for (int i = 0; i < numGCs - 1; i++) { + System.gc(); + } + } +} + +public class TestSummarizeRSetStats { + + public static String runTest(String[] additionalArgs, int numGCs) throws Exception { + ArrayList finalargs = new ArrayList(); + String[] defaultArgs = new String[] { + "-XX:+UseG1GC", + "-Xmn4m", + "-Xmx20m", + "-XX:InitiatingHeapOccupancyPercent=100", // we don't want the additional GCs due to initial marking + "-XX:+PrintGC", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:G1HeapRegionSize=1M", + }; + + finalargs.addAll(Arrays.asList(defaultArgs)); + + if (additionalArgs != null) { + finalargs.addAll(Arrays.asList(additionalArgs)); + } + + finalargs.add(RunSystemGCs.class.getName()); + finalargs.add(String.valueOf(numGCs)); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + finalargs.toArray(new String[0])); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + output.shouldHaveExitValue(0); + + String result = output.getStdout(); + return result; + } + + private static void expectStatistics(String result, int expectedCumulative, int expectedPeriodic) throws Exception { + int actualTotal = result.split("Concurrent RS processed").length - 1; + int actualCumulative = result.split("Cumulative RS summary").length - 1; + + if (expectedCumulative != actualCumulative) { + throw new Exception("Incorrect amount of RSet summaries at the end. Expected " + expectedCumulative + ", got " + actualCumulative); + } + + if (expectedPeriodic != (actualTotal - actualCumulative)) { + throw new Exception("Incorrect amount of per-period RSet summaries at the end. Expected " + expectedPeriodic + ", got " + (actualTotal - actualCumulative)); + } + } + + public static void main(String[] args) throws Exception { + String result; + + // no RSet statistics output + result = runTest(null, 0); + expectStatistics(result, 0, 0); + + // no RSet statistics output + result = runTest(null, 2); + expectStatistics(result, 0, 0); + + // no RSet statistics output + result = runTest(new String[] { "-XX:G1SummarizeRSetStatsPeriod=1" }, 3); + expectStatistics(result, 0, 0); + + // single RSet statistics output at the end + result = runTest(new String[] { "-XX:+G1SummarizeRSetStats" }, 0); + expectStatistics(result, 1, 0); + + // single RSet statistics output at the end + result = runTest(new String[] { "-XX:+G1SummarizeRSetStats" }, 2); + expectStatistics(result, 1, 0); + + // single RSet statistics output + result = runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=1" }, 0); + expectStatistics(result, 1, 0); + + // two times RSet statistics output + result = runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=1" }, 1); + expectStatistics(result, 1, 1); + + // four times RSet statistics output + result = runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=1" }, 3); + expectStatistics(result, 1, 3); + + // three times RSet statistics output + result = runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=2" }, 3); + expectStatistics(result, 1, 2); + + // single RSet statistics output + result = runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=100" }, 3); + expectStatistics(result, 1, 1); + } +} + From d2583c85157ed7e30fcb741459f56d36c1360d81 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 28 May 2013 16:37:11 +0530 Subject: [PATCH 069/206] 8015459: Octane test run fails on Turkish locale Reviewed-by: lagergren, attila --- nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java | 3 ++- nashorn/src/jdk/nashorn/internal/objects/DateParser.java | 5 +++-- nashorn/src/jdk/nashorn/internal/parser/TokenType.java | 3 ++- .../src/jdk/nashorn/internal/runtime/GlobalFunctions.java | 5 +++-- nashorn/src/jdk/nashorn/internal/runtime/JSType.java | 3 ++- nashorn/src/jdk/nashorn/internal/runtime/Logging.java | 3 ++- nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java | 3 ++- .../jdk/nashorn/internal/runtime/options/OptionTemplate.java | 2 +- 8 files changed, 17 insertions(+), 10 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index aae2fd2df7c..21b61cd8ec5 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -58,6 +58,7 @@ import java.util.EnumSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.TreeMap; import jdk.nashorn.internal.codegen.ClassEmitter.Flag; @@ -2220,7 +2221,7 @@ final class CodeGenerator extends NodeOperatorVisitor { this.params = arg; break; case "type": - this.type = arg.toLowerCase(Locale.ROOT); + this.type = arg.toLowerCase(Locale.ENGLISH); break; case "default": this.defaultValue = arg; From e58031cebaedb81897301900e64d72745e498c6f Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Tue, 28 May 2013 12:46:10 +0100 Subject: [PATCH 070/206] 6970173: Debug pointer at bad position Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/Lower.java | 2 +- .../DebugPointerAtBadPositionTest.java | 112 ++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 langtools/test/tools/javac/T6970173/DebugPointerAtBadPositionTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java index 98ee76968d2..2e08b47b618 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java @@ -2931,7 +2931,7 @@ public class Lower extends TreeTranslator { } result = make.If(cond, - make_at(detailPos). + make_at(tree). Throw(makeNewClass(syms.assertionErrorType, exnArgs)), null); } else { diff --git a/langtools/test/tools/javac/T6970173/DebugPointerAtBadPositionTest.java b/langtools/test/tools/javac/T6970173/DebugPointerAtBadPositionTest.java new file mode 100644 index 00000000000..a66f7ca93d1 --- /dev/null +++ b/langtools/test/tools/javac/T6970173/DebugPointerAtBadPositionTest.java @@ -0,0 +1,112 @@ +/* + * 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 6970173 + * @summary Debug pointer at bad position + * @library /tools/javac/lib + * @build ToolBox + * @run main DebugPointerAtBadPositionTest + */ + +import java.io.File; +import java.nio.file.Paths; + +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.Code_attribute; +import com.sun.tools.classfile.LineNumberTable_attribute; +import com.sun.tools.classfile.Method; +import com.sun.tools.javac.util.Assert; + +public class DebugPointerAtBadPositionTest { + + static final String testSource = + "public class AssertionTest {\n" + + " void lookForThisMethod() {\n" + + " int i;\n" + + " i = 33;\n" + + " assert // line 5\n" + + " i < 89:\n" + + " i < 100; // line 7\n" + + " }\n" + + "}"; + + static final int[][] expectedLNT = { + {4, 0}, + {5, 3}, + {8, 34} + }; + + static final String methodToLookFor = "lookForThisMethod"; + static final String seekMethodNotFoundMsg = + "The seek method was not found"; + static final String foundLNTLengthDifferentThanExpMsg = + "The LineNumberTable found has a length different to the expected one"; + + public static void main(String[] args) throws Exception { + new DebugPointerAtBadPositionTest().run(); + } + + void run() throws Exception { + compileTestClass(); + checkClassFile(new File(Paths.get(System.getProperty("user.dir"), + "AssertionTest.class").toUri()), methodToLookFor); + } + + void compileTestClass() throws Exception { + ToolBox.JavaToolArgs javacSuccessArgs = + new ToolBox.JavaToolArgs().setSources(testSource); + ToolBox.javac(javacSuccessArgs); + } + + void checkClassFile(final File cfile, String methodToFind) throws Exception { + ClassFile classFile = ClassFile.read(cfile); + boolean methodFound = false; + for (Method method : classFile.methods) { + if (method.getName(classFile.constant_pool).equals(methodToFind)) { + methodFound = true; + Code_attribute code = (Code_attribute) method.attributes.get("Code"); + LineNumberTable_attribute lnt = + (LineNumberTable_attribute) code.attributes.get("LineNumberTable"); + Assert.check(lnt.line_number_table_length == expectedLNT.length, + foundLNTLengthDifferentThanExpMsg); + int i = 0; + for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) { + Assert.check(entry.line_number == expectedLNT[i][0] && + entry.start_pc == expectedLNT[i][1], + "LNT entry at pos " + i + " differ from expected." + + "Found " + entry.line_number + ":" + entry.start_pc + + ". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]); + i++; + } + } + } + Assert.check(methodFound, seekMethodNotFoundMsg); + } + + void error(String msg) { + throw new AssertionError(msg); + } + +} From 7f2a2f1460e0c397e9a867ccd2efe382f4093535 Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Tue, 28 May 2013 15:08:57 +0200 Subject: [PATCH 071/206] 8015329: Print reason for failed MiniDumpWriteDump() call Printing both result from GetLastError and text representation of error. Also changed so that we produce dumps by default on client versions of Windows when running with a debug build. Also reviewed by peter.allwin@oracle.com Reviewed-by: sla, dholmes --- hotspot/src/os/windows/vm/os_windows.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 5a05d416a98..275dc3b809a 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -944,6 +944,8 @@ void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* MINIDUMP_TYPE dumpType; static const char* cwd; +// Default is to always create dump for debug builds, on product builds only dump on server versions of Windows. +#ifndef ASSERT // If running on a client version of Windows and user has not explicitly enabled dumping if (!os::win32::is_windows_server() && !CreateMinidumpOnCrash) { VMError::report_coredump_status("Minidumps are not enabled by default on client versions of Windows", false); @@ -953,6 +955,12 @@ void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* VMError::report_coredump_status("Minidump has been disabled from the command line", false); return; } +#else + if (!FLAG_IS_DEFAULT(CreateMinidumpOnCrash) && !CreateMinidumpOnCrash) { + VMError::report_coredump_status("Minidump has been disabled from the command line", false); + return; + } +#endif dbghelp = os::win32::load_Windows_dll("DBGHELP.DLL", NULL, 0); @@ -1004,7 +1012,21 @@ void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* // the dump types we really want. If first call fails, lets fall back to just use MiniDumpWithFullMemory then. if (_MiniDumpWriteDump(hProcess, processId, dumpFile, dumpType, pmei, NULL, NULL) == false && _MiniDumpWriteDump(hProcess, processId, dumpFile, (MINIDUMP_TYPE)MiniDumpWithFullMemory, pmei, NULL, NULL) == false) { - VMError::report_coredump_status("Call to MiniDumpWriteDump() failed", false); + DWORD error = GetLastError(); + LPTSTR msgbuf = NULL; + + if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, error, 0, (LPTSTR)&msgbuf, 0, NULL) != 0) { + + jio_snprintf(buffer, bufferSize, "Call to MiniDumpWriteDump() failed (Error 0x%x: %s)", error, msgbuf); + LocalFree(msgbuf); + } else { + // Call to FormatMessage failed, just include the result from GetLastError + jio_snprintf(buffer, bufferSize, "Call to MiniDumpWriteDump() failed (Error 0x%x)", error); + } + VMError::report_coredump_status(buffer, false); } else { VMError::report_coredump_status(buffer, true); } From b0dcc34e06089cd76a0c85f39b0ed0d88418c33c Mon Sep 17 00:00:00 2001 From: Joseph Provino Date: Tue, 28 May 2013 11:17:16 -0400 Subject: [PATCH 072/206] 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release AsyncGetCallTrace is needed in libjvm.symbols so that programs which reference it can build correctly. Reviewed-by: dholmes, bobv --- hotspot/make/excludeSrc.make | 2 +- hotspot/src/share/vm/prims/forte.cpp | 38 ++++++++++++++++++---------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/hotspot/make/excludeSrc.make b/hotspot/make/excludeSrc.make index 93f68ee41c0..df9bc302165 100644 --- a/hotspot/make/excludeSrc.make +++ b/hotspot/make/excludeSrc.make @@ -25,7 +25,7 @@ ifeq ($(INCLUDE_JVMTI), false) CXXFLAGS += -DINCLUDE_JVMTI=0 CFLAGS += -DINCLUDE_JVMTI=0 - Src_Files_EXCLUDE += jvmtiGetLoadedClasses.cpp forte.cpp jvmtiThreadState.cpp jvmtiExtensions.cpp \ + Src_Files_EXCLUDE += jvmtiGetLoadedClasses.cpp jvmtiThreadState.cpp jvmtiExtensions.cpp \ jvmtiImpl.cpp jvmtiManageCapabilities.cpp jvmtiRawMonitor.cpp jvmtiUtil.cpp jvmtiTrace.cpp \ jvmtiCodeBlobEvents.cpp jvmtiEnv.cpp jvmtiRedefineClasses.cpp jvmtiEnvBase.cpp jvmtiEnvThreadState.cpp \ jvmtiTagMap.cpp jvmtiEventController.cpp evmCompat.cpp jvmtiEnter.xsl jvmtiExport.cpp \ diff --git a/hotspot/src/share/vm/prims/forte.cpp b/hotspot/src/share/vm/prims/forte.cpp index 33419f29836..737dcecd0e1 100644 --- a/hotspot/src/share/vm/prims/forte.cpp +++ b/hotspot/src/share/vm/prims/forte.cpp @@ -35,6 +35,19 @@ #include "runtime/vframe.hpp" #include "runtime/vframeArray.hpp" +// call frame copied from old .h file and renamed +typedef struct { + jint lineno; // line number in the source file + jmethodID method_id; // method executed in this frame +} ASGCT_CallFrame; + +// call trace copied from old .h file and renamed +typedef struct { + JNIEnv *env_id; // Env where trace was recorded + jint num_frames; // number of frames in this trace + ASGCT_CallFrame *frames; // frames +} ASGCT_CallTrace; + // These name match the names reported by the forte quality kit enum { ticks_no_Java_frame = 0, @@ -50,6 +63,8 @@ enum { ticks_safepoint = -10 }; +#if INCLUDE_JVMTI + //------------------------------------------------------- // Native interfaces for use by Forte tools. @@ -360,20 +375,6 @@ static bool find_initial_Java_frame(JavaThread* thread, } - -// call frame copied from old .h file and renamed -typedef struct { - jint lineno; // line number in the source file - jmethodID method_id; // method executed in this frame -} ASGCT_CallFrame; - -// call trace copied from old .h file and renamed -typedef struct { - JNIEnv *env_id; // Env where trace was recorded - jint num_frames; // number of frames in this trace - ASGCT_CallFrame *frames; // frames -} ASGCT_CallTrace; - static void forte_fill_call_trace_given_top(JavaThread* thd, ASGCT_CallTrace* trace, int depth, @@ -634,3 +635,12 @@ void Forte::register_stub(const char* name, address start, address end) { pointer_delta(end, start, sizeof(jbyte)), 0, NULL); #endif // !_WINDOWS && !IA64 } + +#else // INCLUDE_JVMTI +extern "C" { + JNIEXPORT + void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) { + trace->num_frames = ticks_no_class_load; // -1 + } +} +#endif // INCLUDE_JVMTI From 8d4061812f566f10543125e7dd12f0aa932c856c Mon Sep 17 00:00:00 2001 From: Joseph Provino Date: Tue, 28 May 2013 11:32:46 -0400 Subject: [PATCH 073/206] 8011064: Some tests have failed with SIGSEGV on arm-hflt on build b82 NMT_detail is only supported when frame pointers are not omitted (-fno-omit-frame-pointer). Reviewed-by: dholmes, cjplummer --- hotspot/src/share/vm/services/memTracker.cpp | 11 ++++++++++- hotspot/src/share/vm/utilities/globalDefinitions.hpp | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/services/memTracker.cpp b/hotspot/src/share/vm/services/memTracker.cpp index a89de2f40af..0e6f7c42e57 100644 --- a/hotspot/src/share/vm/services/memTracker.cpp +++ b/hotspot/src/share/vm/services/memTracker.cpp @@ -34,6 +34,7 @@ #include "services/memReporter.hpp" #include "services/memTracker.hpp" #include "utilities/decoder.hpp" +#include "utilities/defaultStream.hpp" #include "utilities/globalDefinitions.hpp" bool NMT_track_callsite = false; @@ -77,7 +78,15 @@ void MemTracker::init_tracking_options(const char* option_line) { if (strcmp(option_line, "=summary") == 0) { _tracking_level = NMT_summary; } else if (strcmp(option_line, "=detail") == 0) { - _tracking_level = NMT_detail; + // detail relies on a stack-walking ability that may not + // be available depending on platform and/or compiler flags + if (PLATFORM_NMT_DETAIL_SUPPORTED) { + _tracking_level = NMT_detail; + } else { + jio_fprintf(defaultStream::error_stream(), + "NMT detail is not supported on this platform. Using NMT summary instead."); + _tracking_level = NMT_summary; + } } else if (strcmp(option_line, "=off") != 0) { vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL); } diff --git a/hotspot/src/share/vm/utilities/globalDefinitions.hpp b/hotspot/src/share/vm/utilities/globalDefinitions.hpp index 5609ffdf431..d9088307a97 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp @@ -380,6 +380,14 @@ const uint64_t KlassEncodingMetaspaceMax = (uint64_t(max_juint) + 1) << LogKlass # include "globalDefinitions_ppc.hpp" #endif +/* + * If a platform does not support NMT_detail + * the platform specific globalDefinitions (above) + * can set PLATFORM_NMT_DETAIL_SUPPORTED to false + */ +#ifndef PLATFORM_NMT_DETAIL_SUPPORTED +#define PLATFORM_NMT_DETAIL_SUPPORTED true +#endif // The byte alignment to be used by Arena::Amalloc. See bugid 4169348. // Note: this value must be a power of 2 From 0793ab7e650022fa61ef49a27021ecc5218e12bd Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 28 May 2013 19:54:18 +0400 Subject: [PATCH 074/206] 8015493: runtime/contended/OopMaps.java fails with OutOfMemory Limit the memory footprint to dodge OutOfMemory errors. Reviewed-by: dcubed, ctornqvi, iignatyev --- hotspot/test/runtime/contended/OopMaps.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hotspot/test/runtime/contended/OopMaps.java b/hotspot/test/runtime/contended/OopMaps.java index b8dfbba416b..8faa0bee2ac 100644 --- a/hotspot/test/runtime/contended/OopMaps.java +++ b/hotspot/test/runtime/contended/OopMaps.java @@ -41,12 +41,15 @@ import sun.misc.Contended; /* * @test * @bug 8015270 + * @bug 8015493 * @summary \@Contended: fix multiple issues in the layout code * - * @run main/othervm -XX:-RestrictContended OopMaps + * @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMaps */ public class OopMaps { + public static final int COUNT = 10000; + public static void main(String[] args) throws Exception { Object o01 = new Object(); Object o02 = new Object(); @@ -63,7 +66,6 @@ public class OopMaps { Object o13 = new Object(); Object o14 = new Object(); - final int COUNT = 100000; R1[] rs = new R1[COUNT]; for (int i = 0; i < COUNT; i++) { From bbae50582f86f8da3e13b8479a1a36e285be831b Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Tue, 28 May 2013 17:39:41 +0100 Subject: [PATCH 075/206] 8012333: javac, ClassFile should have a read(Path) method Reviewed-by: jjg --- .../share/classes/com/sun/tools/classfile/ClassFile.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/langtools/src/share/classes/com/sun/tools/classfile/ClassFile.java b/langtools/src/share/classes/com/sun/tools/classfile/ClassFile.java index 9a68f617365..e8b5fc8d85a 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/ClassFile.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/ClassFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -29,6 +29,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Path; import static com.sun.tools.classfile.AccessFlags.*; @@ -46,6 +47,11 @@ public class ClassFile { return read(file, new Attribute.Factory()); } + public static ClassFile read(Path path) + throws IOException, ConstantPoolException { + return read(path.toFile(), new Attribute.Factory()); + } + public static ClassFile read(File file, Attribute.Factory attributeFactory) throws IOException, ConstantPoolException { FileInputStream in = new FileInputStream(file); From ee0d343130f058a87a008c402c747f0f375fb99a Mon Sep 17 00:00:00 2001 From: Klara Ward Date: Tue, 28 May 2013 20:03:21 +0200 Subject: [PATCH 076/206] 8014762: Add JMC configure option mapping to Jprt.gmk Need to add the mapping between JPRT env var and configure flag for JMC, from ALT_JMC_ZIP_DIR to --with-jmc-zip-dir (same pattern as for Javafx) Reviewed-by: tbell, erikj --- common/autoconf/generated-configure.sh | 38 +++++++++++++------------- common/makefiles/Jprt.gmk | 3 ++ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 832b6410016..8fb1be7c79a 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -2844,7 +2844,7 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;} || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi done @@ -3775,7 +3775,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1367502949 +DATE_WHEN_GENERATED=1369764185 ############################################################################### # @@ -6608,7 +6608,7 @@ fi $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -6641,7 +6641,7 @@ fi $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -6674,7 +6674,7 @@ fi $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5 ;; +*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' @@ -19747,7 +19747,7 @@ fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -19862,7 +19862,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -19905,7 +19905,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -19964,7 +19964,7 @@ $as_echo "$ac_try_echo"; } >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi fi fi @@ -20016,7 +20016,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -24191,7 +24191,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=cpp @@ -24591,7 +24591,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=cpp @@ -28426,7 +28426,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int *) -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_int_p=0 fi @@ -29640,7 +29640,7 @@ if test "x$with_x" = xno; then have_x=disabled else case $x_includes,$x_libraries in #( - *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5 ;; #( + *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #( *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -32295,7 +32295,7 @@ and LIBFFI_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else LIBFFI_CFLAGS=$pkg_cv_LIBFFI_CFLAGS LIBFFI_LIBS=$pkg_cv_LIBFFI_LIBS @@ -33825,7 +33825,7 @@ do "$OUTPUT_ROOT/spec.sh") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/spec.sh:$AUTOCONF_DIR/spec.sh.in" ;; "$OUTPUT_ROOT/Makefile") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in" ;; - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -34140,7 +34140,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -34168,7 +34168,7 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -34195,7 +34195,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac diff --git a/common/makefiles/Jprt.gmk b/common/makefiles/Jprt.gmk index c38dedce1f5..576f34d4b4d 100644 --- a/common/makefiles/Jprt.gmk +++ b/common/makefiles/Jprt.gmk @@ -127,6 +127,9 @@ else ifdef ALT_JAVAFX_ZIP_DIR @$(ECHO) " --with-javafx-zip-dir=$(call UnixPath,$(ALT_JAVAFX_ZIP_DIR)) " >> $@.tmp endif + ifdef ALT_JMC_ZIP_DIR + @$(ECHO) " --with-jmc-zip-dir=$(call UnixPath,$(ALT_JMC_ZIP_DIR)) " >> $@.tmp + endif ifdef ALT_WIXDIR @$(ECHO) " --with-wix=$(call UnixPath,$(ALT_WIXDIR)) " >> $@.tmp endif From 9dc36eb9234346e83d1fb2f95265719eac891bf1 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Tue, 28 May 2013 16:36:19 -0700 Subject: [PATCH 077/206] 8014912: Restore PrintSharedSpaces functionality after NPG Added dumping of object sizes in CDS archive, sorted by MetaspaceObj::Type Reviewed-by: coleenp, acorn --- hotspot/src/share/vm/memory/allocation.cpp | 5 +- hotspot/src/share/vm/memory/allocation.hpp | 49 +++++- hotspot/src/share/vm/memory/metaspace.cpp | 80 +++++++--- hotspot/src/share/vm/memory/metaspace.hpp | 30 +++- .../src/share/vm/memory/metaspaceShared.cpp | 149 ++++++++++++++++++ hotspot/src/share/vm/oops/annotations.cpp | 2 +- hotspot/src/share/vm/oops/constMethod.cpp | 2 +- hotspot/src/share/vm/oops/constantPool.cpp | 2 +- hotspot/src/share/vm/oops/cpCache.cpp | 3 +- hotspot/src/share/vm/oops/klass.cpp | 2 +- hotspot/src/share/vm/oops/method.cpp | 2 +- hotspot/src/share/vm/oops/methodCounters.cpp | 2 +- hotspot/src/share/vm/oops/methodData.cpp | 3 +- hotspot/src/share/vm/oops/symbol.cpp | 2 +- hotspot/src/share/vm/utilities/array.hpp | 4 +- 15 files changed, 301 insertions(+), 36 deletions(-) diff --git a/hotspot/src/share/vm/memory/allocation.cpp b/hotspot/src/share/vm/memory/allocation.cpp index a6721c9e76f..6b08c13e5f4 100644 --- a/hotspot/src/share/vm/memory/allocation.cpp +++ b/hotspot/src/share/vm/memory/allocation.cpp @@ -60,10 +60,11 @@ void* _ValueObj::operator new [](size_t size) { ShouldNotCallThis(); return 0; void _ValueObj::operator delete [](void* p) { ShouldNotCallThis(); } void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data, - size_t word_size, bool read_only, TRAPS) { + size_t word_size, bool read_only, + MetaspaceObj::Type type, TRAPS) { // Klass has it's own operator new return Metaspace::allocate(loader_data, word_size, read_only, - Metaspace::NonClassType, CHECK_NULL); + type, CHECK_NULL); } bool MetaspaceObj::is_shared() const { diff --git a/hotspot/src/share/vm/memory/allocation.hpp b/hotspot/src/share/vm/memory/allocation.hpp index 2955943b3f6..ebdb29cd26c 100644 --- a/hotspot/src/share/vm/memory/allocation.hpp +++ b/hotspot/src/share/vm/memory/allocation.hpp @@ -268,8 +268,55 @@ class MetaspaceObj { bool is_shared() const; void print_address_on(outputStream* st) const; // nonvirtual address printing +#define METASPACE_OBJ_TYPES_DO(f) \ + f(Unknown) \ + f(Class) \ + f(Symbol) \ + f(TypeArrayU1) \ + f(TypeArrayU2) \ + f(TypeArrayU4) \ + f(TypeArrayU8) \ + f(TypeArrayOther) \ + f(Method) \ + f(ConstMethod) \ + f(MethodData) \ + f(ConstantPool) \ + f(ConstantPoolCache) \ + f(Annotation) \ + f(MethodCounters) + +#define METASPACE_OBJ_TYPE_DECLARE(name) name ## Type, +#define METASPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name; + + enum Type { + // Types are MetaspaceObj::ClassType, MetaspaceObj::SymbolType, etc + METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_DECLARE) + _number_of_types + }; + + static const char * type_name(Type type) { + switch(type) { + METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_NAME_CASE) + default: + ShouldNotReachHere(); + return NULL; + } + } + + static MetaspaceObj::Type array_type(size_t elem_size) { + switch (elem_size) { + case 1: return TypeArrayU1Type; + case 2: return TypeArrayU2Type; + case 4: return TypeArrayU4Type; + case 8: return TypeArrayU8Type; + default: + return TypeArrayOtherType; + } + } + void* operator new(size_t size, ClassLoaderData* loader_data, - size_t word_size, bool read_only, Thread* thread); + size_t word_size, bool read_only, + Type type, Thread* thread); // can't use TRAPS from this header file. void operator delete(void* p) { ShouldNotCallThis(); } }; diff --git a/hotspot/src/share/vm/memory/metaspace.cpp b/hotspot/src/share/vm/memory/metaspace.cpp index 4be4658cad9..c840b9363ef 100644 --- a/hotspot/src/share/vm/memory/metaspace.cpp +++ b/hotspot/src/share/vm/memory/metaspace.cpp @@ -713,6 +713,23 @@ class SpaceManager : public CHeapObj { #ifdef ASSERT void verify_allocated_blocks_words(); #endif + + size_t get_raw_word_size(size_t word_size) { + // If only the dictionary is going to be used (i.e., no + // indexed free list), then there is a minimum size requirement. + // MinChunkSize is a placeholder for the real minimum size JJJ + size_t byte_size = word_size * BytesPerWord; + + size_t byte_size_with_overhead = byte_size + Metablock::overhead(); + + size_t raw_bytes_size = MAX2(byte_size_with_overhead, + Metablock::min_block_byte_size()); + raw_bytes_size = ARENA_ALIGN(raw_bytes_size); + size_t raw_word_size = raw_bytes_size / BytesPerWord; + assert(raw_word_size * BytesPerWord == raw_bytes_size, "Size problem"); + + return raw_word_size; + } }; uint const SpaceManager::_small_chunk_limit = 4; @@ -2320,19 +2337,7 @@ Metachunk* SpaceManager::get_new_chunk(size_t word_size, MetaWord* SpaceManager::allocate(size_t word_size) { MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); - // If only the dictionary is going to be used (i.e., no - // indexed free list), then there is a minimum size requirement. - // MinChunkSize is a placeholder for the real minimum size JJJ - size_t byte_size = word_size * BytesPerWord; - - size_t byte_size_with_overhead = byte_size + Metablock::overhead(); - - size_t raw_bytes_size = MAX2(byte_size_with_overhead, - Metablock::min_block_byte_size()); - raw_bytes_size = ARENA_ALIGN(raw_bytes_size); - size_t raw_word_size = raw_bytes_size / BytesPerWord; - assert(raw_word_size * BytesPerWord == raw_bytes_size, "Size problem"); - + size_t raw_word_size = get_raw_word_size(word_size); BlockFreelist* fl = block_freelists(); MetaWord* p = NULL; // Allocation from the dictionary is expensive in the sense that @@ -2896,6 +2901,9 @@ void Metaspace::initialize(Mutex* lock, if (class_chunk != NULL) { class_vsm()->add_chunk(class_chunk, true); } + + _alloc_record_head = NULL; + _alloc_record_tail = NULL; } size_t Metaspace::align_word_size_up(size_t word_size) { @@ -3000,12 +3008,14 @@ void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) { } Metablock* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, - bool read_only, MetadataType mdtype, TRAPS) { + bool read_only, MetaspaceObj::Type type, TRAPS) { if (HAS_PENDING_EXCEPTION) { assert(false, "Should not allocate with exception pending"); return NULL; // caller does a CHECK_NULL too } + MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType; + // SSS: Should we align the allocations and make sure the sizes are aligned. MetaWord* result = NULL; @@ -3015,13 +3025,13 @@ Metablock* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, // with the SymbolTable_lock. Dumping is single threaded for now. We'll have // to revisit this for application class data sharing. if (DumpSharedSpaces) { - if (read_only) { - result = loader_data->ro_metaspace()->allocate(word_size, NonClassType); - } else { - result = loader_data->rw_metaspace()->allocate(word_size, NonClassType); - } + assert(type > MetaspaceObj::UnknownType && type < MetaspaceObj::_number_of_types, "sanity"); + Metaspace* space = read_only ? loader_data->ro_metaspace() : loader_data->rw_metaspace(); + result = space->allocate(word_size, NonClassType); if (result == NULL) { report_out_of_shared_space(read_only ? SharedReadOnly : SharedReadWrite); + } else { + space->record_allocation(result, type, space->vsm()->get_raw_word_size(word_size)); } return Metablock::initialize(result, word_size); } @@ -3056,6 +3066,38 @@ Metablock* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, return Metablock::initialize(result, word_size); } +void Metaspace::record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size) { + assert(DumpSharedSpaces, "sanity"); + + AllocRecord *rec = new AllocRecord((address)ptr, type, (int)word_size * HeapWordSize); + if (_alloc_record_head == NULL) { + _alloc_record_head = _alloc_record_tail = rec; + } else { + _alloc_record_tail->_next = rec; + _alloc_record_tail = rec; + } +} + +void Metaspace::iterate(Metaspace::AllocRecordClosure *closure) { + assert(DumpSharedSpaces, "unimplemented for !DumpSharedSpaces"); + + address last_addr = (address)bottom(); + + for (AllocRecord *rec = _alloc_record_head; rec; rec = rec->_next) { + address ptr = rec->_ptr; + if (last_addr < ptr) { + closure->doit(last_addr, MetaspaceObj::UnknownType, ptr - last_addr); + } + closure->doit(ptr, rec->_type, rec->_byte_size); + last_addr = ptr + rec->_byte_size; + } + + address top = ((address)bottom()) + used_bytes_slow(Metaspace::NonClassType); + if (last_addr < top) { + closure->doit(last_addr, MetaspaceObj::UnknownType, top - last_addr); + } +} + void Metaspace::purge() { MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); diff --git a/hotspot/src/share/vm/memory/metaspace.hpp b/hotspot/src/share/vm/memory/metaspace.hpp index 7d8e0d9410e..70acbb1667f 100644 --- a/hotspot/src/share/vm/memory/metaspace.hpp +++ b/hotspot/src/share/vm/memory/metaspace.hpp @@ -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 @@ -127,6 +127,23 @@ class Metaspace : public CHeapObj { static VirtualSpaceList* space_list() { return _space_list; } static VirtualSpaceList* class_space_list() { return _class_space_list; } + // This is used by DumpSharedSpaces only, where only _vsm is used. So we will + // maintain a single list for now. + void record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size); + + class AllocRecord : public CHeapObj { + public: + AllocRecord(address ptr, MetaspaceObj::Type type, int byte_size) + : _next(NULL), _ptr(ptr), _type(type), _byte_size(byte_size) {} + AllocRecord *_next; + address _ptr; + MetaspaceObj::Type _type; + int _byte_size; + }; + + AllocRecord * _alloc_record_head; + AllocRecord * _alloc_record_tail; + public: Metaspace(Mutex* lock, MetaspaceType type); @@ -148,8 +165,8 @@ class Metaspace : public CHeapObj { size_t used_bytes_slow(MetadataType mdtype) const; size_t capacity_bytes_slow(MetadataType mdtype) const; - static Metablock* allocate(ClassLoaderData* loader_data, size_t size, - bool read_only, MetadataType mdtype, TRAPS); + static Metablock* allocate(ClassLoaderData* loader_data, size_t word_size, + bool read_only, MetaspaceObj::Type type, TRAPS); void deallocate(MetaWord* ptr, size_t byte_size, bool is_class); MetaWord* expand_and_allocate(size_t size, @@ -166,6 +183,13 @@ class Metaspace : public CHeapObj { void print_on(outputStream* st) const; // Debugging support void verify(); + + class AllocRecordClosure : public StackObj { + public: + virtual void doit(address ptr, MetaspaceObj::Type type, int byte_size) = 0; + }; + + void iterate(AllocRecordClosure *closure); }; class MetaspaceAux : AllStatic { diff --git a/hotspot/src/share/vm/memory/metaspaceShared.cpp b/hotspot/src/share/vm/memory/metaspaceShared.cpp index 5f0f152e975..d2c91827485 100644 --- a/hotspot/src/share/vm/memory/metaspaceShared.cpp +++ b/hotspot/src/share/vm/memory/metaspaceShared.cpp @@ -243,6 +243,147 @@ public: bool reading() const { return false; } }; +// This is for dumping detailed statistics for the allocations +// in the shared spaces. +class DumpAllocClosure : public Metaspace::AllocRecordClosure { +public: + + // Here's poor man's enum inheritance +#define SHAREDSPACE_OBJ_TYPES_DO(f) \ + METASPACE_OBJ_TYPES_DO(f) \ + f(SymbolHashentry) \ + f(SymbolBuckets) \ + f(Other) + +#define SHAREDSPACE_OBJ_TYPE_DECLARE(name) name ## Type, +#define SHAREDSPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name; + + enum Type { + // Types are MetaspaceObj::ClassType, MetaspaceObj::SymbolType, etc + SHAREDSPACE_OBJ_TYPES_DO(SHAREDSPACE_OBJ_TYPE_DECLARE) + _number_of_types + }; + + static const char * type_name(Type type) { + switch(type) { + SHAREDSPACE_OBJ_TYPES_DO(SHAREDSPACE_OBJ_TYPE_NAME_CASE) + default: + ShouldNotReachHere(); + return NULL; + } + } + +public: + enum { + RO = 0, + RW = 1 + }; + + int _counts[2][_number_of_types]; + int _bytes [2][_number_of_types]; + int _which; + + DumpAllocClosure() { + memset(_counts, 0, sizeof(_counts)); + memset(_bytes, 0, sizeof(_bytes)); + }; + + void iterate_metaspace(Metaspace* space, int which) { + assert(which == RO || which == RW, "sanity"); + _which = which; + space->iterate(this); + } + + virtual void doit(address ptr, MetaspaceObj::Type type, int byte_size) { + assert(int(type) >= 0 && type < MetaspaceObj::_number_of_types, "sanity"); + _counts[_which][type] ++; + _bytes [_which][type] += byte_size; + } + + void dump_stats(int ro_all, int rw_all, int md_all, int mc_all); +}; + +void DumpAllocClosure::dump_stats(int ro_all, int rw_all, int md_all, int mc_all) { + rw_all += (md_all + mc_all); // md and mc are all mapped Read/Write + int other_bytes = md_all + mc_all; + + // Calculate size of data that was not allocated by Metaspace::allocate() + int symbol_count = _counts[RO][MetaspaceObj::SymbolType]; + int symhash_bytes = symbol_count * sizeof (HashtableEntry); + int symbuck_count = SymbolTable::the_table()->table_size(); + int symbuck_bytes = symbuck_count * sizeof(HashtableBucket); + + _counts[RW][SymbolHashentryType] = symbol_count; + _bytes [RW][SymbolHashentryType] = symhash_bytes; + other_bytes -= symhash_bytes; + + _counts[RW][SymbolBucketsType] = symbuck_count; + _bytes [RW][SymbolBucketsType] = symbuck_bytes; + other_bytes -= symbuck_bytes; + + // TODO: count things like dictionary, vtable, etc + _bytes[RW][OtherType] = other_bytes; + + // prevent divide-by-zero + if (ro_all < 1) { + ro_all = 1; + } + if (rw_all < 1) { + rw_all = 1; + } + + int all_ro_count = 0; + int all_ro_bytes = 0; + int all_rw_count = 0; + int all_rw_bytes = 0; + + const char *fmt = "%-20s: %8d %10d %5.1f | %8d %10d %5.1f | %8d %10d %5.1f"; + const char *sep = "--------------------+---------------------------+---------------------------+--------------------------"; + const char *hdr = " ro_cnt ro_bytes % | rw_cnt rw_bytes % | all_cnt all_bytes %"; + + tty->print_cr("Detailed metadata info (rw includes md and mc):"); + tty->print_cr(hdr); + tty->print_cr(sep); + for (int type = 0; type < int(_number_of_types); type ++) { + const char *name = type_name((Type)type); + int ro_count = _counts[RO][type]; + int ro_bytes = _bytes [RO][type]; + int rw_count = _counts[RW][type]; + int rw_bytes = _bytes [RW][type]; + int count = ro_count + rw_count; + int bytes = ro_bytes + rw_bytes; + + double ro_perc = 100.0 * double(ro_bytes) / double(ro_all); + double rw_perc = 100.0 * double(rw_bytes) / double(rw_all); + double perc = 100.0 * double(bytes) / double(ro_all + rw_all); + + tty->print_cr(fmt, name, + ro_count, ro_bytes, ro_perc, + rw_count, rw_bytes, rw_perc, + count, bytes, perc); + + all_ro_count += ro_count; + all_ro_bytes += ro_bytes; + all_rw_count += rw_count; + all_rw_bytes += rw_bytes; + } + + int all_count = all_ro_count + all_rw_count; + int all_bytes = all_ro_bytes + all_rw_bytes; + + double all_ro_perc = 100.0 * double(all_ro_bytes) / double(ro_all); + double all_rw_perc = 100.0 * double(all_rw_bytes) / double(rw_all); + double all_perc = 100.0 * double(all_bytes) / double(ro_all + rw_all); + + tty->print_cr(sep); + tty->print_cr(fmt, "Total", + all_ro_count, all_ro_bytes, all_ro_perc, + all_rw_count, all_rw_bytes, all_rw_perc, + all_count, all_bytes, all_perc); + + assert(all_ro_bytes == ro_all, "everything should have been counted"); + assert(all_rw_bytes == rw_all, "everything should have been counted"); +} // Populate the shared space. @@ -454,6 +595,14 @@ void VM_PopulateDumpSharedSpace::doit() { mapinfo->close(); memmove(vtbl_list, saved_vtbl, vtbl_list_size * sizeof(void*)); + + if (PrintSharedSpaces) { + DumpAllocClosure dac; + dac.iterate_metaspace(_loader_data->ro_metaspace(), DumpAllocClosure::RO); + dac.iterate_metaspace(_loader_data->rw_metaspace(), DumpAllocClosure::RW); + + dac.dump_stats(int(ro_bytes), int(rw_bytes), int(md_bytes), int(mc_bytes)); + } } static void link_shared_classes(Klass* obj, TRAPS) { diff --git a/hotspot/src/share/vm/oops/annotations.cpp b/hotspot/src/share/vm/oops/annotations.cpp index 546257a17df..1eb3afbb740 100644 --- a/hotspot/src/share/vm/oops/annotations.cpp +++ b/hotspot/src/share/vm/oops/annotations.cpp @@ -33,7 +33,7 @@ // Allocate annotations in metadata area Annotations* Annotations::allocate(ClassLoaderData* loader_data, TRAPS) { - return new (loader_data, size(), true, THREAD) Annotations(); + return new (loader_data, size(), true, MetaspaceObj::AnnotationType, THREAD) Annotations(); } // helper diff --git a/hotspot/src/share/vm/oops/constMethod.cpp b/hotspot/src/share/vm/oops/constMethod.cpp index 1d0376a0b74..22f3b87da5a 100644 --- a/hotspot/src/share/vm/oops/constMethod.cpp +++ b/hotspot/src/share/vm/oops/constMethod.cpp @@ -40,7 +40,7 @@ ConstMethod* ConstMethod::allocate(ClassLoaderData* loader_data, MethodType method_type, TRAPS) { int size = ConstMethod::size(byte_code_size, sizes); - return new (loader_data, size, true, THREAD) ConstMethod( + return new (loader_data, size, true, MetaspaceObj::ConstMethodType, THREAD) ConstMethod( byte_code_size, sizes, method_type, size); } diff --git a/hotspot/src/share/vm/oops/constantPool.cpp b/hotspot/src/share/vm/oops/constantPool.cpp index fe1d7340e47..c2879e2d02a 100644 --- a/hotspot/src/share/vm/oops/constantPool.cpp +++ b/hotspot/src/share/vm/oops/constantPool.cpp @@ -55,7 +55,7 @@ ConstantPool* ConstantPool::allocate(ClassLoaderData* loader_data, int length, T // the resolved_references array, which is recreated at startup time. // But that could be moved to InstanceKlass (although a pain to access from // assembly code). Maybe it could be moved to the cpCache which is RW. - return new (loader_data, size, false, THREAD) ConstantPool(tags); + return new (loader_data, size, false, MetaspaceObj::ConstantPoolType, THREAD) ConstantPool(tags); } ConstantPool::ConstantPool(Array* tags) { diff --git a/hotspot/src/share/vm/oops/cpCache.cpp b/hotspot/src/share/vm/oops/cpCache.cpp index bc15e282b77..9e2b83c2caf 100644 --- a/hotspot/src/share/vm/oops/cpCache.cpp +++ b/hotspot/src/share/vm/oops/cpCache.cpp @@ -542,7 +542,8 @@ ConstantPoolCache* ConstantPoolCache::allocate(ClassLoaderData* loader_data, const intStack& invokedynamic_map, TRAPS) { int size = ConstantPoolCache::size(length); - return new (loader_data, size, false, THREAD) ConstantPoolCache(length, index_map, invokedynamic_map); + return new (loader_data, size, false, MetaspaceObj::ConstantPoolCacheType, THREAD) + ConstantPoolCache(length, index_map, invokedynamic_map); } void ConstantPoolCache::initialize(const intArray& inverse_index_map, diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp index 5c334206b97..f7a7334afb1 100644 --- a/hotspot/src/share/vm/oops/klass.cpp +++ b/hotspot/src/share/vm/oops/klass.cpp @@ -140,7 +140,7 @@ Method* Klass::uncached_lookup_method(Symbol* name, Symbol* signature) const { void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) { return Metaspace::allocate(loader_data, word_size, /*read_only*/false, - Metaspace::ClassType, CHECK_NULL); + MetaspaceObj::ClassType, CHECK_NULL); } Klass::Klass() { diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index 62b81ea4e93..1e8b1c3bb41 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -74,7 +74,7 @@ Method* Method::allocate(ClassLoaderData* loader_data, int size = Method::size(access_flags.is_native()); - return new (loader_data, size, false, THREAD) Method(cm, access_flags, size); + return new (loader_data, size, false, MetaspaceObj::MethodType, THREAD) Method(cm, access_flags, size); } Method::Method(ConstMethod* xconst, AccessFlags access_flags, int size) { diff --git a/hotspot/src/share/vm/oops/methodCounters.cpp b/hotspot/src/share/vm/oops/methodCounters.cpp index 53d3e682b77..1ee8eb17001 100644 --- a/hotspot/src/share/vm/oops/methodCounters.cpp +++ b/hotspot/src/share/vm/oops/methodCounters.cpp @@ -26,7 +26,7 @@ #include "runtime/thread.inline.hpp" MethodCounters* MethodCounters::allocate(ClassLoaderData* loader_data, TRAPS) { - return new(loader_data, size(), false, THREAD) MethodCounters(); + return new(loader_data, size(), false, MetaspaceObj::MethodCountersType, THREAD) MethodCounters(); } void MethodCounters::clear_counters() { diff --git a/hotspot/src/share/vm/oops/methodData.cpp b/hotspot/src/share/vm/oops/methodData.cpp index 73f70bac9d3..89a4cd4aa6b 100644 --- a/hotspot/src/share/vm/oops/methodData.cpp +++ b/hotspot/src/share/vm/oops/methodData.cpp @@ -388,7 +388,8 @@ void ArgInfoData::print_data_on(outputStream* st) { MethodData* MethodData::allocate(ClassLoaderData* loader_data, methodHandle method, TRAPS) { int size = MethodData::compute_allocation_size_in_words(method); - return new (loader_data, size, false, THREAD) MethodData(method(), size, CHECK_NULL); + return new (loader_data, size, false, MetaspaceObj::MethodDataType, THREAD) + MethodData(method(), size, CHECK_NULL); } int MethodData::bytecode_cell_count(Bytecodes::Code code) { diff --git a/hotspot/src/share/vm/oops/symbol.cpp b/hotspot/src/share/vm/oops/symbol.cpp index 253d0df887c..8ee933bf135 100644 --- a/hotspot/src/share/vm/oops/symbol.cpp +++ b/hotspot/src/share/vm/oops/symbol.cpp @@ -55,7 +55,7 @@ void* Symbol::operator new(size_t sz, int len, ClassLoaderData* loader_data, TRA address res; int alloc_size = size(len)*HeapWordSize; res = (address) Metaspace::allocate(loader_data, size(len), true, - Metaspace::NonClassType, CHECK_NULL); + MetaspaceObj::SymbolType, CHECK_NULL); return res; } diff --git a/hotspot/src/share/vm/utilities/array.hpp b/hotspot/src/share/vm/utilities/array.hpp index 5578ed9b61f..048a5781269 100644 --- a/hotspot/src/share/vm/utilities/array.hpp +++ b/hotspot/src/share/vm/utilities/array.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -320,7 +320,7 @@ protected: void* operator new(size_t size, ClassLoaderData* loader_data, int length, bool read_only, TRAPS) { size_t word_size = Array::size(length); return (void*) Metaspace::allocate(loader_data, word_size, read_only, - Metaspace::NonClassType, CHECK_NULL); + MetaspaceObj::array_type(sizeof(T)), CHECK_NULL); } static size_t byte_sizeof(int length) { return sizeof(Array) + MAX2(length - 1, 0) * sizeof(T); } From 33f5aae0ffb362d954b35d8203072757adec02e2 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Wed, 29 May 2013 10:56:29 +0100 Subject: [PATCH 078/206] 7053059: VerifyError with double Assignment using a Generic Member of a Superclass Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/TransTypes.java | 11 ++-- .../VerifyErrorWithDoubleAssignmentTest.java | 51 +++++++++++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 langtools/test/tools/javac/T7053059/VerifyErrorWithDoubleAssignmentTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java index a58dec6f7f1..4c227425149 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java @@ -172,10 +172,13 @@ public class TransTypes extends TreeTranslator { JCExpression retype(JCExpression tree, Type erasedType, Type target) { // System.err.println("retype " + tree + " to " + erasedType);//DEBUG if (!erasedType.isPrimitive()) { - if (target != null && target.isPrimitive()) + if (target != null && target.isPrimitive()) { target = erasure(tree.type); + } tree.type = erasedType; - if (target != null) return coerce(tree, target); + if (target != null) { + return coerce(tree, target); + } } return tree; } @@ -686,8 +689,8 @@ public class TransTypes extends TreeTranslator { public void visitAssign(JCAssign tree) { tree.lhs = translate(tree.lhs, null); tree.rhs = translate(tree.rhs, erasure(tree.lhs.type)); - tree.type = erasure(tree.type); - result = tree; + tree.type = erasure(tree.lhs.type); + result = retype(tree, tree.type, pt); } public void visitAssignop(JCAssignOp tree) { diff --git a/langtools/test/tools/javac/T7053059/VerifyErrorWithDoubleAssignmentTest.java b/langtools/test/tools/javac/T7053059/VerifyErrorWithDoubleAssignmentTest.java new file mode 100644 index 00000000000..e03b1a54874 --- /dev/null +++ b/langtools/test/tools/javac/T7053059/VerifyErrorWithDoubleAssignmentTest.java @@ -0,0 +1,51 @@ +/* + * 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 7053059 + * @summary VerifyError with double Assignment using a Generic Member of a Superclass + * @run main VerifyErrorWithDoubleAssignmentTest + */ + +public class VerifyErrorWithDoubleAssignmentTest { + + static class A { + D d; + + D getD() { + return null; + } + } + + static class B extends A { + Integer y; + B() { + y = d = getD(); + } + } + + public static void main(String[] args) { + new B(); + } +} From 993430afb0ca57b1079caa08f7cbfc7efc00459e Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 29 May 2013 15:41:07 +0530 Subject: [PATCH 079/206] 8005979: A lot of tests are named "runTest" in reports Reviewed-by: jlaskey --- nashorn/make/project.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties index 839d7486c72..2e3839b6732 100644 --- a/nashorn/make/project.properties +++ b/nashorn/make/project.properties @@ -87,6 +87,7 @@ testng.verbose=2 testng.listeners=\ org.testng.reporters.SuiteHTMLReporter, \ + org.testng.reporters.TestHTMLReporter, \ org.testng.reporters.jq.Main, \ org.testng.reporters.FailedReporter, \ org.testng.reporters.XMLReporter \ From 9a455252720998b09d658c0daca84de896f2a8cd Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 29 May 2013 13:58:40 +0200 Subject: [PATCH 080/206] 8013920: Configure sets JOBS to 0 if memory is too low Reviewed-by: tbell --- common/autoconf/build-performance.m4 | 3 +++ common/autoconf/generated-configure.sh | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/common/autoconf/build-performance.m4 b/common/autoconf/build-performance.m4 index e7d6364edff..a1abced459d 100644 --- a/common/autoconf/build-performance.m4 +++ b/common/autoconf/build-performance.m4 @@ -145,6 +145,9 @@ AC_DEFUN_ONCE([BPERF_SETUP_BUILD_JOBS], if test "$JOBS" -gt "16"; then JOBS=16 fi + if test "$JOBS" -eq "0"; then + JOBS=1 + fi AC_MSG_RESULT([$JOBS]) else JOBS=$with_jobs diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 87b75cb6cd7..90e29e63de5 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -3780,7 +3780,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1369723814 +DATE_WHEN_GENERATED=1369828684 ############################################################################### # @@ -32933,6 +32933,9 @@ $as_echo_n "checking for appropriate number of jobs to run in parallel... " >&6; if test "$JOBS" -gt "16"; then JOBS=16 fi + if test "$JOBS" -eq "0"; then + JOBS=1 + fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JOBS" >&5 $as_echo "$JOBS" >&6; } else From 4f1888c9fc5c64f2124b5d3a7e540a5054820eb1 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 29 May 2013 14:01:04 +0200 Subject: [PATCH 081/206] 8013489: New build system does not run codesign on SA-related launchers on OS X Reviewed-by: sla, tbell --- common/autoconf/basics.m4 | 14 ++++++ common/autoconf/generated-configure.sh | 59 +++++++++++++++++++++++++- common/autoconf/spec.gmk.in | 1 + common/makefiles/MakeBase.gmk | 4 +- common/makefiles/NativeCompilation.gmk | 14 ++++-- 5 files changed, 85 insertions(+), 7 deletions(-) diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index 305424db718..c4768b02acf 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -617,6 +617,20 @@ fi if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then BASIC_REQUIRE_PROG(XATTR, xattr) + AC_PATH_PROG(CODESIGN, codesign) + if test "x$CODESIGN" != "x"; then + # Verify that the openjdk_codesign certificate is present + AC_MSG_CHECKING([if openjdk_codesign certificate is present]) + rm -f codesign-testfile + touch codesign-testfile + codesign -s openjdk_codesign codesign-testfile 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD || CODESIGN= + rm -f codesign-testfile + if test "x$CODESIGN" = x; then + AC_MSG_RESULT([no]) + else + AC_MSG_RESULT([yes]) + fi + fi fi ]) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 90e29e63de5..f723c40f0a9 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -797,6 +797,7 @@ OS_VERSION_MICRO OS_VERSION_MINOR OS_VERSION_MAJOR PKG_CONFIG +CODESIGN XATTR TIME STAT @@ -3780,7 +3781,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1369828684 +DATE_WHEN_GENERATED=1369828849 ############################################################################### # @@ -10493,6 +10494,62 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} fi + # Extract the first word of "codesign", so it can be a program name with args. +set dummy codesign; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_CODESIGN+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $CODESIGN in + [\\/]* | ?:[\\/]*) + ac_cv_path_CODESIGN="$CODESIGN" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_CODESIGN="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +CODESIGN=$ac_cv_path_CODESIGN +if test -n "$CODESIGN"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CODESIGN" >&5 +$as_echo "$CODESIGN" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test "x$CODESIGN" != "x"; then + # Verify that the openjdk_codesign certificate is present + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if openjdk_codesign certificate is present" >&5 +$as_echo_n "checking if openjdk_codesign certificate is present... " >&6; } + rm -f codesign-testfile + touch codesign-testfile + codesign -s openjdk_codesign codesign-testfile 2>&5 >&5 || CODESIGN= + rm -f codesign-testfile + if test "x$CODESIGN" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + fi + fi fi diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 8705a2a0114..1ebf89d827d 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -478,6 +478,7 @@ CCACHE:=@CCACHE@ # CD is going away, but remains to cater for legacy makefiles. CD:=cd CHMOD:=@CHMOD@ +CODESIGN:=@CODESIGN@ COMM:=@COMM@ CP:=@CP@ CPIO:=@CPIO@ diff --git a/common/makefiles/MakeBase.gmk b/common/makefiles/MakeBase.gmk index 3cbdf79bae9..98a56f86cd1 100644 --- a/common/makefiles/MakeBase.gmk +++ b/common/makefiles/MakeBase.gmk @@ -361,8 +361,8 @@ $(eval $(call SetupLogging)) # This is to be called by all SetupFoo macros define LogSetupMacroEntry - $(if $(26),$(error Internal makefile error: Too many arguments to LogSetupMacroEntry, please update MakeBase.gmk)) - $(if $(findstring $(LOG_LEVEL),debug trace), $(info $1 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25,$(if $($i),$(NEWLINE) $(strip [$i] $($i)))))) + $(if $(27),$(error Internal makefile error: Too many arguments to LogSetupMacroEntry, please update MakeBase.gmk)) + $(if $(findstring $(LOG_LEVEL),debug trace), $(info $1 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26,$(if $($i),$(NEWLINE) $(strip [$i] $($i)))))) endef # Make directory without forking mkdir if not needed diff --git a/common/makefiles/NativeCompilation.gmk b/common/makefiles/NativeCompilation.gmk index c3b276609c3..227832c4c43 100644 --- a/common/makefiles/NativeCompilation.gmk +++ b/common/makefiles/NativeCompilation.gmk @@ -147,9 +147,9 @@ define SetupNativeCompilation # CC the compiler to use, default is $(CC) # LDEXE the linker to use for linking executables, default is $(LDEXE) # OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST - $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) - $(call LogSetupMacroEntry,SetupNativeCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15),$(16),$(17),$(18),$(19),$(20),$(21),$(22),$(23),$(24),$(25)) - $(if $(26),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk)) + $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) + $(call LogSetupMacroEntry,SetupNativeCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15),$(16),$(17),$(18),$(19),$(20),$(21),$(22),$(23),$(24),$(25),$(26)) + $(if $(27),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk)) ifneq (,$$($1_BIN)) $$(error BIN has been replaced with OBJECT_DIR) @@ -567,6 +567,12 @@ define SetupNativeCompilation ifneq (,$$($1_GEN_MANIFEST)) $(MT) -nologo -manifest $$($1_GEN_MANIFEST) -outputresource:$$@;#1 endif - + # This only works if the openjdk_codesign identity is present on the system. Let + # silently fail otherwise. + ifneq (,$(CODESIGN)) + ifneq (,$$($1_CODESIGN)) + $(CODESIGN) -s openjdk_codesign $$@ + endif + endif endif endef From e4879cb3e6c773cb41068b8c2ffde9724f75d334 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 29 May 2013 14:01:24 +0200 Subject: [PATCH 082/206] 8013489: New build system does not run codesign on SA-related launchers on OS X Reviewed-by: sla, tbell --- jdk/makefiles/CompileLaunchers.gmk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jdk/makefiles/CompileLaunchers.gmk b/jdk/makefiles/CompileLaunchers.gmk index 0621f4ce38b..90348b6360f 100644 --- a/jdk/makefiles/CompileLaunchers.gmk +++ b/jdk/makefiles/CompileLaunchers.gmk @@ -95,6 +95,9 @@ define SetupLauncher $1_PLIST_FILE:=Info-cmdline.plist ifneq ($(11),) $1_PLIST_FILE:=$(11) + ifneq ($$(findstring privileged,$$($1_PLIST_FILE)),) + $1_CODESIGN:=true + endif endif $1_LDFLAGS += -Wl,-all_load $(JDK_OUTPUTDIR)/objs/libjli_static.a \ @@ -174,7 +177,8 @@ define SetupLauncher -D "JDK_INTERNAL_NAME=$1" \ -D "JDK_FTYPE=0x1L" \ $7,\ - MANIFEST:=$(JDK_TOPDIR)/src/windows/resource/java.manifest) + MANIFEST:=$(JDK_TOPDIR)/src/windows/resource/java.manifest,\ + CODESIGN:=$$($1_CODESIGN)) BUILD_LAUNCHERS += $$(BUILD_LAUNCHER_$1) From 14cc2ba534f4c9ddeda159070400659769c557d0 Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Wed, 29 May 2013 14:08:00 +0200 Subject: [PATCH 083/206] 8011023: Math round didn't conform to ECMAScript 5 spec Reviewed-by: jlaskey, attila --- .../nashorn/internal/objects/NativeMath.java | 10 +++--- nashorn/test/script/basic/JDK-8011023.js | 34 +++++++++++++++++++ .../test/script/basic/JDK-8011023.js.EXPECTED | 3 ++ 3 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8011023.js create mode 100644 nashorn/test/script/basic/JDK-8011023.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java b/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java index 7f330efc103..50a2d864f29 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java @@ -611,13 +611,11 @@ public final class NativeMath extends ScriptObject { */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object round(final Object self, final Object x) { - if (GlobalFunctions.isNaN(self, x)) { - return Double.NaN; - } else if (!GlobalFunctions.isFinite(self, x)) { - return x; + final double d = JSType.toNumber(x); + if (Math.getExponent(d) >= 52) { + return d; } - - return Math.round(JSType.toNumber(x)); + return Math.copySign(Math.floor(d + 0.5), d); } /** diff --git a/nashorn/test/script/basic/JDK-8011023.js b/nashorn/test/script/basic/JDK-8011023.js new file mode 100644 index 00000000000..fbc2ca96782 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8011023.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * Round should be ecma compliant + * + * @test + * @run + */ + +print(1/Math.round(-0.5)); +print(Math.round(9007199254740991)); +print(Math.round(9223372036854775807*2)); + diff --git a/nashorn/test/script/basic/JDK-8011023.js.EXPECTED b/nashorn/test/script/basic/JDK-8011023.js.EXPECTED new file mode 100644 index 00000000000..f7e1ef45f1c --- /dev/null +++ b/nashorn/test/script/basic/JDK-8011023.js.EXPECTED @@ -0,0 +1,3 @@ +-Infinity +9007199254740991 +18446744073709552000 From 4e5a976adf1ccc1994f487f62029ad3488c739f2 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 29 May 2013 21:27:10 +0530 Subject: [PATCH 084/206] 8015349: "abc".lastIndexOf("a",-1) should evaluate to 0 and not -1 Reviewed-by: lagergren, attila, jlaskey --- .../internal/objects/NativeString.java | 15 +++++-- nashorn/test/script/basic/JDK-8015349.js | 43 +++++++++++++++++++ .../test/script/basic/JDK-8015349.js.EXPECTED | 9 ++++ 3 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8015349.js create mode 100644 nashorn/test/script/basic/JDK-8015349.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeString.java b/nashorn/src/jdk/nashorn/internal/objects/NativeString.java index adbef5cb633..df4aa1bff38 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeString.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeString.java @@ -631,17 +631,24 @@ public final class NativeString extends ScriptObject { final String str = checkObjectToString(self); final String searchStr = JSType.toString(search); + final int length = str.length(); - int from; + int end; if (pos == UNDEFINED) { - from = str.length(); + end = length; } else { final double numPos = JSType.toNumber(pos); - from = !Double.isNaN(numPos) ? (int)numPos : (int)Double.POSITIVE_INFINITY; + end = Double.isNaN(numPos) ? length : (int)numPos; + if (end < 0) { + end = 0; + } else if (end > length) { + end = length; + } } - return str.lastIndexOf(searchStr, from); + + return str.lastIndexOf(searchStr, end); } /** diff --git a/nashorn/test/script/basic/JDK-8015349.js b/nashorn/test/script/basic/JDK-8015349.js new file mode 100644 index 00000000000..7588a651d60 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015349.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8015349: "abc".lastIndexOf("a",-1) should evaluate to 0 and not -1 + * + * @test + * @run + */ + +function printEval(code) { + print(code + " = " + eval(code)); +} + +printEval("'abc'.lastIndexOf('a', 4)"); +printEval("'abc'.lastIndexOf('b', Infinity)"); +printEval("'abc'.lastIndexOf('a', -1)"); +printEval("'abc'.lastIndexOf('a', -Infinity)"); +printEval("'oracle'.lastIndexOf('u')"); +printEval("'hello'.lastIndexOf('l')"); +printEval("'hello'.lastIndexOf('l', 2)"); +printEval("'hello'.lastIndexOf('l', 3)"); +printEval("'hello'.lastIndexOf('l', 1)"); diff --git a/nashorn/test/script/basic/JDK-8015349.js.EXPECTED b/nashorn/test/script/basic/JDK-8015349.js.EXPECTED new file mode 100644 index 00000000000..f743dc4c1df --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015349.js.EXPECTED @@ -0,0 +1,9 @@ +'abc'.lastIndexOf('a', 4) = 0 +'abc'.lastIndexOf('b', Infinity) = 1 +'abc'.lastIndexOf('a', -1) = 0 +'abc'.lastIndexOf('a', -Infinity) = 0 +'oracle'.lastIndexOf('u') = -1 +'hello'.lastIndexOf('l') = 3 +'hello'.lastIndexOf('l', 2) = 2 +'hello'.lastIndexOf('l', 3) = 3 +'hello'.lastIndexOf('l', 1) = -1 From a3f6ca8aed38328bb86568e608f94b3e66776b24 Mon Sep 17 00:00:00 2001 From: James Laskey Date: Wed, 29 May 2013 16:23:50 -0300 Subject: [PATCH 085/206] 8015636: Add more typed arrays code coverage tests Reviewed-by: sundar --- nashorn/test/script/basic/typedarrays.js | 96 ++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 nashorn/test/script/basic/typedarrays.js diff --git a/nashorn/test/script/basic/typedarrays.js b/nashorn/test/script/basic/typedarrays.js new file mode 100644 index 00000000000..0854bea9d19 --- /dev/null +++ b/nashorn/test/script/basic/typedarrays.js @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * typedarray test. + * + * @test + * @run + */ + + +var typeDefinitions = [ +Int8Array, +Uint8Array, +Uint8ClampedArray, +Int16Array, +Uint16Array, +Int32Array, +Uint32Array, +Float32Array, +Float64Array, +]; + +var mem1 = new ArrayBuffer(1024); +mem1.byteLength; +mem1.slice(512); +mem1.slice(512, 748); + +var size = 128; +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +var arr2 = [99, 89]; +var partial = []; +var all = []; + +typeDefinitions.forEach(function(arrayDef) { + var p = arrayDef.prototype; + var sub = []; + sub.push(new arrayDef(mem1, arrayDef.BYTES_PER_ELEMENT, 3)); + sub.push(new arrayDef(size)); + sub.push(new arrayDef(arr)); + //push the instances, they will be reused to do instance based construction + partial.push({ + instances:sub, + type:arrayDef + }); + + all.concat(all, sub); + +}); + +partial.forEach(function(inst) { + // build new instances with TypeArray instance as parameter. + partial.forEach(function(other) { + other.instances.forEach(function(otherInstance) { + var ii = new inst.type(otherInstance); + all.push(ii); + }); + }) +}); + +all.forEach(function(instance) { + // cover instance props and functions + var arr = Object.getOwnPropertyNames(instance); + arr.forEach(function(p) { + var val = instance[p]; + if(!isNaN(p)){ + val[p] = 99; + } + }); + + instance.set(instance, 0); + instance.set(instance); + instance.set(arr2); + instance.subarray(5, 9); + instance.subarray(5); +}); From dd5dcda9077271b756f41eb5bf2114da14c03853 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 29 May 2013 15:34:56 -0700 Subject: [PATCH 086/206] 8015641: genstubs needs to cope with static interface methods Reviewed-by: ksrini --- langtools/make/tools/genstubs/GenStubs.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langtools/make/tools/genstubs/GenStubs.java b/langtools/make/tools/genstubs/GenStubs.java index 0ff475c9473..ffa95c97792 100644 --- a/langtools/make/tools/genstubs/GenStubs.java +++ b/langtools/make/tools/genstubs/GenStubs.java @@ -230,9 +230,9 @@ public class GenStubs { tree.typarams = translateTypeParams(tree.typarams); tree.params = translateVarDefs(tree.params); tree.thrown = translate(tree.thrown); - if (tree.restype != null && tree.body != null) { + if (tree.body != null) { if ((currClassMods & Flags.INTERFACE) != 0) { - tree.mods.flags &= ~Flags.DEFAULT; + tree.mods.flags &= ~(Flags.DEFAULT | Flags.STATIC); } else { tree.mods.flags |= Flags.NATIVE; } From 91a299799ef6720995468b94b1bf525a0def4d1e Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Thu, 30 May 2013 16:49:46 +0530 Subject: [PATCH 087/206] 8015353: Date.parse illegal string parsing issues Reviewed-by: jlaskey, lagergren --- .../nashorn/internal/objects/NativeDate.java | 1 + .../{objects => parser}/DateParser.java | 12 +++++- nashorn/test/script/basic/JDK-8015353.js | 38 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) rename nashorn/src/jdk/nashorn/internal/{objects => parser}/DateParser.java (98%) create mode 100644 nashorn/test/script/basic/JDK-8015353.js diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java b/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java index fa2c9d17a81..ef01d74b252 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java @@ -39,6 +39,7 @@ import jdk.nashorn.internal.objects.annotations.Function; import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.SpecializedConstructor; import jdk.nashorn.internal.objects.annotations.Where; +import jdk.nashorn.internal.parser.DateParser; import jdk.nashorn.internal.runtime.ConsString; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptEnvironment; diff --git a/nashorn/src/jdk/nashorn/internal/objects/DateParser.java b/nashorn/src/jdk/nashorn/internal/parser/DateParser.java similarity index 98% rename from nashorn/src/jdk/nashorn/internal/objects/DateParser.java rename to nashorn/src/jdk/nashorn/internal/parser/DateParser.java index b66d3dc99c1..34832bb1b44 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/DateParser.java +++ b/nashorn/src/jdk/nashorn/internal/parser/DateParser.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.objects; +package jdk.nashorn.internal.parser; import static java.lang.Character.DECIMAL_DIGIT_NUMBER; import static java.lang.Character.LOWERCASE_LETTER; @@ -196,6 +196,11 @@ public class DateParser { break; case SIGN: + if (peek() == -1) { + // END after sign - wrong! + return false; + } + if (currentField == YEAR) { yearSign = numValue; } else if (currentField < SECOND || !setTimezone(readTimeZoneOffset(), true)) { @@ -297,6 +302,11 @@ public class DateParser { break; case SIGN: + if (peek() == -1) { + // END after sign - wrong! + return false; + } + if (!setTimezone(readTimeZoneOffset(), true)) { return false; } diff --git a/nashorn/test/script/basic/JDK-8015353.js b/nashorn/test/script/basic/JDK-8015353.js new file mode 100644 index 00000000000..a9baa4691ae --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015353.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8015353: Date.parse illegal string parsing issues + * + * @test + * @run + */ + +function checkDate(str) { + if (! isNaN(Date.parse(str))) { + fail(str + " is parsed as legal Date"); + } +} + +checkDate("2012-01-10T00:00:00.000-"); +checkDate("2012-01-01T00:00+"); From 36b5e14b3106294d4150ff6a9b39fefb0d299983 Mon Sep 17 00:00:00 2001 From: James Tomson Date: Thu, 30 May 2013 18:10:26 +0400 Subject: [PATCH 088/206] 8015303: [macosx] Application launched via custom URL Scheme does not receive URL Make copies of event parameters Reviewed-by: anthony, swingler, serb --- .../macosx/native/sun/osxapp/QueuingApplicationDelegate.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jdk/src/macosx/native/sun/osxapp/QueuingApplicationDelegate.m b/jdk/src/macosx/native/sun/osxapp/QueuingApplicationDelegate.m index 5b71d8ab96c..736155fdc01 100644 --- a/jdk/src/macosx/native/sun/osxapp/QueuingApplicationDelegate.m +++ b/jdk/src/macosx/native/sun/osxapp/QueuingApplicationDelegate.m @@ -110,8 +110,14 @@ - (void)_handleOpenURLEvent:(NSAppleEventDescriptor *)openURLEvent withReplyEvent:(NSAppleEventDescriptor *)replyEvent { + // Make an explicit copy of the passed events as they may be invalidated by the time they're processed + NSAppleEventDescriptor *openURLEventCopy = [openURLEvent copy]; + NSAppleEventDescriptor *replyEventCopy = [replyEvent copy]; + [self.queue addObject:[^(){ - [self.realDelegate _handleOpenURLEvent:openURLEvent withReplyEvent:replyEvent]; + [self.realDelegate _handleOpenURLEvent:openURLEventCopy withReplyEvent:replyEventCopy]; + [openURLEventCopy release]; + [replyEventCopy release]; } copy]]; } From e460380426d3e91ef4891b7f410801f796549d79 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Thu, 30 May 2013 18:23:21 +0400 Subject: [PATCH 089/206] 8013424: Regression: java.awt.datatransfer.FlavorListeners not notified on Linux/Java 7 Reviewed-by: anthony --- jdk/src/solaris/classes/sun/awt/X11/XClipboard.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java b/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java index 44ee617783b..6293bc52573 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java @@ -179,6 +179,7 @@ public final class XClipboard extends SunClipboard implements OwnershipListener } synchronized (XClipboard.classLock) { if (targetsAtom2Clipboard != null && !targetsAtom2Clipboard.isEmpty()) { + // The viewer is still registered, schedule next poll. XToolkit.schedule(this, XClipboard.getPollInterval()); } } @@ -191,7 +192,8 @@ public final class XClipboard extends SunClipboard implements OwnershipListener final XSelectionEvent xse = ev.get_xselection(); XClipboard clipboard = null; synchronized (XClipboard.classLock) { - if (targetsAtom2Clipboard != null && !targetsAtom2Clipboard.isEmpty()) { + if (targetsAtom2Clipboard != null && targetsAtom2Clipboard.isEmpty()) { + // The viewer was unregistered, remove the dispatcher. XToolkit.removeEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), this); return; } From 833d23804d16304e03fd9766df08a82643cf68c6 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Thu, 30 May 2013 18:31:33 +0400 Subject: [PATCH 090/206] 8013773: requestFocusInWindow to a disabled component prevents window of getting focused Reviewed-by: leonidr, alexsch --- .../java/awt/DefaultKeyboardFocusManager.java | 1 + .../ResetMostRecentFocusOwnerTest.java | 121 ++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 jdk/test/java/awt/Focus/ResetMostRecentFocusOwnerTest/ResetMostRecentFocusOwnerTest.java diff --git a/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java b/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java index 68e1f52a221..f4199881989 100644 --- a/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java +++ b/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java @@ -559,6 +559,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager { } else { restoreFocus(fe, newFocusedWindow); } + setMostRecentFocusOwner(newFocusedWindow, null); // see: 8013773 } break; } diff --git a/jdk/test/java/awt/Focus/ResetMostRecentFocusOwnerTest/ResetMostRecentFocusOwnerTest.java b/jdk/test/java/awt/Focus/ResetMostRecentFocusOwnerTest/ResetMostRecentFocusOwnerTest.java new file mode 100644 index 00000000000..f98bbdf7386 --- /dev/null +++ b/jdk/test/java/awt/Focus/ResetMostRecentFocusOwnerTest/ResetMostRecentFocusOwnerTest.java @@ -0,0 +1,121 @@ +/* + * 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 8013773 + @summary Tests that disabled component is not retained as most recent focus owner. + @author Anton.Tarasov: area=awt.focus + @library ../../regtesthelpers + @build Util + @run main ResetMostRecentFocusOwnerTest +*/ + +import java.applet.Applet; +import java.awt.AWTEvent; +import java.awt.FlowLayout; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.AWTEventListener; +import java.awt.event.FocusEvent; +import java.awt.event.WindowEvent; +import javax.swing.JButton; +import javax.swing.JFrame; +import test.java.awt.regtesthelpers.Util; + +public class ResetMostRecentFocusOwnerTest extends Applet { + + public static void main(String[] args) { + ResetMostRecentFocusOwnerTest app = new ResetMostRecentFocusOwnerTest(); + app.init(); + app.start(); + } + + @Override + public void start() { + + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + public void eventDispatched(AWTEvent e) { + System.err.println(e); + } + }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK); + + boolean gained = false; + final Robot robot = Util.createRobot(); + + JFrame frame1 = new JFrame("Main Frame"); + final JButton b1 = new JButton("button1"); + frame1.add(b1); + frame1.pack(); + frame1.setLocation(0, 300); + + Util.showWindowWait(frame1); + + final JFrame frame2 = new JFrame("Test Frame"); + final JButton b2 = new JButton("button2"); + frame2.add(b2); + frame2.pack(); + frame2.setLocation(300, 300); + + b2.setEnabled(false); + b2.requestFocus(); + + Util.showWindowWait(frame2); + + robot.delay(500); + + // + // It's expeced that the focus is restored to . + // If not, click to set focus on it. + // + if (!b1.hasFocus()) { + gained = Util.trackFocusGained(b1, new Runnable() { + public void run() { + Util.clickOnComp(b1, robot); + } + }, 5000, false); + + if (!gained) { + throw new RuntimeException("Unexpected state: focus is not on "); + } + } + + robot.delay(500); + + // + // Click , check that focus is set on the parent frame. + // + gained = false; + gained = Util.trackFocusGained(frame2, new Runnable() { + public void run() { + Util.clickOnComp(b2, robot); + } + }, 5000, false); + + if (!gained) { + throw new RuntimeException("Test failed: focus wasn't set to "); + } + + System.out.println("Test passed."); + } +} From 2ab206de9e05b8ef480df87253dbf70fb616acec Mon Sep 17 00:00:00 2001 From: Jiri Vanek Date: Thu, 30 May 2013 16:50:31 +0100 Subject: [PATCH 091/206] 8011693: Remove redundant fontconfig files Remove unused fontconfig files from OpenJDK GNU/Linux builds Reviewed-by: andrew, prr --- jdk/make/sun/awt/Makefile | 17 +- jdk/makefiles/GendataFontConfig.gmk | 8 +- .../linux.fontconfig.Fedora.properties | 377 ------------------ .../linux.fontconfig.SuSE.properties | 154 ------- .../linux.fontconfig.Ubuntu.properties | 348 ---------------- .../fontconfigs/linux.fontconfig.properties | 189 --------- 6 files changed, 14 insertions(+), 1079 deletions(-) delete mode 100644 jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.Fedora.properties delete mode 100644 jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.SuSE.properties delete mode 100644 jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.Ubuntu.properties delete mode 100644 jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.properties diff --git a/jdk/make/sun/awt/Makefile b/jdk/make/sun/awt/Makefile index ed9361294a4..5ac9d64c773 100644 --- a/jdk/make/sun/awt/Makefile +++ b/jdk/make/sun/awt/Makefile @@ -390,12 +390,9 @@ ifeq ($(PLATFORM), linux) # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv LINUX ifdef OPENJDK -FONTCONFIGS_SRC = $(PLATFORM_SRC)/classes/sun/awt/fontconfigs -_FONTCONFIGS = \ - fontconfig.properties \ - fontconfig.SuSE.properties \ - fontconfig.Ubuntu.properties \ - fontconfig.Fedora.properties +FONTCONFIGS_SRC = +_FONTCONFIGS = + else FONTCONFIGS_SRC = $(CLOSED_SRC)/solaris/classes/sun/awt/fontconfigs @@ -441,7 +438,11 @@ endif # PLATFORM FONTCONFIGS = $(_FONTCONFIGS:%=$(LIBDIR)/%.src) BINARYFONTCONFIGS = $(_FONTCONFIGS:%.properties=$(LIBDIR)/%.bfc) +ifneq ("x$(_FONTCONFIGS)", "x") fontconfigs: $(FONTCONFIGS) $(BINARYFONTCONFIGS) +else +fontconfigs: +endif $(LIBDIR)/%.src: $(FONTCONFIGS_SRC)/$(FONTCONFIGS_SRC_PREFIX)% $(install-file) @@ -455,9 +456,13 @@ $(LIBDIR)/%.bfc: $(FONTCONFIGS_SRC)/$(FONTCONFIGS_SRC_PREFIX)%.properties \ $(call chmod-file, 444) @$(java-vm-cleanup) +ifneq ("x$(_FONTCONFIGS)", "x") fontconfigs.clean : $(RM) $(FONTCONFIGS) $(RM) $(BINARYFONTCONFIGS) +else +fontconfigs.clean : +endif ifeq ($(PLATFORM), windows) # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv WINDOWS diff --git a/jdk/makefiles/GendataFontConfig.gmk b/jdk/makefiles/GendataFontConfig.gmk index 189a7327a1d..08d30faeacb 100644 --- a/jdk/makefiles/GendataFontConfig.gmk +++ b/jdk/makefiles/GendataFontConfig.gmk @@ -36,11 +36,9 @@ ifeq ($(OPENJDK_TARGET_OS), linux) ifdef OPENJDK GENDATA_FONT_CONFIG_SRC_DIR := \ $(JDK_TOPDIR)/src/solaris/classes/sun/awt/fontconfigs - GENDATA_FONT_CONFIG_SRC_FILES := \ - fontconfig.properties \ - fontconfig.SuSE.properties \ - fontconfig.Ubuntu.properties \ - fontconfig.Fedora.properties + # This is placeholder for possible fonconfig files which may + # useful for some highly specialized Linux distributions + GENDATA_FONT_CONFIG_SRC_FILES := else GENDATA_FONT_CONFIG_SRC_DIR := \ $(JDK_TOPDIR)/src/closed/solaris/classes/sun/awt/fontconfigs diff --git a/jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.Fedora.properties b/jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.Fedora.properties deleted file mode 100644 index e9f3a4912e3..00000000000 --- a/jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.Fedora.properties +++ /dev/null @@ -1,377 +0,0 @@ -# -# -# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# Version - -# Uses Fedora 9 fonts and file paths. -version=1 - -# Component Font Mappings - -dialog.plain.latin-1=DejaVu Sans -dialog.plain.japanese-x0208=Sazanami Gothic -dialog.plain.korean=Baekmuk Gulim -dialog.plain.chinese-big5=AR PL ShanHeiSun Uni -dialog.plain.chinese-gb18030=AR PL ShanHeiSun Uni -dialog.plain.bengali=Lohit Bengali -dialog.plain.gujarati=Lohit Gujarati -dialog.plain.hindi=Lohit Hindi -dialog.plain.malayalam=Lohit Malayalam -dialog.plain.oriya=Lohit Oriya -dialog.plain.punjabi=Lohit Punjabi -dialog.plain.tamil=Lohit Tamil -dialog.plain.telugu=Lohit Telugu -dialog.plain.sinhala=LKLUG - -dialog.bold.latin-1=DejaVu Sans Bold -dialog.bold.japanese-x0208=Sazanami Gothic -dialog.bold.korean=Baekmuk Gulim -dialog.bold.chinese-big5=AR PL ShanHeiSun Uni -dialog.bold.chinese-gb18030=AR PL ShanHeiSun Uni -dialog.bold.bengali=Lohit Bengali -dialog.bold.gujarati=Lohit Gujarati -dialog.bold.hindi=Lohit Hindi -dialog.bold.malayalam=Lohit Malayalam -dialog.bold.oriya=Lohit Oriya -dialog.bold.punjabi=Lohit Punjabi -dialog.bold.tamil=Lohit Tamil -dialog.bold.telugu=Lohit Telugu -dialog.bold.sinhala=LKLUG - -dialog.italic.latin-1=DejaVu Sans Oblique -dialog.italic.japanese-x0208=Sazanami Gothic -dialog.italic.korean=Baekmuk Gulim -dialog.italic.chinese-big5=AR PL ShanHeiSun Uni -dialog.italic.chinese-gb18030=AR PL ShanHeiSun Uni -dialog.italic.bengali=Lohit Bengali -dialog.italic.gujarati=Lohit Gujarati -dialog.italic.hindi=Lohit Hindi -dialog.italic.malayalam=Lohit Malayalam -dialog.italic.oriya=Lohit Oriya -dialog.italic.punjabi=Lohit Punjabi -dialog.italic.tamil=Lohit Tamil -dialog.italic.telugu=Lohit Telugu -dialog.italic.sinhala=LKLUG - -dialog.bolditalic.latin-1=DejaVu Sans Bold Oblique -dialog.bolditalic.japanese-x0208=Sazanami Gothic -dialog.bolditalic.korean=Baekmuk Gulim -dialog.bolditalic.chinese-big5=AR PL ShanHeiSun Uni -dialog.bolditalic.chinese-gb18030=AR PL ShanHeiSun Uni -dialog.bolditalic.bengali=Lohit Bengali -dialog.bolditalic.gujarati=Lohit Gujarati -dialog.bolditalic.hindi=Lohit Hindi -dialog.bolditalic.malayalam=Lohit Malayalam -dialog.bolditalic.oriya=Lohit Oriya -dialog.bolditalic.punjabi=Lohit Punjabi -dialog.bolditalic.tamil=Lohit Tamil -dialog.bolditalic.telugu=Lohit Telugu -dialog.bolditalic.sinhala=LKLUG - -sansserif.plain.latin-1=DejaVu Sans -sansserif.plain.japanese-x0208=Sazanami Gothic -sansserif.plain.korean=Baekmuk Gulim -sansserif.plain.chinese-big5=AR PL ShanHeiSun Uni -sansserif.plain.chinese-gb18030=AR PL ShanHeiSun Uni -sansserif.plain.bengali=Lohit Bengali -sansserif.plain.gujarati=Lohit Gujarati -sansserif.plain.hindi=Lohit Hindi -sansserif.plain.malayalam=Lohit Malayalam -sansserif.plain.oriya=Lohit Oriya -sansserif.plain.punjabi=Lohit Punjabi -sansserif.plain.tamil=Lohit Tamil -sansserif.plain.telugu=Lohit Telugu -sansserif.plain.sinhala=LKLUG - -sansserif.bold.latin-1=DejaVu Sans Bold -sansserif.bold.japanese-x0208=Sazanami Gothic -sansserif.bold.korean=Baekmuk Gulim -sansserif.bold.chinese-big5=AR PL ShanHeiSun Uni -sansserif.bold.chinese-gb18030=AR PL ShanHeiSun Uni -sansserif.bold.bengali=Lohit Bengali -sansserif.bold.gujarati=Lohit Gujarati -sansserif.bold.hindi=Lohit Hindi -sansserif.bold.malayalam=Lohit Malayalam -sansserif.bold.oriya=Lohit Oriya -sansserif.bold.punjabi=Lohit Punjabi -sansserif.bold.tamil=Lohit Tamil -sansserif.bold.telugu=Lohit Telugu -sansserif.bold.sinhala=LKLUG - -sansserif.italic.latin-1=DejaVu Sans Oblique -sansserif.italic.japanese-x0208=Sazanami Gothic -sansserif.italic.korean=Baekmuk Gulim -sansserif.italic.chinese-big5=AR PL ShanHeiSun Uni -sansserif.italic.chinese-gb18030=AR PL ShanHeiSun Uni -sansserif.italic.bengali=Lohit Bengali -sansserif.italic.gujarati=Lohit Gujarati -sansserif.italic.hindi=Lohit Hindi -sansserif.italic.malayalam=Lohit Malayalam -sansserif.italic.oriya=Lohit Oriya -sansserif.italic.punjabi=Lohit Punjabi -sansserif.italic.tamil=Lohit Tamil -sansserif.italic.telugu=Lohit Telugu -sansserif.italic.sinhala=LKLUG - -sansserif.bolditalic.latin-1=DejaVu Sans Bold Oblique -sansserif.bolditalic.japanese-x0208=Sazanami Gothic -sansserif.bolditalic.korean=Baekmuk Gulim -sansserif.bolditalic.chinese-big5=AR PL ShanHeiSun Uni -sansserif.bolditalic.chinese-gb18030=AR PL ShanHeiSun Uni -sansserif.bolditalic.bengali=Lohit Bengali -sansserif.bolditalic.gujarati=Lohit Gujarati -sansserif.bolditalic.hindi=Lohit Hindi -sansserif.bolditalic.malayalam=Lohit Malayalam -sansserif.bolditalic.oriya=Lohit Oriya -sansserif.bolditalic.punjabi=Lohit Punjabi -sansserif.bolditalic.tamil=Lohit Tamil -sansserif.bolditalic.telugu=Lohit Telugu -sansserif.bolditalic.sinhala=LKLUG - -serif.plain.latin-1=DejaVu Serif -serif.plain.japanese-x0208=Sazanami Mincho -serif.plain.korean=Baekmuk Batang -serif.plain.chinese-big5=AR PL ZenKai Uni -serif.plain.chinese-gb18030=AR PL ZenKai Uni -serif.plain.bengali=Lohit Bengali -serif.plain.gujarati=Lohit Gujarati -serif.plain.hindi=Lohit Hindi -serif.plain.malayalam=Lohit Malayalam -serif.plain.oriya=Lohit Oriya -serif.plain.punjabi=Lohit Punjabi -serif.plain.tamil=Lohit Tamil -serif.plain.telugu=Lohit Telugu -serif.plain.sinhala=LKLUG - -serif.bold.latin-1=DejaVu Serif Bold -serif.bold.japanese-x0208=Sazanami Mincho -serif.bold.korean=Baekmuk Batang -serif.bold.chinese-big5=AR PL ZenKai Uni -serif.bold.chinese-gb18030=AR PL ZenKai Uni -serif.bold.bengali=Lohit Bengali -serif.bold.gujarati=Lohit Gujarati -serif.bold.hindi=Lohit Hindi -serif.bold.malayalam=Lohit Malayalam -serif.bold.oriya=Lohit Oriya -serif.bold.punjabi=Lohit Punjabi -serif.bold.tamil=Lohit Tamil -serif.bold.telugu=Lohit Telugu -serif.bold.sinhala=LKLUG - -serif.italic.latin-1=DejaVu Serif Oblique -serif.italic.japanese-x0208=Sazanami Mincho -serif.italic.korean=Baekmuk Batang -serif.italic.chinese-big5=AR PL ZenKai Uni -serif.italic.chinese-gb18030=AR PL ZenKai Uni -serif.italic.bengali=Lohit Bengali -serif.italic.gujarati=Lohit Gujarati -serif.italic.hindi=Lohit Hindi -serif.italic.malayalam=Lohit Malayalam -serif.italic.oriya=Lohit Oriya -serif.italic.punjabi=Lohit Punjabi -serif.italic.tamil=Lohit Tamil -serif.italic.telugu=Lohit Telugu -serif.italic.sinhala=LKLUG - -serif.bolditalic.latin-1=DejaVu Serif Bold Oblique -serif.bolditalic.japanese-x0208=Sazanami Mincho -serif.bolditalic.korean=Baekmuk Batang -serif.bolditalic.chinese-big5=AR PL ZenKai Uni -serif.bolditalic.chinese-gb18030=AR PL ZenKai Uni -serif.bolditalic.bengali=Lohit Bengali -serif.bolditalic.gujarati=Lohit Gujarati -serif.bolditalic.hindi=Lohit Hindi -serif.bolditalic.malayalam=Lohit Malayalam -serif.bolditalic.oriya=Lohit Oriya -serif.bolditalic.punjabi=Lohit Punjabi -serif.bolditalic.tamil=Lohit Tamil -serif.bolditalic.telugu=Lohit Telugu -serif.bolditalic.sinhala=LKLUG - -monospaced.plain.latin-1=DejaVu Sans Mono -monospaced.plain.japanese-x0208=Sazanami Gothic -monospaced.plain.korean=Baekmuk Gulim -monospaced.plain.chinese-big5=AR PL ShanHeiSun Uni -monospaced.plain.chinese-gb18030=AR PL ShanHeiSun Uni -monospaced.plain.bengali=Lohit Bengali -monospaced.plain.gujarati=Lohit Gujarati -monospaced.plain.hindi=Lohit Hindi -monospaced.plain.malayalam=Lohit Malayalam -monospaced.plain.oriya=Lohit Oriya -monospaced.plain.punjabi=Lohit Punjabi -monospaced.plain.tamil=Lohit Tamil -monospaced.plain.telugu=Lohit Telugu -monospaced.plain.sinhala=LKLUG - -monospaced.bold.latin-1=DejaVu Sans Mono Bold -monospaced.bold.japanese-x0208=Sazanami Gothic -monospaced.bold.korean=Baekmuk Gulim -monospaced.bold.chinese-big5=AR PL ShanHeiSun Uni -monospaced.bold.chinese-gb18030=AR PL ShanHeiSun Uni -monospaced.bold.bengali=Lohit Bengali -monospaced.bold.gujarati=Lohit Gujarati -monospaced.bold.hindi=Lohit Hindi -monospaced.bold.malayalam=Lohit Malayalam -monospaced.bold.oriya=Lohit Oriya -monospaced.bold.punjabi=Lohit Punjabi -monospaced.bold.tamil=Lohit Tamil -monospaced.bold.telugu=Lohit Telugu -monospaced.bold.sinhala=LKLUG - -monospaced.italic.latin-1=DejaVu Sans Mono Oblique -monospaced.italic.japanese-x0208=Sazanami Gothic -monospaced.italic.korean=Baekmuk Gulim -monospaced.italic.chinese-big5=AR PL ShanHeiSun Uni -monospaced.italic.chinese-gb18030=AR PL ShanHeiSun Uni -monospaced.italic.bengali=Lohit Bengali -monospaced.italic.gujarati=Lohit Gujarati -monospaced.italic.hindi=Lohit Hindi -monospaced.italic.malayalam=Lohit Malayalam -monospaced.italic.oriya=Lohit Oriya -monospaced.italic.punjabi=Lohit Punjabi -monospaced.italic.tamil=Lohit Tamil -monospaced.italic.telugu=Lohit Telugu -monospaced.italic.sinhala=LKLUG - -monospaced.bolditalic.latin-1=DejaVu Sans Mono Bold Oblique -monospaced.bolditalic.japanese-x0208=Sazanami Gothic -monospaced.bolditalic.korean=Baekmuk Gulim -monospaced.bolditalic.chinese-big5=AR PL ShanHeiSun Uni -monospaced.bolditalic.chinese-gb18030=AR PL ShanHeiSun Uni -monospaced.bolditalic.bengali=Lohit Bengali -monospaced.bolditalic.gujarati=Lohit Gujarati -monospaced.bolditalic.hindi=Lohit Hindi -monospaced.bolditalic.malayalam=Lohit Malayalam -monospaced.bolditalic.oriya=Lohit Oriya -monospaced.bolditalic.punjabi=Lohit Punjabi -monospaced.bolditalic.tamil=Lohit Tamil -monospaced.bolditalic.telugu=Lohit Telugu -monospaced.bolditalic.sinhala=LKLUG - -dialoginput.plain.latin-1=DejaVu Sans Mono -dialoginput.plain.japanese-x0208=Sazanami Gothic -dialoginput.plain.korean=Baekmuk Gulim -dialoginput.plain.chinese-big5=AR PL ShanHeiSun Uni -dialoginput.plain.chinese-gb18030=AR PL ShanHeiSun Uni -dialoginput.plain.bengali=Lohit Bengali -dialoginput.plain.gujarati=Lohit Gujarati -dialoginput.plain.hindi=Lohit Hindi -dialoginput.plain.malayalam=Lohit Malayalam -dialoginput.plain.oriya=Lohit Oriya -dialoginput.plain.punjabi=Lohit Punjabi -dialoginput.plain.tamil=Lohit Tamil -dialoginput.plain.telugu=Lohit Telugu -dialoginput.plain.sinhala=LKLUG - -dialoginput.bold.latin-1=DejaVu Sans Mono Bold -dialoginput.bold.japanese-x0208=Sazanami Gothic -dialoginput.bold.korean=Baekmuk Gulim -dialoginput.bold.chinese-big5=AR PL ShanHeiSun Uni -dialoginput.bold.chinese-gb18030=AR PL ShanHeiSun Uni -dialoginput.bold.bengali=Lohit Bengali -dialoginput.bold.gujarati=Lohit Gujarati -dialoginput.bold.hindi=Lohit Hindi -dialoginput.bold.malayalam=Lohit Malayalam -dialoginput.bold.oriya=Lohit Oriya -dialoginput.bold.punjabi=Lohit Punjabi -dialoginput.bold.tamil=Lohit Tamil -dialoginput.bold.telugu=Lohit Telugu -dialoginput.bold.sinhala=LKLUG - -dialoginput.italic.latin-1=DejaVu Sans Mono Oblique -dialoginput.italic.japanese-x0208=Sazanami Gothic -dialoginput.italic.korean=Baekmuk Gulim -dialoginput.italic.chinese-big5=AR PL ShanHeiSun Uni -dialoginput.italic.chinese-gb18030=AR PL ShanHeiSun Uni -dialoginput.italic.bengali=Lohit Bengali -dialoginput.italic.gujarati=Lohit Gujarati -dialoginput.italic.hindi=Lohit Hindi -dialoginput.italic.malayalam=Lohit Malayalam -dialoginput.italic.oriya=Lohit Oriya -dialoginput.italic.punjabi=Lohit Punjabi -dialoginput.italic.tamil=Lohit Tamil -dialoginput.italic.telugu=Lohit Telugu -dialoginput.italic.sinhala=LKLUG - -dialoginput.bolditalic.latin-1=DejaVu Sans Mono Bold Oblique -dialoginput.bolditalic.japanese-x0208=Sazanami Gothic -dialoginput.bolditalic.korean=Baekmuk Gulim -dialoginput.bolditalic.chinese-big5=AR PL ShanHeiSun Uni -dialoginput.bolditalic.chinese-gb18030=AR PL ShanHeiSun Uni -dialoginput.bolditalic.bengali=Lohit Bengali -dialoginput.bolditalic.gujarati=Lohit Gujarati -dialoginput.bolditalic.hindi=Lohit Hindi -dialoginput.bolditalic.malayalam=Lohit Malayalam -dialoginput.bolditalic.oriya=Lohit Oriya -dialoginput.bolditalic.punjabi=Lohit Punjabi -dialoginput.bolditalic.tamil=Lohit Tamil -dialoginput.bolditalic.telugu=Lohit Telugu -dialoginput.bolditalic.sinhala=LKLUG - -# Search Sequences - -sequence.allfonts=latin-1 -sequence.allfonts.Big5=chinese-big5,latin-1 -sequence.allfonts.x-euc-jp-linux=japanese-x0208,latin-1 -sequence.allfonts.EUC-KR=korean,latin-1 -sequence.allfonts.GB18030=chinese-gb18030,latin-1 -sequence.fallback=chinese-big5,chinese-gb18030,japanese-x0208,korean,bengali,gujarati,hindi,oriya,punjabi,malayalam,tamil,telugu,sinhala - -# Font File Names - -filename.DejaVu_Sans=/usr/share/fonts/dejavu/DejaVuSans.ttf -filename.DejaVu_Sans_Bold=/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf -filename.DejaVu_Sans_Oblique=/usr/share/fonts/dejavu/DejaVuSans-Oblique.ttf -filename.DejaVu_Sans_Bold_Oblique=/usr/share/fonts/dejavu/DejaVuSans-BoldOblique.ttf - -filename.DejaVu_Sans_Mono=/usr/share/fonts/dejavu/DejaVuSansMono.ttf -filename.DejaVu_Sans_Mono_Bold=/usr/share/fonts/dejavu/DejaVuSansMono-Bold.ttf -filename.DejaVu_Sans_Mono_Oblique=/usr/share/fonts/dejavu/DejaVuSansMono-Oblique.ttf -filename.DejaVu_Sans_Mono_Bold_Oblique=/usr/share/fonts/dejavu/DejaVuSansMono-BoldOblique.ttf - -filename.DejaVu_Serif=/usr/share/fonts/dejavu/DejaVuSerif.ttf -filename.DejaVu_Serif_Bold=/usr/share/fonts/dejavu/DejaVuSerif-Bold.ttf -filename.DejaVu_Serif_Oblique=/usr/share/fonts/dejavu/DejaVuSerif-Oblique.ttf -filename.DejaVu_Serif_Bold_Oblique=/usr/share/fonts/dejavu/DejaVuSerif-BoldOblique.ttf - -filename.Sazanami_Gothic=/usr/share/fonts/sazanami-fonts-gothic/sazanami-gothic.ttf -filename.Sazanami_Mincho=/usr/share/fonts/sazanami-fonts-mincho/sazanami-mincho.ttf -filename.AR_PL_ShanHeiSun_Uni=/usr/share/fonts/cjkunifonts-uming/uming.ttc -filename.AR_PL_ZenKai_Uni=/usr/share/fonts/cjkunifonts-ukai/ukai.ttc -filename.Baekmuk_Gulim=/usr/share/fonts/baekmuk-ttf-gulim/gulim.ttf -filename.Baekmuk_Batang=/usr/share/fonts/baekmuk-ttf-batang/batang.ttf - -filename.Lohit_Bengali=/usr/share/fonts/lohit-bengali/lohit_bn.ttf -filename.Lohit_Gujarati=/usr/share/fonts/lohit-gujarati/lohit_gu.ttf -filename.Lohit_Hindi=/usr/share/fonts/lohit-hindi/lohit_hi.ttf -filename.Lohit_Kannda=/usr/share/fonts/lohit-kannada/lohit_kn.ttf -filename.Lohit_Malayalam=/usr/share/fonts/lohit-malayalam/lohit_ml.ttf -filename.Lohit_Oriya=/usr/share/fonts/lohit-oriya/lohit_or.ttf -filename.Lohit_Punjabi=/usr/share/fonts/lohit-punjabi/lohit_pa.ttf -filename.Lohit_Tamil=/usr/share/fonts/lohit-tamil/lohit_ta.ttf -filename.Lohit_Telugu=/usr/share/fonts/lohit-telugu/lohit_te.ttf -filename.LKLUG=/usr/share/fonts/lklug/lklug.ttf - diff --git a/jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.SuSE.properties b/jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.SuSE.properties deleted file mode 100644 index fb86ded9afc..00000000000 --- a/jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.SuSE.properties +++ /dev/null @@ -1,154 +0,0 @@ -# -# -# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# Version - -# Uses SuSE 10.2 fonts and file paths. -version=1 - -# Component Font Mappings - -dialog.plain.latin-1=Albany AMT -dialog.plain.japanese-x0208=Sazanami Gothic -dialog.plain.korean=UnDotum - -dialog.bold.latin-1=Albany AMT Bold -dialog.bold.japanese-x0208=Sazanami Gothic -dialog.bold.korean=UnDotum Bold - -dialog.italic.latin-1=Albany AMT Italic -dialog.italic.japanese-x0208=Sazanami Gothic -dialog.italic.korean=UnDotum - -dialog.bolditalic.latin-1=Albany AMT Bold Italic -dialog.bolditalic.japanese-x0208=Sazanami Gothic -dialog.bolditalic.korean=UnDotum Bold - - -sansserif.plain.latin-1=Albany AMT -sansserif.plain.japanese-x0208=Sazanami Gothic -sansserif.plain.korean=UnDotum - -sansserif.bold.latin-1=Albany AMT Bold -sansserif.bold.japanese-x0208=Sazanami Gothic -sansserif.bold.korean=UnDotum Bold - -sansserif.italic.latin-1=Albany AMT Italic -sansserif.italic.japanese-x0208=Sazanami Gothic -sansserif.italic.korean=UnDotum - -sansserif.bolditalic.latin-1=Albany AMT Bold Italic -sansserif.bolditalic.japanese-x0208=Sazanami Gothic -sansserif.bolditalic.korean=UnDotum Bold - - -serif.plain.latin-1=Thorndale AMT -serif.plain.japanese-x0208=Sazanami Mincho -serif.plain.korean=UnBatang - -serif.bold.latin-1=Thorndale AMT Bold -serif.bold.japanese-x0208=Sazanami Mincho -serif.bold.korean=UnBatang Bold - -serif.italic.latin-1=Thorndale AMT Italic -serif.italic.japanese-x0208=Sazanami Mincho -serif.italic.korean=UnBatang - -serif.bolditalic.latin-1=Thorndale AMT Bold Italic -serif.bolditalic.japanese-x0208=Sazanami Mincho -serif.bolditalic.korean=UnBatang Bold - - -monospaced.plain.latin-1=Cumberland AMT -monospaced.plain.japanese-x0208=Sazanami Gothic -monospaced.plain.korean=UnDotum - -monospaced.bold.latin-1=Cumberland AMT Bold -monospaced.bold.japanese-x0208=Sazanami Gothic -monospaced.bold.korean=UnDotum Bold - -monospaced.italic.latin-1=Cumberland AMT Italic -monospaced.italic.japanese-x0208=Sazanami Gothic -monospaced.italic.korean=UnDotum - -monospaced.bolditalic.latin-1=Cumberland AMT Bold Italic -monospaced.bolditalic.japanese-x0208=Sazanami Gothic -monospaced.bolditalic.korean=UnDotum Bold - - -dialoginput.plain.latin-1=Cumberland AMT -dialoginput.plain.japanese-x0208=Sazanami Gothic -dialoginput.plain.korean=UnDotum - -dialoginput.bold.latin-1=Cumberland AMT Bold -dialoginput.bold.japanese-x0208=Sazanami Gothic -dialoginput.bold.korean=UnDotum Bold - -dialoginput.italic.latin-1=Cumberland AMT Italic -dialoginput.italic.japanese-x0208=Sazanami Gothic -dialoginput.italic.korean=UnDotum - -dialoginput.bolditalic.latin-1=Cumberland AMT Bold Italic -dialoginput.bolditalic.japanese-x0208=Sazanami Gothic -dialoginput.bolditalic.korean=UnDotum Bold - -allfonts.chinese-big5=AR PL Mingti2L Big5 -allfonts.chinese-gb18030=AR PL SungtiL GB - -# Search Sequences - -sequence.allfonts=latin-1 -sequence.allfonts.Big5=chinese-big5,latin-1 -sequence.allfonts.x-euc-jp-linux=japanese-x0208,latin-1 -sequence.allfonts.EUC-KR=korean,latin-1 -sequence.allfonts.GB18030=chinese-gb18030,latin-1 -sequence.fallback=chinese-big5,chinese-gb18030,japanese-x0208,korean - -# Font File Names - -filename.Albany_AMT=/usr/share/fonts/truetype/albw.ttf -filename.Albany_AMT_Bold=/usr/share/fonts/truetype/albwb.ttf -filename.Albany_AMT_Italic=/usr/share/fonts/truetype/albwb.ttf -filename.Albany_AMT_Bold_Italic=/usr/share/fonts/truetype/albwbi.ttf - -filename.Thorndale_AMT=/usr/share/fonts/truetype/thowr___.ttf -filename.Thorndale_AMT_Bold=/usr/share/fonts/truetype/thowb___.ttf -filename.Thorndale_AMT_Italic=/usr/share/fonts/truetype/thowi___.ttf -filename.Thorndale_AMT_Bold_Italic=/usr/share/fonts/truetype/thowbi__.ttf - -filename.Cumberland_AMT=/usr/share/fonts/truetype/cumbwr__.ttf -filename.Cumberland_AMT_Bold=/usr/share/fonts/truetype/cumbwb__.ttf -filename.Cumberland_AMT_Italic=/usr/share/fonts/truetype/cumbwi__.ttf -filename.Cumberland_AMT_Bold_Italic=/usr/share/fonts/truetype/cumbwbi_.ttf - -filename.Sazanami_Gothic=/usr/share/fonts/truetype/sazanami-gothic.ttf -filename.Sazanami_Mincho=/usr/share/fonts/truetype/sazanami-mincho.ttf -filename.AR_PL_SungtiL_GB=/usr/share/fonts/truetype/gbsn00lp.ttf -filename.AR_PL_Mingti2L_Big5=/usr/share/fonts/truetype/bsmi00lp.ttf -filename.UnDotum=/usr/share/fonts/truetype/UnDotum.ttf -filename.UnDotum_Bold=/usr/share/fonts/truetype/UnDotumBold.ttf -filename.UnBatang=/usr/share/fonts/truetype/UnBatang.ttf -filename.UnBatang_Bold=/usr/share/fonts/truetype/UnBatangBold.ttf diff --git a/jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.Ubuntu.properties b/jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.Ubuntu.properties deleted file mode 100644 index e1817934138..00000000000 --- a/jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.Ubuntu.properties +++ /dev/null @@ -1,348 +0,0 @@ -# -# -# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# Version - -# Uses Ubuntu 8.04 (hardy), Debian 6.0 (Squeeze) (and more recent releases) fonts and file paths. -version=1 - -# Component Font Mappings - -# Chinese fonts -allfonts.umingcn=AR PL UMing CN -#allfonts.umingcn.motif=AR PL UMing CN -allfonts.uminghk=AR PL UMing HK -#allfonts.uminghk.motif=AR PL UMing HK -allfonts.umingtw=AR PL UMing TW -#allfonts.umingtw.motif=AR PL UMing TW -allfonts.wqy-zenhei=WenQuanYi Zen Hei -#allfonts.wqy-zenhei.motif=WenQuanYi Zen Hei -allfonts.shanheisun=AR PL ShanHeiSun Uni -#allfonts.shanheisun.motif=AR PL ShanHeiSun Uni - -# Indic scripts -allfonts.bengali=Lohit Bengali -allfonts.gujarati=Lohit Gujarati -allfonts.hindi=Lohit Hindi -#allfonts.malayalam=Lohit Malayalam -allfonts.oriya=Lohit Oriya -allfonts.punjabi=Lohit Punjabi -allfonts.tamil=Lohit Tamil -allfonts.telugu=Lohit Telugu -allfonts.sinhala=LKLUG - - -serif.plain.latin-1=DejaVu Serif -#serif.plain.latin-1.motif=LuxiSerif-Regular -serif.plain.japanese-kochi=Kochi Mincho -serif.plain.japanese-sazanami=Sazanami Mincho -serif.plain.japanese-vlgothic=Sazanami Mincho -serif.plain.korean-baekmuk=Baekmuk Batang -#serif.plain.korean-baekmuk.motif=Baekmuk Batang -serif.plain.korean-un=UnBatang -#serif.plain.korean-un.motif=UnBatang - -serif.bold.latin-1=DejaVu Serif Bold -#serif.bold.latin-1.motif=LuxiSerif-Bold -serif.bold.japanese-kochi=Kochi Mincho -serif.bold.japanese-sazanami=Sazanami Mincho -serif.bold.japanese-vlgothic=Sazanami Mincho -serif.bold.korean-baekmuk=Baekmuk Batang -#serif.bold.korean-baekmuk.motif=Baekmuk Batang -serif.bold.korean-un=UnBatang Bold -#serif.bold.korean-un.motif=UnBatang Bold - -serif.italic.latin-1=DejaVu Serif Oblique -#serif.italic.latin-1.motif=LuxiSerif-Oblique -serif.italic.japanese-kochi=Kochi Mincho -serif.italic.japanese-sazanami=Sazanami Mincho -serif.italic.japanese-vlgothic=Sazanami Mincho -serif.italic.korean-baekmuk=Baekmuk Batang -#serif.italic.korean-baekmuk.motif=Baekmuk Batang -serif.italic.korean-un=UnBatang -#serif.italic.korean-un.motif=UnBatang - -serif.bolditalic.latin-1=DejaVu Serif Bold Oblique -#serif.bolditalic.latin-1.motif=LuxiSerif-BoldOblique -serif.bolditalic.japanese-kochi=Kochi Mincho -serif.bolditalic.japanese-sazanami=Sazanami Mincho -serif.bolditalic.japanese-vlgothic=Sazanami Mincho -serif.bolditalic.korean-baekmuk=Baekmuk Batang -#serif.bolditalic.korean-baekmuk.motif=Baekmuk Batang -serif.bolditalic.korean-un=UnBatang Bold -#serif.bolditalic.korean-un.motif=UnBatang Bold - -sansserif.plain.latin-1=DejaVu Sans -#sansserif.plain.latin-1.motif=LuxiSans-Regular -sansserif.plain.japanese-kochi=Kochi Gothic -sansserif.plain.japanese-sazanami=Sazanami Gothic -sansserif.plain.japanese-vlgothic=VL PGothic -sansserif.plain.korean-baekmuk=Baekmuk Gulim -#sansserif.plain.korean-baekmuk.motif=Baekmuk Gulim -sansserif.plain.korean-un=UnDotum -#sansserif.plain.korean-un.motif=UnDotum - -sansserif.bold.latin-1=DejaVu Sans Bold -#sansserif.bold.latin-1.motif=LuxiSans-Bold -sansserif.bold.japanese-kochi=Kochi Gothic -sansserif.bold.japanese-sazanami=Sazanami Gothic -sansserif.bold.japanese-vlgothic=VL PGothic -sansserif.bold.korean-baekmuk=Baekmuk Gulim -#sansserif.bold.korean-baekmuk.motif=Baekmuk Gulim -sansserif.bold.korean-un=UnDotum Bold -#sansserif.bold.korean-un.motif=UnDotum Bold - -sansserif.italic.latin-1=DejaVu Sans Oblique -#sansserif.italic.latin-1.motif=LuxiSans-Oblique -sansserif.italic.japanese-kochi=Kochi Gothic -sansserif.italic.japanese-sazanami=Sazanami Gothic -sansserif.italic.japanese-vlgothic=VL PGothic -sansserif.italic.korean-baekmuk=Baekmuk Gulim -#sansserif.italic.korean-baekmuk.motif=Baekmuk Gulim -sansserif.italic.korean-un=UnDotum -#sansserif.italic.korean-un.motif=UnDotum - -sansserif.bolditalic.latin-1=DejaVu Sans Bold Oblique -#sansserif.bolditalic.latin-1.motif=LuxiSans-BoldOblique -sansserif.bolditalic.japanese-kochi=Kochi Gothic -sansserif.bolditalic.japanese-sazanami=Sazanami Gothic -sansserif.bolditalic.japanese-vlgothic=VL PGothic -sansserif.bolditalic.korean-baekmuk=Baekmuk Gulim -#sansserif.bolditalic.korean-baekmuk.motif=Baekmuk Gulim -sansserif.bolditalic.korean-un=UnDotum Bold -#sansserif.bolditalic.korean-un.motif=UnDotum Bold - -monospaced.plain.latin-1=DejaVu Sans Mono -#monospaced.plain.latin-1.motif=LuxiMono-Regular -monospaced.plain.japanese-kochi=Kochi Gothic -monospaced.plain.japanese-sazanami=Sazanami Gothic -monospaced.plain.japanese-vlgothic=VL Gothic -monospaced.plain.korean-baekmuk=Baekmuk Gulim -#monospaced.plain.korean-baekmuk.motif=Baekmuk Gulim -monospaced.plain.korean-un=UnDotum -#monospaced.plain.korean-un.motif=UnDotum - -monospaced.bold.latin-1=DejaVu Sans Mono Bold -#monospaced.bold.latin-1.motif=LuxiMono-Bold -monospaced.bold.japanese-kochi=Kochi Gothic -monospaced.bold.japanese-sazanami=Sazanami Gothic -monospaced.bold.japanese-vlgothic=VL Gothic -monospaced.bold.korean-baekmuk=Baekmuk Gulim -#monospaced.bold.korean-baekmuk.motif=Baekmuk Gulim -monospaced.bold.korean-un=UnDotum Bold -#monospaced.bold.korean-un.motif=UnDotum Bold - -monospaced.italic.latin-1=DejaVu Sans Mono Oblique -#monospaced.italic.latin-1.motif=LuxiMono-Oblique -monospaced.italic.japanese-kochi=Kochi Gothic -monospaced.italic.japanese-sazanami=Sazanami Gothic -monospaced.italic.japanese-vlgothic=VL Gothic -monospaced.italic.korean-baekmuk=Baekmuk Gulim -#monospaced.italic.korean-baekmuk.motif=Baekmuk Gulim -monospaced.italic.korean-un=UnDotum -#monospaced.italic.korean-un.motif=UnDotum - -monospaced.bolditalic.latin-1=DejaVu Sans Mono Bold Oblique -#monospaced.bolditalic.latin-1.motif=LuxiMono-BoldOblique -monospaced.bolditalic.japanese-kochi=Kochi Gothic -monospaced.bolditalic.japanese-sazanami=Sazanami Gothic -monospaced.bolditalic.japanese-vlgothic=VL Gothic -monospaced.bolditalic.korean-baekmuk=Baekmuk Gulim -#monospaced.bolditalic.korean-baekmuk.motif=Baekmuk Gulim -monospaced.bolditalic.korean-un=UnDotum Bold -#monospaced.bolditalic.korean-un.motif=UnDotum Bold - -dialog.plain.latin-1=DejaVu Sans -#dialog.plain.latin-1.motif=LuxiSans-Regular -dialog.plain.japanese-kochi=Kochi Gothic -dialog.plain.japanese-sazanami=Sazanami Gothic -dialog.plain.japanese-vlgothic=VL PGothic -dialog.plain.korean-baekmuk=Baekmuk Gulim -#dialog.plain.korean-baekmuk.motif=Baekmuk Gulim -dialog.plain.korean-un=UnDotum -#dialog.plain.korean-un.motif=UnDotum - -dialog.bold.latin-1=DejaVu Sans Bold -#dialog.bold.latin-1.motif=LuxiSans-Bold -dialog.bold.japanese-kochi=Kochi Gothic -dialog.bold.japanese-sazanami=Sazanami Gothic -dialog.bold.japanese-vlgothic=VL PGothic -dialog.bold.korean-baekmuk=Baekmuk Gulim -#dialog.bold.korean-baekmuk.motif=Baekmuk Gulim -dialog.bold.korean-un=UnDotum Bold -#dialog.bold.korean-un.motif=UnDotum Bold - -dialog.italic.latin-1=DejaVu Sans Oblique -#dialog.italic.latin-1.motif=LuxiSans-Oblique -dialog.italic.japanese-kochi=Kochi Gothic -dialog.italic.japanese-sazanami=Sazanami Gothic -dialog.italic.japanese-vlgothic=VL PGothic -dialog.italic.korean-baekmuk=Baekmuk Gulim -#dialog.italic.korean-baekmuk.motif=Baekmuk Gulim -dialog.italic.korean-un=UnDotum -#dialog.italic.korean-un.motif=UnDotum - -dialog.bolditalic.latin-1=DejaVu Sans Bold Oblique -#dialog.bolditalic.latin-1.motif=LuxiSans-BoldOblique -dialog.bolditalic.japanese-kochi=Kochi Gothic -dialog.bolditalic.japanese-sazanami=Sazanami Gothic -dialog.bolditalic.japanese-vlgothic=VL PGothic -dialog.bolditalic.korean-baekmuk=Baekmuk Gulim -#dialog.bolditalic.korean-baekmuk.motif=Baekmuk Gulim -dialog.bolditalic.korean-un=UnDotum Bold -#dialog.bolditalic.korean-un.motif=UnDotum Bold - -dialoginput.plain.latin-1=DejaVu Sans Mono -#dialoginput.plain.latin-1.motif=LuxiMono-Regular -dialoginput.plain.japanese-kochi=Kochi Gothic -dialoginput.plain.japanese-sazanami=Sazanami Gothic -dialoginput.plain.japanese-vlgothic=VL Gothic -dialoginput.plain.korean-baekmuk=Baekmuk Gulim -#dialoginput.plain.korean-baekmuk.motif=Baekmuk Gulim -dialoginput.plain.korean-un=UnDotum -#dialoginput.plain.korean-un.motif=UnDotum - -dialoginput.bold.latin-1=DejaVu Sans Mono Bold -#dialoginput.bold.latin-1.motif=LuxiMono-Bold -dialoginput.bold.japanese-kochi=Kochi Gothic -dialoginput.bold.japanese-sazanami=Sazanami Gothic -dialoginput.bold.japanese-vlgothic=VL Gothic -dialoginput.bold.korean-baekmuk=Baekmuk Gulim -#dialoginput.bold.korean-baekmuk.motif=Baekmuk Gulim -dialoginput.bold.korean-un=UnDotum Bold -#dialoginput.bold.korean-un.motif=UnDotum Bold - -dialoginput.italic.latin-1=DejaVu Sans Mono Oblique -#dialoginput.italic.latin-1.motif=LuxiMono-Oblique -dialoginput.italic.japanese-kochi=Kochi Gothic -dialoginput.italic.japanese-sazanami=Sazanami Gothic -dialoginput.italic.japanese-vlgothic=VL Gothic -dialoginput.italic.korean-baekmuk=Baekmuk Gulim -#dialoginput.italic.korean-baekmuk.motif=Baekmuk Gulim -dialoginput.italic.korean-un=UnDotum -#dialoginput.italic.korean-un.motif=UnDotum - -dialoginput.bolditalic.latin-1=DejaVu Sans Mono Bold Oblique -#dialoginput.bolditalic.latin-1.motif=LuxiMono-BoldOblique -dialoginput.bolditalic.japanese-kochi=Kochi Gothic -dialoginput.bolditalic.japanese-sazanami=Sazanami Gothic -dialoginput.bolditalic.japanese-vlgothic=VL Gothic -dialoginput.bolditalic.korean-baekmuk=Baekmuk Gulim -#dialoginput.bolditalic.korean-baekmuk.motif=Baekmuk Gulim -dialoginput.bolditalic.korean-un=UnDotum Bold -#dialoginput.bolditalic.korean-un.motif=UnDotum Bold - -# Search Sequences - -sequence.allfonts=latin-1 -sequence.allfonts.GB18030=latin-1,umingcn,shanheisun,wqy-zenhei -sequence.allfonts.GB2312=latin-1,umingcn,shanheisun,wqy-zenhei -sequence.allfonts.GBK=latin-1,umingcn,shanheisun,wqy-zenhei -sequence.allfonts.x-euc-jp-linux=latin-1,japanese-vlgothic,japanese-sazanami,japanese-kochi -sequence.allfonts.EUC-KR=latin-1,korean-un,korean-baekmuk -sequence.allfonts.Big5=latin-1,umingtw,shanheisun,wqy-zenhei -sequence.allfonts.Big5-HKSCS=latin-1,uminghk,shanheisun,wqy-zenhei -#sequence.fallback=uminghk,shanheisun,wqy-zenhei,japanese-vlgothic,japanese-kochi,japanese-sazanami,korean-un,korean-baekmuk,bengali,gujarati,hindi,oriya,punjabi,malayalam,tamil,telugu,sinhala -sequence.fallback=uminghk,shanheisun,wqy-zenhei,japanese-vlgothic,japanese-sazanami,japanese-kochi,korean-un,korean-baekmuk,bengali,gujarati,hindi,oriya,punjabi,tamil,telugu - -# Exclusion Ranges - -exclusion.japanese-kochi=0390-03d6,2200-22ef,2701-27be -exclusion.japanese-sazanami=0390-03d6,2200-22ef,2701-27be -exclusion.japanese-vlgothic=0390-03d6,2200-22ef,2701-27be - -# Font File Names - -filename.DejaVu_Sans=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf -filename.DejaVu_Sans_Bold=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf -filename.DejaVu_Sans_Oblique=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Oblique.ttf -filename.DejaVu_Sans_Bold_Oblique=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-BoldOblique.ttf - -filename.DejaVu_Sans_Mono=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf -filename.DejaVu_Sans_Mono_Bold=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Bold.ttf -filename.DejaVu_Sans_Mono_Oblique=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Oblique.ttf -filename.DejaVu_Sans_Mono_Bold_Oblique=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-BoldOblique.ttf - -filename.DejaVu_Serif=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf -filename.DejaVu_Serif_Bold=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-Bold.ttf -filename.DejaVu_Serif_Oblique=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-Oblique.ttf -filename.DejaVu_Serif_Bold_Oblique=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-BoldOblique.ttf - -filename.AR_PL_UMing_CN=/usr/share/fonts/truetype/arphic/uming.ttc -filename.AR_PL_UMing_HK=/usr/share/fonts/truetype/arphic/uming.ttc -filename.AR_PL_UMing_TW=/usr/share/fonts/truetype/arphic/uming.ttc -filename.AR_PL_ShanHeiSun_Uni=/usr/share/fonts/truetype/arphic/uming.ttf - -filename.WenQuanYi_Zen_Hei=/usr/share/fonts/truetype/wqy/wqy-zenhei.ttf -filename.Baekmuk_Batang=/usr/share/fonts/truetype/baekmuk/batang.ttf -filename.UnBatang=/usr/share/fonts/truetype/unfonts/UnBatang.ttf -filename.UnBatang_Bold=/usr/share/fonts/truetype/unfonts/UnBatangBold.ttf -filename.Baekmuk_Gulim=/usr/share/fonts/truetype/baekmuk/gulim.ttf -filename.UnDotum=/usr/share/fonts/truetype/unfonts/UnDotum.ttf -filename.UnDotum_Bold=/usr/share/fonts/truetype/unfonts/UnDotumBold.ttf -filename.Kochi_Gothic=/usr/share/fonts/truetype/kochi/kochi-gothic.ttf -filename.Sazanami_Gothic=/usr/share/fonts/truetype/sazanami/sazanami-gothic.ttf -filename.Kochi_Mincho=/usr/share/fonts/truetype/kochi/kochi-mincho.ttf -filename.Sazanami_Mincho=/usr/share/fonts/truetype/sazanami/sazanami-mincho.ttf -filename.VL_Gothic=/usr/share/fonts/truetype/vlgothic/VL-Gothic-Regular.ttf -filename.VL_PGothic=/usr/share/fonts/truetype/vlgothic/VL-PGothic-Regular.ttf - -filename.Lohit_Bengali=/usr/share/fonts/truetype/ttf-bengali-fonts/lohit_bn.ttf -filename.Lohit_Gujarati=/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_gu.ttf -filename.Lohit_Hindi=/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_hi.ttf -filename.Lohit_Kannda=/usr/share/fonts/truetype/ttf-kannada-fonts/lohit_kn.ttf -#filename.Lohit_Malayalam=/usr/share/fonts/lohit-malayalam/lohit_ml.ttf -filename.Lohit_Oriya=/usr/share/fonts/truetype/ttf-oriya-fonts/lohit_or.ttf -filename.Lohit_Punjabi=/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf -filename.Lohit_Tamil=/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_ta.ttf -filename.Lohit_Telugu=/usr/share/fonts/truetype/ttf-telugu-fonts/lohit_te.ttf -filename.LKLUG=/usr/share/fonts/truetype/ttf-sinhala-lklug/lklug.ttf - -filename.LuxiSans-Regular=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxisr.ttf -filename.LuxiSans-Bold=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxisb.ttf -filename.LuxiSans-Oblique=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxisri.ttf -filename.LuxiSans-BoldOblique=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxisbi.ttf -filename.LuxiMono-Regular=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luximr.ttf -filename.LuxiMono-Bold=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luximb.ttf -filename.LuxiMono-Oblique=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luximri.ttf -filename.LuxiMono-BoldOblique=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luximbi.ttf -filename.LuxiSerif-Regular=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxirr.ttf -filename.LuxiSerif-Bold=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxirb.ttf -filename.LuxiSerif-Oblique=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxirri.ttf -filename.LuxiSerif-BoldOblique=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxirbi.ttf - -# AWT X11 font paths -awtfontpath.latin-1=/usr/share/fonts/X11/Type1 -awtfontpath.umingcn=/usr/share/fonts/truetype/arphic -awtfontpath.uminghk=/usr/share/fonts/truetype/arphic -awtfontpath.umingtw=/usr/share/fonts/truetype/arphic -awtfontpath.shanheisun=/usr/share/fonts/truetype/arphic -awtfontpath.wqy-zenhei=/usr/share/fonts/truetype/wqy -awtfontpath.japanese-kochi=/usr/share/fonts/truetype/kochi -awtfontpath.japanese-sazanami=/usr/share/fonts/truetype/sazanami -awtfontpath.japanese-vlgothic=/usr/share/fonts/truetype/vlgothic -awtfontpath.korean-baekmuk=/usr/share/fonts/truetype/baekmuk -awtfontpath.korean-un=/usr/share/fonts/truetype/unfonts diff --git a/jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.properties b/jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.properties deleted file mode 100644 index da4cf8d7225..00000000000 --- a/jdk/src/solaris/classes/sun/awt/fontconfigs/linux.fontconfig.properties +++ /dev/null @@ -1,189 +0,0 @@ -# -# -# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# Version - -# Uses Fedora Core 6 fonts and file paths. -version=1 - -# Component Font Mappings - -dialog.plain.latin-1=DejaVu LGC Sans -dialog.plain.japanese-x0208=Sazanami Gothic -dialog.plain.korean=Baekmuk Gulim -dialog.plain.chinese-big5=AR PL ShanHeiSun Uni -dialog.plain.chinese-gb18030=AR PL ShanHeiSun Uni - -dialog.bold.latin-1=DejaVu LGC Sans Bold -dialog.bold.japanese-x0208=Sazanami Gothic -dialog.bold.korean=Baekmuk Gulim -dialog.bold.chinese-big5=AR PL ShanHeiSun Uni -dialog.bold.chinese-gb18030=AR PL ShanHeiSun Uni - -dialog.italic.latin-1=DejaVu LGC Sans Oblique -dialog.italic.japanese-x0208=Sazanami Gothic -dialog.italic.korean=Baekmuk Gulim -dialog.italic.chinese-big5=AR PL ShanHeiSun Uni -dialog.italic.chinese-gb18030=AR PL ShanHeiSun Uni - -dialog.bolditalic.latin-1=DejaVu LGC Sans Bold Oblique -dialog.bolditalic.japanese-x0208=Sazanami Gothic -dialog.bolditalic.korean=Baekmuk Gulim -dialog.bolditalic.chinese-big5=AR PL ShanHeiSun Uni -dialog.bolditalic.chinese-gb18030=AR PL ShanHeiSun Uni - - -sansserif.plain.latin-1=DejaVu LGC Sans -sansserif.plain.japanese-x0208=Sazanami Gothic -sansserif.plain.korean=Baekmuk Gulim -sansserif.plain.chinese-big5=AR PL ShanHeiSun Uni -sansserif.plain.chinese-gb18030=AR PL ShanHeiSun Uni - -sansserif.bold.latin-1=DejaVu LGC Sans Bold -sansserif.bold.japanese-x0208=Sazanami Gothic -sansserif.bold.korean=Baekmuk Gulim -sansserif.bold.chinese-big5=AR PL ShanHeiSun Uni -sansserif.bold.chinese-gb18030=AR PL ShanHeiSun Uni - -sansserif.italic.latin-1=DejaVu LGC Sans Oblique -sansserif.italic.japanese-x0208=Sazanami Gothic -sansserif.italic.korean=Baekmuk Gulim -sansserif.italic.chinese-big5=AR PL ShanHeiSun Uni -sansserif.italic.chinese-gb18030=AR PL ShanHeiSun Uni - -sansserif.bolditalic.latin-1=DejaVu LGC Sans Bold Oblique -sansserif.bolditalic.japanese-x0208=Sazanami Gothic -sansserif.bolditalic.korean=Baekmuk Gulim -sansserif.bolditalic.chinese-big5=AR PL ShanHeiSun Uni -sansserif.bolditalic.chinese-gb18030=AR PL ShanHeiSun Uni - - -serif.plain.latin-1=DejaVu LGC Serif -serif.plain.japanese-x0208=Sazanami Mincho -serif.plain.korean=Baekmuk Batang -serif.plain.chinese-big5=AR PL ZenKai Uni -serif.plain.chinese-gb18030=AR PL ZenKai Uni - -serif.bold.latin-1=DejaVu LGC Serif Bold -serif.bold.japanese-x0208=Sazanami Mincho -serif.bold.korean=Baekmuk Batang -serif.bold.chinese-big5=AR PL ZenKai Uni -serif.bold.chinese-gb18030=AR PL ZenKai Uni - -serif.italic.latin-1=DejaVu LGC Serif Oblique -serif.italic.japanese-x0208=Sazanami Mincho -serif.italic.korean=Baekmuk Batang -serif.italic.chinese-big5=AR PL ZenKai Uni -serif.italic.chinese-gb18030=AR PL ZenKai Uni - -serif.bolditalic.latin-1=DejaVu LGC Serif Bold Oblique -serif.bolditalic.japanese-x0208=Sazanami Mincho -serif.bolditalic.korean=Baekmuk Batang -serif.bolditalic.chinese-big5=AR PL ZenKai Uni -serif.bolditalic.chinese-gb18030=AR PL ZenKai Uni - - -monospaced.plain.latin-1=DejaVu LGC Sans Mono -monospaced.plain.japanese-x0208=Sazanami Gothic -monospaced.plain.korean=Baekmuk Gulim -monospaced.plain.chinese-big5=AR PL ShanHeiSun Uni -monospaced.plain.chinese-gb18030=AR PL ShanHeiSun Uni - -monospaced.bold.latin-1=DejaVu LGC Sans Mono Bold -monospaced.bold.japanese-x0208=Sazanami Gothic -monospaced.bold.korean=Baekmuk Gulim -monospaced.bold.chinese-big5=AR PL ShanHeiSun Uni -monospaced.bold.chinese-gb18030=AR PL ShanHeiSun Uni - -monospaced.italic.latin-1=DejaVu LGC Sans Mono Oblique -monospaced.italic.japanese-x0208=Sazanami Gothic -monospaced.italic.korean=Baekmuk Gulim -monospaced.italic.chinese-big5=AR PL ShanHeiSun Uni -monospaced.italic.chinese-gb18030=AR PL ShanHeiSun Uni - -monospaced.bolditalic.latin-1=DejaVu LGC Sans Mono Bold Oblique -monospaced.bolditalic.japanese-x0208=Sazanami Gothic -monospaced.bolditalic.korean=Baekmuk Gulim -monospaced.bolditalic.chinese-big5=AR PL ShanHeiSun Uni -monospaced.bolditalic.chinese-gb18030=AR PL ShanHeiSun Uni - - -dialoginput.plain.latin-1=DejaVu LGC Sans Mono -dialoginput.plain.japanese-x0208=Sazanami Gothic -dialoginput.plain.korean=Baekmuk Gulim -dialoginput.plain.chinese-big5=AR PL ShanHeiSun Uni -dialoginput.plain.chinese-gb18030=AR PL ShanHeiSun Uni - -dialoginput.bold.latin-1=DejaVu LGC Sans Mono Bold -dialoginput.bold.japanese-x0208=Sazanami Gothic -dialoginput.bold.korean=Baekmuk Gulim -dialoginput.bold.chinese-big5=AR PL ShanHeiSun Uni -dialoginput.bold.chinese-gb18030=AR PL ShanHeiSun Uni - -dialoginput.italic.latin-1=DejaVu LGC Sans Mono Oblique -dialoginput.italic.japanese-x0208=Sazanami Gothic -dialoginput.italic.korean=Baekmuk Gulim -dialoginput.italic.chinese-big5=AR PL ShanHeiSun Uni -dialoginput.italic.chinese-gb18030=AR PL ShanHeiSun Uni - -dialoginput.bolditalic.latin-1=DejaVu LGC Sans Mono Bold Oblique -dialoginput.bolditalic.japanese-x0208=Sazanami Gothic -dialoginput.bolditalic.korean=Baekmuk Gulim -dialoginput.bolditalic.chinese-big5=AR PL ShanHeiSun Uni -dialoginput.bolditalic.chinese-gb18030=AR PL ShanHeiSun Uni - -# Search Sequences - -sequence.allfonts=latin-1 -sequence.allfonts.Big5=chinese-big5,latin-1 -sequence.allfonts.x-euc-jp-linux=japanese-x0208,latin-1 -sequence.allfonts.EUC-KR=korean,latin-1 -sequence.allfonts.GB18030=chinese-gb18030,latin-1 -sequence.fallback=chinese-big5,chinese-gb18030,japanese-x0208,korean - -# Font File Names - -filename.DejaVu_LGC_Sans=/usr/share/fonts/dejavu-lgc/DejaVuLGCSans.ttf -filename.DejaVu_LGC_Sans_Bold=/usr/share/fonts/dejavu-lgc/DejaVuLGCSans-Bold.ttf -filename.DejaVu_LGC_Sans_Oblique=/usr/share/fonts/dejavu-lgc/DejaVuLGCSans-Oblique.ttf -filename.DejaVu_LGC_Sans_Bold_Oblique=/usr/share/fonts/dejavu-lgc/DejaVuLGCSans-BoldOblique.ttf - -filename.DejaVu_LGC_Sans_Mono=/usr/share/fonts/dejavu-lgc/DejaVuLGCSansMono.ttf -filename.DejaVu_LGC_Sans_Mono_Bold=/usr/share/fonts/dejavu-lgc/DejaVuLGCSansMono-Bold.ttf -filename.DejaVu_LGC_Sans_Mono_Oblique=/usr/share/fonts/dejavu-lgc/DejaVuLGCSansMono-Oblique.ttf -filename.DejaVu_LGC_Sans_Mono_Bold_Oblique=/usr/share/fonts/dejavu-lgc/DejaVuLGCSansMono-BoldOblique.ttf - -filename.DejaVu_LGC_Serif=/usr/share/fonts/dejavu-lgc/DejaVuLGCSerif.ttf -filename.DejaVu_LGC_Serif_Bold=/usr/share/fonts/dejavu-lgc/DejaVuLGCSerif-Bold.ttf -filename.DejaVu_LGC_Serif_Oblique=/usr/share/fonts/dejavu-lgc/DejaVuLGCSerif-Oblique.ttf -filename.DejaVu_LGC_Serif_Bold_Oblique=/usr/share/fonts/dejavu-lgc/DejaVuLGCSerif-BoldOblique.ttf - -filename.Sazanami_Gothic=/usr/share/fonts/japanese/TrueType/sazanami-gothic.ttf -filename.Sazanami_Mincho=/usr/share/fonts/japanese/TrueType/sazanami-mincho.ttf -filename.AR_PL_ShanHeiSun_Uni=/usr/share/fonts/chinese/TrueType/uming.ttf -filename.AR_PL_ZenKai_Uni=/usr/share/fonts/chinese/TrueType/ukai.ttf -filename.Baekmuk_Gulim=/usr/share/fonts/korean/TrueType/gulim.ttf -filename.Baekmuk_Batang=/usr/share/fonts/korean/TrueType/batang.ttf From 7fe48f8a2018f92ebb6e81a021f9596c883fb9cd Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 30 May 2013 10:57:50 -0700 Subject: [PATCH 092/206] Added tag jdk8-b92 for changeset b51d66ab6ffd --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index dc47bb707b1..729f6cad52d 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -213,3 +213,4 @@ e1a929afcfc492470d50be0b6b0e8dc77d3760b9 jdk8-b88 892a0196d10c67f3a12f0eefb0bb536e423d8868 jdk8-b89 69b773a221b956a3386933ecdbfeccee0edeac47 jdk8-b90 cb51fb4789ac0b8be4056482077ddfb8f3bd3805 jdk8-b91 +3a36c926a7aafa9d4a892a45ef3678e87ad8359b jdk8-b92 From 5eaf3d4ac5f3001bd711124428c5754702eec53c Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 30 May 2013 10:57:52 -0700 Subject: [PATCH 093/206] Added tag jdk8-b92 for changeset 8ada1018118c --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index af3629045ae..f928f750ea0 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -213,3 +213,4 @@ f1709874d55a06bc3d5dfa02dbcdfbc59f4cba34 jdk8-b87 fe4150590ee597f4e125fea950aa3b352622cc2d jdk8-b89 c8286839d0df04aba819ec4bef12b86babccf30e jdk8-b90 8f7ffb296385f85a4a6d53f9f2d4a7b13a8fa1ff jdk8-b91 +717aa26f8e0a1c0e768aebb3a763aca56db0c83e jdk8-b92 From e9072745064b0a6b3efc019f5fbb8ee222add6a6 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 30 May 2013 10:57:57 -0700 Subject: [PATCH 094/206] Added tag jdk8-b92 for changeset b34bf6985a14 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index f2fb4715f13..8fd9b705d0f 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -345,3 +345,4 @@ c4af77d2045476c56fbf3f914b336bb1b7cd18af hs25-b30 b19517cecc2e91636d7c16ba2f35e3d3dc628099 hs25-b33 7cbdf0e3725c0c56a2ff7540fc70b6d4b5890d04 jdk8-b91 38da9f4f67096745f851318d792d6468aa1f6cf8 hs25-b34 +092018493d3bbeb1c24278fd8c40ff3d76e1fed7 jdk8-b92 From a979b3188ffb717e2fcdab756fb132f169d89da1 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 30 May 2013 10:58:08 -0700 Subject: [PATCH 095/206] Added tag jdk8-b92 for changeset d2f0e76ff056 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index e23e9fa8292..5df651317b4 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -213,3 +213,4 @@ eddbc8ad2435a89f64729512337c9f2669e4dd85 jdk8-b87 893d2ba8bbea3a8d090e51d8eaea285b390789ea jdk8-b89 668acc0e1034bc1bec6d02be92e0dd4a63d0667e jdk8-b90 e3065fb07877c7e96e8b93416fe2ab9a4c9eb2a5 jdk8-b91 +1ab5d8d6eab81e65c6c3cf21739474cd67a0e7cf jdk8-b92 From d30d85e939122ca05f983d9db6f2bdada0ba719e Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 30 May 2013 10:58:13 -0700 Subject: [PATCH 096/206] Added tag jdk8-b92 for changeset 3e02d3c20e99 --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 088ec3da462..199677923db 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -213,3 +213,4 @@ a5e7c2f093c9996ab3419db1565094a07b059e9c jdk8-b86 88838e08e4ef6a254867c8126070a1975683108d jdk8-b89 3e5b9ea5ac35ea7096da484e24a863cf4552179f jdk8-b90 0bb1a9fa56b037d072efdaae5f5b73a0f23c966c jdk8-b91 +a0f604766ca14818e2a7b1558cc399499caabf75 jdk8-b92 From f49bd7d3b8ec8565c6322563671137d275f4fc0f Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 30 May 2013 10:58:32 -0700 Subject: [PATCH 097/206] Added tag jdk8-b92 for changeset fe7926936461 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 1c4ad707352..3d445226a63 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -213,3 +213,4 @@ a1e10f3adc47c8602a72e43a41403a642e73e0b1 jdk8-b88 ec434cfd2752a7742c875c2fe7d556d8b81c0f3a jdk8-b89 e19283cd30a43fca94d8f7639c73ef66db493b1e jdk8-b90 997c0fae2b12108959387862be54b78ca0ae3fca jdk8-b91 +149890642a0ed5138a4f16fe08ddbfeb8f8a1cb4 jdk8-b92 From 403f5cc7b32b7df1757b66d830152df2d4dad9f1 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 30 May 2013 10:58:35 -0700 Subject: [PATCH 098/206] Added tag jdk8-b92 for changeset 3ed2867af3bf --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index 0c80753de1e..b4d15f59f0d 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -201,3 +201,4 @@ e0378f0a50dafdcfb7b04f6401d320f89884baa1 jdk8-b85 45ce27fbe2720d80070095c0db7344ec41e2833d jdk8-b89 67ca019e3713dd71c884d753de02fd0021981969 jdk8-b90 6b9f4120380091b8b1751a825b9f84bf1be224fe jdk8-b91 +dee23cce5235b594a96d3361b65eacc97bd5a583 jdk8-b92 From a246da16d1caab2f524a7aa23cae22511f68364e Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Thu, 30 May 2013 11:46:39 -0700 Subject: [PATCH 099/206] 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds The InstanceKlass _initial_method_idnum value must be adjusted if overpass methods are added. Reviewed-by: twisti, kvn --- .../src/share/vm/classfile/defaultMethods.cpp | 1 + .../test/compiler/8015436/Test8015436.java | 74 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 hotspot/test/compiler/8015436/Test8015436.java diff --git a/hotspot/src/share/vm/classfile/defaultMethods.cpp b/hotspot/src/share/vm/classfile/defaultMethods.cpp index 1977b07ea10..d6529ca4439 100644 --- a/hotspot/src/share/vm/classfile/defaultMethods.cpp +++ b/hotspot/src/share/vm/classfile/defaultMethods.cpp @@ -1349,6 +1349,7 @@ static void merge_in_new_methods(InstanceKlass* klass, // Replace klass methods with new merged lists klass->set_methods(merged_methods); + klass->set_initial_method_idnum(new_size); ClassLoaderData* cld = klass->class_loader_data(); MetadataFactory::free_array(cld, original_methods); diff --git a/hotspot/test/compiler/8015436/Test8015436.java b/hotspot/test/compiler/8015436/Test8015436.java new file mode 100644 index 00000000000..5037a7a73af --- /dev/null +++ b/hotspot/test/compiler/8015436/Test8015436.java @@ -0,0 +1,74 @@ +/* + * 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 8015436 + * @summary the IK _initial_method_idnum value must be adjusted if overpass methods are added + * @run main Test8015436 + * + */ + +/* + * The test checks that a MemberName for the defaultMethod() is cached in + * the class MemberNameTable without a crash in the VM fastdebug mode. + * The original issue was that the InstanceKlass _initial_method_idnum was + * not adjusted properly when the overpass methods are added to the class. + * The expected/correct behavior: The test does not crash nor throw any exceptions. + * All the invocations of the defaultMethod() must be completed successfully. + */ + +import java.lang.invoke.*; + +interface InterfaceWithDefaultMethod { + public void someMethod(); + + default public void defaultMethod(String str){ + System.out.println("defaultMethod() " + str); + } +} + +class Test8015436 implements InterfaceWithDefaultMethod { + @Override + public void someMethod() { + System.out.println("someMethod() invoked"); + } + + public static void main(String[] args) throws Throwable { + Test8015436 testObj = new Test8015436(); + testObj.someMethod(); + testObj.defaultMethod("invoked directly"); + + MethodHandles.Lookup lookup = MethodHandles.lookup(); + MethodType mt = MethodType.methodType(void.class, String.class); + MethodHandle mh = lookup.findVirtual(Test8015436.class, "defaultMethod", mt); + mh.invokeExact(testObj, "invoked via a MethodHandle"); + } +} + +/* + * A successful execution gives the output: + * someMethod() invoked + * defaultMethod() invoked directly + * defaultMethod() invoked via a MethodHandle + */ From 06d1d22eb56c0f4f043548409c017d515b75858f Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Fri, 31 May 2013 10:04:59 +0100 Subject: [PATCH 100/206] 7179353: try-with-resources fails to compile with generic exception parameters Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/Flow.java | 8 ++-- .../com/sun/tools/javac/comp/Resolve.java | 6 +-- .../GenericsAndTWRCompileErrorTest.java | 42 +++++++++++++++++++ 3 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 langtools/test/tools/javac/T7179353/GenericsAndTWRCompileErrorTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java index 1e6d7da1839..85ce604ff4f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -808,9 +808,10 @@ public class Flow { */ void markThrown(JCTree tree, Type exc) { if (!chk.isUnchecked(tree.pos(), exc)) { - if (!chk.isHandled(exc, caught)) + if (!chk.isHandled(exc, caught)) { pendingExits.append(new FlowPendingExit(tree, exc)); - thrown = chk.incl(exc, thrown); + } + thrown = chk.incl(exc, thrown); } } @@ -1066,8 +1067,9 @@ public class Flow { names.close, List.nil(), List.nil()); + Type mt = types.memberType(resource.type, closeMethod); if (closeMethod.kind == MTH) { - for (Type t : ((MethodSymbol)closeMethod).getThrownTypes()) { + for (Type t : mt.getThrownTypes()) { markThrown(resource, t); } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index 09b1d4c92f2..9618a00c3bb 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -349,7 +349,7 @@ public class Resolve { : isAccessible(env, t.tsym, checkInner); } - /** Is symbol accessible as a member of given type in given evironment? + /** Is symbol accessible as a member of given type in given environment? * @param env The current environment. * @param site The type of which the tested symbol is regarded * as a member. @@ -490,11 +490,11 @@ public class Resolve { }; /** Try to instantiate the type of a method so that it fits - * given type arguments and argument types. If succesful, return + * given type arguments and argument types. If successful, return * the method's instantiated type, else return null. * The instantiation will take into account an additional leading * formal parameter if the method is an instance method seen as a member - * of un underdetermined site In this case, we treat site as an additional + * of an under determined site. In this case, we treat site as an additional * parameter and the parameters of the class containing the method as * additional type variables that get instantiated. * diff --git a/langtools/test/tools/javac/T7179353/GenericsAndTWRCompileErrorTest.java b/langtools/test/tools/javac/T7179353/GenericsAndTWRCompileErrorTest.java new file mode 100644 index 00000000000..133bc345ff2 --- /dev/null +++ b/langtools/test/tools/javac/T7179353/GenericsAndTWRCompileErrorTest.java @@ -0,0 +1,42 @@ +/* + * 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 7179353 + * @summary try-with-resources fails to compile with generic exception parameters + * @compile GenericsAndTWRCompileErrorTest.java + */ + +public class GenericsAndTWRCompileErrorTest { + + public static class Resource implements AutoCloseable { + public void close() throws E { } + } + + public void test() throws E { + try (Resource r = new Resource()) { + + } + } +} From 912472fd718aa2fb51a203f7a8a3e649b8745e98 Mon Sep 17 00:00:00 2001 From: Anthony Petrov Date: Fri, 31 May 2013 14:12:53 +0400 Subject: [PATCH 101/206] 8013189: JMenuItems draw behind TextArea Untie XTextAreaPeer internal components from the TextArea parent to prevent its invalidation. I.e. force the java.awt.smartInvalidate=true locally. Reviewed-by: art, serb --- .../classes/sun/awt/X11/XTextAreaPeer.java | 13 +++ .../awt/TextArea/Mixing/TextAreaMixing.java | 99 +++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 jdk/test/java/awt/TextArea/Mixing/TextAreaMixing.java diff --git a/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java index fcefc02bbfd..27465df84a5 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java @@ -1143,6 +1143,19 @@ class XTextAreaPeer extends XComponentPeer implements TextAreaPeer { addNotify(); } + @Override + public void invalidate() { + synchronized (getTreeLock()) { + final Container parent = getParent(); + AWTAccessor.getComponentAccessor().setParent(this, null); + try { + super.invalidate(); + } finally { + AWTAccessor.getComponentAccessor().setParent(this, parent); + } + } + } + public void focusGained(FocusEvent e) { Graphics g = getGraphics(); Rectangle r = getViewportBorderBounds(); diff --git a/jdk/test/java/awt/TextArea/Mixing/TextAreaMixing.java b/jdk/test/java/awt/TextArea/Mixing/TextAreaMixing.java new file mode 100644 index 00000000000..f07ddf3bd99 --- /dev/null +++ b/jdk/test/java/awt/TextArea/Mixing/TextAreaMixing.java @@ -0,0 +1,99 @@ +/* + * 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 8013189 + * @run main TextAreaMixing + * @summary TextArea should support HW/LW mixing + * @author anthony.petrov@oracle.com + */ + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +public class TextAreaMixing { + + private static volatile boolean menuClicked = false; + private static JMenuItem menuItem; + + public static void main(String[] args) throws Exception { + // The bug is only reproducible on X11, but there's no reason + // for this test to not pass on any platofrm + + final JFrame frame = new JFrame("JFrame"); + frame.setLayout(new GridLayout(0, 1)); + frame.setSize(200, 200); + + JMenuBar menuBar = new JMenuBar(); + JMenu menu = new JMenu("Test Menu"); + + for (int i = 0; i < 6; i++) { + JMenuItem mi = new JMenuItem(Integer.toString(i)); + mi.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + menuClicked = true; + } + }); + menu.add(mi); + + // Choose a random (OK, the fourth) menu item to click on + if (i == 3) { + menuItem = mi; + } + } + menuBar.add(menu); + frame.setJMenuBar(menuBar); + + frame.getContentPane().add(new TextArea()); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + + Thread.sleep(2000); + + Robot robot = new Robot(); + + // Open the menu + Point loc = menu.getLocationOnScreen(); + robot.mouseMove(loc.x + menu.getWidth() / 2, loc.y + menu.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + Thread.sleep(500); + + // Click an item + loc = menuItem.getLocationOnScreen(); + robot.mouseMove(loc.x + menuItem.getWidth() / 2, loc.y + menuItem.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + Thread.sleep(500); + + frame.dispose(); + + if (!menuClicked) { + throw new RuntimeException("A menu item has never been clicked."); + } + } +} From 3c4b82e2bbe44472434de537566e4081a61c5e2b Mon Sep 17 00:00:00 2001 From: Andrew Brygin Date: Fri, 31 May 2013 14:30:28 +0400 Subject: [PATCH 102/206] 8015606: Text is not rendered correctly if destination buffer is custom Reviewed-by: prr, vadim --- .../classes/sun/java2d/loops/MaskFill.java | 4 + .../loops/RenderToCustomBufferTest.java | 115 ++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 jdk/test/sun/java2d/loops/RenderToCustomBufferTest.java diff --git a/jdk/src/share/classes/sun/java2d/loops/MaskFill.java b/jdk/src/share/classes/sun/java2d/loops/MaskFill.java index 47c41ee1cd3..601a3fc7eb8 100644 --- a/jdk/src/share/classes/sun/java2d/loops/MaskFill.java +++ b/jdk/src/share/classes/sun/java2d/loops/MaskFill.java @@ -36,6 +36,7 @@ import sun.awt.image.BufImgSurfaceData; import sun.java2d.loops.GraphicsPrimitive; import sun.java2d.SunGraphics2D; import sun.java2d.SurfaceData; +import sun.java2d.pipe.Region; /** * MaskFill @@ -194,10 +195,13 @@ public class MaskFill extends GraphicsPrimitive // REMIND: This is not pretty. It would be nicer if we // passed a "FillData" object to the Pixel loops, instead // of a SunGraphics2D parameter... + Region clip = sg2d.clipRegion; + sg2d.clipRegion = null; int pixel = sg2d.pixel; sg2d.pixel = tmpData.pixelFor(sg2d.getColor()); fillop.FillRect(sg2d, tmpData, 0, 0, w, h); sg2d.pixel = pixel; + sg2d.clipRegion = clip; maskop.MaskBlit(tmpData, sData, comp, null, 0, 0, x, y, w, h, diff --git a/jdk/test/sun/java2d/loops/RenderToCustomBufferTest.java b/jdk/test/sun/java2d/loops/RenderToCustomBufferTest.java new file mode 100644 index 00000000000..37e866f5ba0 --- /dev/null +++ b/jdk/test/sun/java2d/loops/RenderToCustomBufferTest.java @@ -0,0 +1,115 @@ +/* + * 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 8015606 + * @summary Test verifies whether a text is rendered correctly to + * a custom buffered image. + * + * @run main RenderToCustomBufferTest + */ + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.Transparency; +import java.awt.color.ColorSpace; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.ComponentColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.WritableRaster; + +public class RenderToCustomBufferTest { + public static void main(String[] args) { + final BufferedImage dst_custom = createCustomBuffer(); + final BufferedImage dst_dcm = new BufferedImage(width, height, + BufferedImage.TYPE_INT_RGB); + + renderTo(dst_custom); + renderTo(dst_dcm); + + check(dst_custom, dst_dcm); + } + + private static void check(BufferedImage a, BufferedImage b) { + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + int pa = a.getRGB(x, y); + int pb = b.getRGB(x, y); + + if (pa != pb) { + String msg = String.format( + "Point [%d, %d] has different colors: %08X and %08X", + x, y, pa, pb); + throw new RuntimeException("Test failed: " + msg); + } + } + } + } + + private static BufferedImage createCustomBuffer() { + ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); + ColorModel cm = new ComponentColorModel(cs, false, false, + Transparency.OPAQUE, DataBuffer.TYPE_FLOAT); + WritableRaster wr = cm.createCompatibleWritableRaster(width, height); + + return new BufferedImage(cm, wr, false, null); + } + + private static void renderTo(BufferedImage dst) { + System.out.println("The buffer: " + dst); + Graphics2D g = dst.createGraphics(); + + final int w = dst.getWidth(); + final int h = dst.getHeight(); + + g.setColor(Color.blue); + g.fillRect(0, 0, w, h); + + g.setColor(Color.red); + Font f = g.getFont(); + g.setFont(f.deriveFont(48f)); + + g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + + // NB: this clip ctriggers the problem + g.setClip(50, 50, 200, 100); + + g.drawString("AA Text", 52, 90); + + g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); + + // NB: this clip ctriggers the problem + g.setClip(50, 100, 100, 100); + g.drawString("Text", 52, 148); + + g.dispose(); + } + + private static final int width = 230; + private static final int height = 150; +} From 8bcbbe70deb978d2f56eb8d7c52ec52a07b3514a Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Fri, 31 May 2013 12:56:56 +0200 Subject: [PATCH 103/206] 8015693: reduce NodeLiteralNode to NullLiteralNode Reviewed-by: jlaskey, lagergren --- .../jdk/nashorn/internal/ir/LiteralNode.java | 62 +++---------------- 1 file changed, 9 insertions(+), 53 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java b/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java index 7a59c5fe840..c34f9d94c5b 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java @@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir; import java.util.Arrays; import java.util.Collections; import java.util.List; - import jdk.nashorn.internal.codegen.CompileUnit; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.annotations.Immutable; @@ -242,8 +241,8 @@ public abstract class LiteralNode extends Node implements PropertyKey { * * @return the new literal node */ - public static LiteralNode newInstance(final long token, final int finish) { - return new NodeLiteralNode(token, finish); + public static LiteralNode newInstance(final long token, final int finish) { + return new NullLiteralNode(token, finish); } /** @@ -253,8 +252,8 @@ public abstract class LiteralNode extends Node implements PropertyKey { * * @return the new literal node */ - public static LiteralNode newInstance(final Node parent) { - return new NodeLiteralNode(parent.getToken(), parent.getFinish()); + public static LiteralNode newInstance(final Node parent) { + return new NullLiteralNode(parent.getToken(), parent.getFinish()); } @Immutable @@ -496,33 +495,15 @@ public abstract class LiteralNode extends Node implements PropertyKey { return new LexerTokenLiteralNode(parent.getToken(), parent.getFinish(), value); } - private static final class NodeLiteralNode extends LiteralNode { + private static final class NullLiteralNode extends LiteralNode { - private NodeLiteralNode(final long token, final int finish) { - this(token, finish, null); - } - - private NodeLiteralNode(final long token, final int finish, final Node value) { - super(Token.recast(token, TokenType.OBJECT), finish, value); - } - - private NodeLiteralNode(final LiteralNode literalNode) { - super(literalNode); - } - - private NodeLiteralNode(final LiteralNode literalNode, final Node value) { - super(literalNode, value); + private NullLiteralNode(final long token, final int finish) { + super(Token.recast(token, TokenType.OBJECT), finish, null); } @Override public Node accept(final NodeVisitor visitor) { if (visitor.enterLiteralNode(this)) { - if (value != null) { - final Node newValue = value.accept(visitor); - if(value != newValue) { - return visitor.leaveLiteralNode(new NodeLiteralNode(this, newValue)); - } - } return visitor.leaveLiteralNode(this); } @@ -531,38 +512,13 @@ public abstract class LiteralNode extends Node implements PropertyKey { @Override public Type getType() { - return value == null ? Type.OBJECT : super.getType(); + return Type.OBJECT; } @Override public Type getWidestOperationType() { - return value == null ? Type.OBJECT : value.getWidestOperationType(); + return Type.OBJECT; } - - } - /** - * Create a new node literal for an arbitrary node - * - * @param token token - * @param finish finish - * @param value the literal value node - * - * @return the new literal node - */ - public static LiteralNode newInstance(final long token, final int finish, final Node value) { - return new NodeLiteralNode(token, finish, value); - } - - /** - * Create a new node literal based on a parent node (source, token, finish) - * - * @param parent parent node - * @param value node value - * - * @return the new literal node - */ - public static LiteralNode newInstance(final Node parent, final Node value) { - return new NodeLiteralNode(parent.getToken(), parent.getFinish(), value); } /** From 9617ee41ca599d227e537b31c6f5bc5501576014 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Fri, 31 May 2013 12:57:25 +0200 Subject: [PATCH 104/206] 8015684: FieldObjectCreator.putField ignores getValueType Reviewed-by: jlaskey, lagergren --- .../nashorn/internal/codegen/CodeGenerator.java | 13 +------------ .../internal/codegen/FieldObjectCreator.java | 16 ---------------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index 21b61cd8ec5..c291707301b 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -60,7 +60,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.TreeMap; - import jdk.nashorn.internal.codegen.ClassEmitter.Flag; import jdk.nashorn.internal.codegen.CompilerConstants.Call; import jdk.nashorn.internal.codegen.RuntimeCallSite.SpecializedRuntimeNode; @@ -80,11 +79,11 @@ import jdk.nashorn.internal.ir.EmptyNode; import jdk.nashorn.internal.ir.ExecuteNode; import jdk.nashorn.internal.ir.ForNode; import jdk.nashorn.internal.ir.FunctionNode; -import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.IdentNode; import jdk.nashorn.internal.ir.IfNode; import jdk.nashorn.internal.ir.IndexNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.LexicalContextNode; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; @@ -941,11 +940,6 @@ final class CodeGenerator extends NodeOperatorVisitor foc = new FieldObjectCreator(this, nameList, newSymbols, values, true, hasArguments) { - @Override - protected Type getValueType(final Symbol value) { - return value.getSymbolType(); - } - @Override protected void loadValue(final Symbol value) { method.load(value); @@ -1356,11 +1350,6 @@ final class CodeGenerator extends NodeOperatorVisitor(this, keys, symbols, values) { - @Override - protected Type getValueType(final Node node) { - return node.getType(); - } - @Override protected void loadValue(final Node node) { load(node); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java b/nashorn/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java index 57b8b384919..16ad2709762 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java @@ -144,15 +144,6 @@ public abstract class FieldObjectCreator extends ObjectCreator { */ protected abstract void loadValue(T value); - /** - * Determine the type of a value. Defined by anonymous subclasses in code gen. - * - * @param value Value to inspect. - * - * @return Value type. - */ - protected abstract Type getValueType(T value); - /** * Store a value in a field of the generated class object. * @@ -165,13 +156,6 @@ public abstract class FieldObjectCreator extends ObjectCreator { method.dup(); loadValue(value); - - final Type valueType = getValueType(value); - // for example when we have a with scope - if (valueType.isObject() || valueType.isBoolean()) { - method.convert(OBJECT); - } - method.convert(OBJECT); method.putField(getClassName(), ObjectClassGenerator.getFieldName(fieldIndex, Type.OBJECT), typeDescriptor(Object.class)); } From 102a06fdef3e0c92c4e9e2ec24956fbe0a13541c Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Fri, 31 May 2013 12:57:44 +0200 Subject: [PATCH 105/206] 8015674: CodeGenerator.initSymbols mutates a list Reviewed-by: jlaskey, lagergren --- .../internal/codegen/CodeGenerator.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index c291707301b..34837bfac74 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -456,17 +456,18 @@ final class CodeGenerator extends NodeOperatorVisitor symbols, final Type type) { - if (symbols.isEmpty()) { - return; - } - - method.loadUndefined(type); - while (!symbols.isEmpty()) { - final Symbol symbol = symbols.removeFirst(); - if (!symbols.isEmpty()) { - method.dup(); - } - method.store(symbol); + final Iterator it = symbols.iterator(); + if(it.hasNext()) { + method.loadUndefined(type); + boolean hasNext; + do { + final Symbol symbol = it.next(); + hasNext = it.hasNext(); + if(hasNext) { + method.dup(); + } + method.store(symbol); + } while(hasNext); } } From c6404425ec6787c18c815c7b3cb13ae3134fb17c Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Fri, 31 May 2013 12:58:02 +0200 Subject: [PATCH 106/206] 8015673: Type for :e symbol is wrong Reviewed-by: jlaskey, lagergren --- nashorn/src/jdk/nashorn/internal/codegen/Attr.java | 7 +++---- .../jdk/nashorn/internal/codegen/CompilerConstants.java | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java index cf3e6946174..d0b5a00a77c 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java @@ -84,13 +84,12 @@ import jdk.nashorn.internal.ir.TryNode; import jdk.nashorn.internal.ir.UnaryNode; import jdk.nashorn.internal.ir.VarNode; import jdk.nashorn.internal.ir.WithNode; -import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor; +import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.TokenType; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.Debug; import jdk.nashorn.internal.runtime.DebugLogger; -import jdk.nashorn.internal.runtime.ECMAException; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.Property; import jdk.nashorn.internal.runtime.PropertyMap; @@ -1323,7 +1322,7 @@ final class Attr extends NodeOperatorVisitor { @Override public Node leaveForNode(final ForNode forNode) { if (forNode.isForIn()) { - forNode.setIterator(newInternal(lc.getCurrentFunction().uniqueName(ITERATOR_PREFIX.symbolName()), Type.OBJECT)); //NASHORN-73 + forNode.setIterator(newInternal(lc.getCurrentFunction().uniqueName(ITERATOR_PREFIX.symbolName()), Type.typeFor(ITERATOR_PREFIX.type()))); //NASHORN-73 /* * Iterators return objects, so we need to widen the scope of the * init variable if it, for example, has been assigned double type @@ -1500,7 +1499,7 @@ final class Attr extends NodeOperatorVisitor { } private Symbol exceptionSymbol() { - return newInternal(lc.getCurrentFunction().uniqueName(EXCEPTION_PREFIX.symbolName()), Type.typeFor(ECMAException.class)); + return newInternal(lc.getCurrentFunction().uniqueName(EXCEPTION_PREFIX.symbolName()), Type.typeFor(EXCEPTION_PREFIX.type())); } /** diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CompilerConstants.java b/nashorn/src/jdk/nashorn/internal/codegen/CompilerConstants.java index d9c68ad8288..3deff98c00a 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CompilerConstants.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CompilerConstants.java @@ -29,6 +29,7 @@ import static jdk.nashorn.internal.lookup.Lookup.MH; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; +import java.util.Iterator; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptObject; @@ -105,13 +106,13 @@ public enum CompilerConstants { ARGUMENTS("arguments", Object.class, 2), /** prefix for iterators for for (x in ...) */ - ITERATOR_PREFIX(":i"), + ITERATOR_PREFIX(":i", Iterator.class), /** prefix for tag variable used for switch evaluation */ SWITCH_TAG_PREFIX(":s"), /** prefix for all exceptions */ - EXCEPTION_PREFIX(":e"), + EXCEPTION_PREFIX(":e", Throwable.class), /** prefix for quick slots generated in Store */ QUICK_PREFIX(":q"), From 6d51346158d4d31934fb4851fee84e8042262d40 Mon Sep 17 00:00:00 2001 From: Joel Borggren-Franck Date: Fri, 31 May 2013 13:02:24 +0200 Subject: [PATCH 107/206] 8014709: Constructor.getAnnotatedReturnType() returns empty AnnotatedType Reviewed-by: stefank, rbackman --- hotspot/src/share/vm/runtime/reflection.cpp | 4 ++++ .../test/runtime/8007320/ConstMethodTest.java | 23 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/runtime/reflection.cpp b/hotspot/src/share/vm/runtime/reflection.cpp index 8d0cab2a441..5a9b4dd5b12 100644 --- a/hotspot/src/share/vm/runtime/reflection.cpp +++ b/hotspot/src/share/vm/runtime/reflection.cpp @@ -817,6 +817,10 @@ oop Reflection::new_constructor(methodHandle method, TRAPS) { typeArrayOop an_oop = Annotations::make_java_array(method->parameter_annotations(), CHECK_NULL); java_lang_reflect_Constructor::set_parameter_annotations(ch(), an_oop); } + if (java_lang_reflect_Constructor::has_type_annotations_field()) { + typeArrayOop an_oop = Annotations::make_java_array(method->type_annotations(), CHECK_NULL); + java_lang_reflect_Constructor::set_type_annotations(ch(), an_oop); + } return ch(); } diff --git a/hotspot/test/runtime/8007320/ConstMethodTest.java b/hotspot/test/runtime/8007320/ConstMethodTest.java index 68ca8dcb218..d24ff6df979 100644 --- a/hotspot/test/runtime/8007320/ConstMethodTest.java +++ b/hotspot/test/runtime/8007320/ConstMethodTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8007320 + * @bug 8007320 8014709 * @summary Test all optional fields in ConstMethod * @compile -g -parameters ConstMethodTest.java * @run main ConstMethodTest @@ -74,6 +74,11 @@ class OkException extends RuntimeException {}; @MyAnnotation(name="someName", value = "Hello World") public class ConstMethodTest { + public @TypeAnno("constructor") ConstMethodTest() { } + + public ConstMethodTest(int i) { + // needs a second unannotated constructor + } private static void check(boolean b) { if (!b) @@ -139,10 +144,26 @@ public class ConstMethodTest { } } + private static void testConstructor() throws Exception { + for (Constructor c : ConstMethodTest.class.getDeclaredConstructors()) { + Annotation[] aa = c.getAnnotatedReturnType().getAnnotations(); + if (c.getParameterTypes().length == 1) { // should be un-annotated + check(aa.length == 0); + } else if (c.getParameterTypes().length == 0) { //should be annotated + check(aa.length == 1); + check(((TypeAnno)aa[0]).value().equals("constructor")); + } else { + //should not happen + check(false); + } + } + } + public static void main(java.lang.String[] unused) throws Throwable { // pass 5 so kitchenSinkFunc is instantiated with an int kitchenSinkFunc("parameter", "param2", 5); test1(); + testConstructor(); } }; From 391e1eadefe1824f94a0396ce315920085ac8c5e Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Fri, 31 May 2013 15:56:07 +0400 Subject: [PATCH 108/206] 8015589: Test java/awt/Window/Grab/GrabTest.java fails on MacOSX Reviewed-by: anthony --- jdk/test/java/awt/Window/Grab/GrabTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/test/java/awt/Window/Grab/GrabTest.java b/jdk/test/java/awt/Window/Grab/GrabTest.java index ff447e1f0db..12f85fa5e8d 100644 --- a/jdk/test/java/awt/Window/Grab/GrabTest.java +++ b/jdk/test/java/awt/Window/Grab/GrabTest.java @@ -175,7 +175,7 @@ public class GrabTest { // 6. Check that press on the outside area causes ungrab Point loc = f.getLocationOnScreen(); - robot.mouseMove(loc.x + 100, loc.y + f.getSize().height + 1); + robot.mouseMove(loc.x + 100, loc.y + f.getSize().height + 10); Util.waitForIdle(robot); robot.mousePress(InputEvent.BUTTON1_MASK); robot.delay(50); From 9fcacb29a504a7480d0a3d9c7e75faec33fac992 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Fri, 31 May 2013 14:05:09 +0200 Subject: [PATCH 109/206] 7195481: FDS: debuginfo file for libjdwp.so is missed Reviewed-by: tbell --- jdk/make/jpda/back/Makefile | 2 ++ jdk/makefiles/CompileNativeLibraries.gmk | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/jdk/make/jpda/back/Makefile b/jdk/make/jpda/back/Makefile index 2095c4cf7dc..8c23009b76f 100644 --- a/jdk/make/jpda/back/Makefile +++ b/jdk/make/jpda/back/Makefile @@ -31,6 +31,8 @@ BUILDDIR = ../.. LIBRARY = jdwp PRODUCT = jpda +LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1 + FILES_m = mapfile-vers include $(BUILDDIR)/common/Defs.gmk diff --git a/jdk/makefiles/CompileNativeLibraries.gmk b/jdk/makefiles/CompileNativeLibraries.gmk index 1836cbb13f9..bf0a189e91d 100644 --- a/jdk/makefiles/CompileNativeLibraries.gmk +++ b/jdk/makefiles/CompileNativeLibraries.gmk @@ -1143,7 +1143,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJDWP,\ -D "JDK_INTERNAL_NAME=jdwp" \ -D "JDK_FTYPE=0x2L",\ OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjdwp,\ - DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES))) + DEBUG_SYMBOLS:=true)) $(BUILD_LIBJDWP) : $(BUILD_LIBJAVA) From 14c2e5664330a9cfedc6ca77bd9812d1df5e0153 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Fri, 31 May 2013 14:07:42 +0200 Subject: [PATCH 110/206] 8014003: New build does not handle symlinks in workspace path Reviewed-by: tbell --- common/autoconf/basics.m4 | 30 ++- common/autoconf/basics_windows.m4 | 2 +- common/autoconf/generated-configure.sh | 283 ++++++------------------- 3 files changed, 79 insertions(+), 236 deletions(-) diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index c4768b02acf..92c91e1bcfc 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -72,7 +72,7 @@ AC_DEFUN([BASIC_FIXUP_PATH], AC_MSG_ERROR([The path of $1, which resolves as "$path", is not found.]) fi - $1="`cd "$path"; $THEPWDCMD`" + $1="`cd "$path"; $THEPWDCMD -L`" fi ]) @@ -169,10 +169,10 @@ AC_DEFUN([BASIC_REMOVE_SYMBOLIC_LINKS], COUNTER=0 sym_link_dir=`$DIRNAME [$]$1` sym_link_file=`$BASENAME [$]$1` - # Use the system pwd and not the shell builtin to resolve directory symlinks cd $sym_link_dir - cd `$THEPWDCMD` - sym_link_dir=`$THEPWDCMD` + # Use -P flag to resolve symlinks in directories. + cd `$THEPWDCMD -P` + sym_link_dir=`$THEPWDCMD -P` # Resolve file symlinks while test $COUNTER -lt 20; do ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'` @@ -183,7 +183,7 @@ AC_DEFUN([BASIC_REMOVE_SYMBOLIC_LINKS], # Again resolve directory symlinks since the target of the just found # link could be in a different directory cd `$DIRNAME $ISLINK` - sym_link_dir=`$THEPWDCMD` + sym_link_dir=`$THEPWDCMD -P` sym_link_file=`$BASENAME $ISLINK` let COUNTER=COUNTER+1 done @@ -264,7 +264,6 @@ BASIC_REQUIRE_PROG(MKDIR, mkdir) BASIC_REQUIRE_PROG(MKTEMP, mktemp) BASIC_REQUIRE_PROG(MV, mv) BASIC_REQUIRE_PROG(PRINTF, printf) -BASIC_REQUIRE_PROG(THEPWDCMD, pwd) BASIC_REQUIRE_PROG(RM, rm) BASIC_REQUIRE_PROG(SH, sh) BASIC_REQUIRE_PROG(SORT, sort) @@ -297,6 +296,10 @@ BASIC_CHECK_NONEMPTY(NAWK) # Always force rm. RM="$RM -f" +# pwd behaves differently on various platforms and some don't support the -L flag. +# Always use the bash builtin pwd to get uniform behavior. +THEPWDCMD=pwd + # These are not required on all platforms AC_PATH_PROG(CYGPATH, cygpath) AC_PATH_PROG(READLINK, readlink) @@ -309,13 +312,12 @@ AC_DEFUN_ONCE([BASIC_SETUP_PATHS], [ # Locate the directory of this script. SCRIPT="[$]0" -BASIC_REMOVE_SYMBOLIC_LINKS(SCRIPT) -AUTOCONF_DIR=`cd \`$DIRNAME $SCRIPT\`; $THEPWDCMD` +AUTOCONF_DIR=`cd \`$DIRNAME $SCRIPT\`; $THEPWDCMD -L` # Where is the source? It is located two levels above the configure script. CURDIR="$PWD" cd "$AUTOCONF_DIR/../.." -SRC_ROOT="`$THEPWDCMD`" +SRC_ROOT="`$THEPWDCMD -L`" if test "x$OPENJDK_TARGET_OS" = "xwindows"; then PATH_SEP=";" @@ -374,13 +376,9 @@ AC_ARG_WITH(conf-name, [AS_HELP_STRING([--with-conf-name], [ CONF_NAME=${with_conf_name} ]) # Test from where we are running configure, in or outside of src root. -# To enable comparison of directories, CURDIR needs to be symlink free -# just like SRC_ROOT already is -NOSYM_CURDIR="$CURDIR" -BASIC_REMOVE_SYMBOLIC_LINKS(NOSYM_CURDIR) -if test "x$NOSYM_CURDIR" = "x$SRC_ROOT" || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common" \ - || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common/autoconf" \ - || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common/makefiles" ; then +if test "x$CURDIR" = "x$SRC_ROOT" || test "x$CURDIR" = "x$SRC_ROOT/common" \ + || test "x$CURDIR" = "x$SRC_ROOT/common/autoconf" \ + || test "x$CURDIR" = "x$SRC_ROOT/common/makefiles" ; then # We are running configure from the src root. # Create a default ./build/target-variant-debuglevel output root. if test "x${CONF_NAME}" = x; then diff --git a/common/autoconf/basics_windows.m4 b/common/autoconf/basics_windows.m4 index d0c48ae7c25..9ddb9e8c5c0 100644 --- a/common/autoconf/basics_windows.m4 +++ b/common/autoconf/basics_windows.m4 @@ -300,7 +300,7 @@ AC_DEFUN([BASIC_FIXUP_EXECUTABLE_MSYS], # Setup basic configuration paths, and platform-specific stuff related to PATHs. AC_DEFUN([BASIC_CHECK_PATHS_WINDOWS], [ - SRC_ROOT_LENGTH=`$THEPWDCMD|$WC -m` + SRC_ROOT_LENGTH=`$THEPWDCMD -L|$WC -m` if test $SRC_ROOT_LENGTH -gt 100; then AC_MSG_ERROR([Your base path is too long. It is $SRC_ROOT_LENGTH characters long, but only 100 is supported]) fi diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index f723c40f0a9..6922b152d76 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -901,7 +901,6 @@ TAIL SORT SH RM -THEPWDCMD PRINTF MV MKTEMP @@ -3781,7 +3780,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1369828849 +DATE_WHEN_GENERATED=1370001995 ############################################################################### # @@ -5170,65 +5169,6 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - for ac_prog in pwd -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_THEPWDCMD+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - case $THEPWDCMD in - [\\/]* | ?:[\\/]*) - ac_cv_path_THEPWDCMD="$THEPWDCMD" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_THEPWDCMD="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -THEPWDCMD=$ac_cv_path_THEPWDCMD -if test -n "$THEPWDCMD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THEPWDCMD" >&5 -$as_echo "$THEPWDCMD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$THEPWDCMD" && break -done - - - if test "x$THEPWDCMD" = x; then - if test "xpwd" = x; then - PROG_NAME=thepwdcmd - else - PROG_NAME=pwd - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 -$as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - as_fn_error $? "Cannot continue" "$LINENO" 5 - fi - - - for ac_prog in rm do # Extract the first word of "$ac_prog", so it can be a program name with args. @@ -6427,6 +6367,10 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} # Always force rm. RM="$RM -f" +# pwd behaves differently on various platforms and some don't support the -L flag. +# Always use the bash builtin pwd to get uniform behavior. +THEPWDCMD=pwd + # These are not required on all platforms # Extract the first word of "cygpath", so it can be a program name with args. set dummy cygpath; ac_word=$2 @@ -7134,65 +7078,17 @@ $as_echo "$COMPILE_TYPE" >&6; } # Locate the directory of this script. SCRIPT="$0" - - if test "x$OPENJDK_BUILD_OS" != xwindows; then - # Follow a chain of symbolic links. Use readlink - # where it exists, else fall back to horribly - # complicated shell code. - if test "x$READLINK_TESTED" != yes; then - # On MacOSX there is a readlink tool with a different - # purpose than the GNU readlink tool. Check the found readlink. - ISGNU=`$READLINK --version 2>&1 | $GREP GNU` - if test "x$ISGNU" = x; then - # A readlink that we do not know how to use. - # Are there other non-GNU readlinks out there? - READLINK_TESTED=yes - READLINK= - fi - fi - - if test "x$READLINK" != x; then - SCRIPT=`$READLINK -f $SCRIPT` - else - # Save the current directory for restoring afterwards - STARTDIR=$PWD - COUNTER=0 - sym_link_dir=`$DIRNAME $SCRIPT` - sym_link_file=`$BASENAME $SCRIPT` - # Use the system pwd and not the shell builtin to resolve directory symlinks - cd $sym_link_dir - cd `$THEPWDCMD` - sym_link_dir=`$THEPWDCMD` - # Resolve file symlinks - while test $COUNTER -lt 20; do - ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'` - if test "x$ISLINK" == x; then - # This is not a symbolic link! We are done! - break - fi - # Again resolve directory symlinks since the target of the just found - # link could be in a different directory - cd `$DIRNAME $ISLINK` - sym_link_dir=`$THEPWDCMD` - sym_link_file=`$BASENAME $ISLINK` - let COUNTER=COUNTER+1 - done - cd $STARTDIR - SCRIPT=$sym_link_dir/$sym_link_file - fi - fi - -AUTOCONF_DIR=`cd \`$DIRNAME $SCRIPT\`; $THEPWDCMD` +AUTOCONF_DIR=`cd \`$DIRNAME $SCRIPT\`; $THEPWDCMD -L` # Where is the source? It is located two levels above the configure script. CURDIR="$PWD" cd "$AUTOCONF_DIR/../.." -SRC_ROOT="`$THEPWDCMD`" +SRC_ROOT="`$THEPWDCMD -L`" if test "x$OPENJDK_TARGET_OS" = "xwindows"; then PATH_SEP=";" - SRC_ROOT_LENGTH=`$THEPWDCMD|$WC -m` + SRC_ROOT_LENGTH=`$THEPWDCMD -L|$WC -m` if test $SRC_ROOT_LENGTH -gt 100; then as_fn_error $? "Your base path is too long. It is $SRC_ROOT_LENGTH characters long, but only 100 is supported" "$LINENO" 5 fi @@ -7408,7 +7304,7 @@ $as_echo "$as_me: The path of SRC_ROOT, which resolves as \"$path\", is invalid. as_fn_error $? "The path of SRC_ROOT, which resolves as \"$path\", is not found." "$LINENO" 5 fi - SRC_ROOT="`cd "$path"; $THEPWDCMD`" + SRC_ROOT="`cd "$path"; $THEPWDCMD -L`" fi @@ -7530,7 +7426,7 @@ $as_echo "$as_me: The path of CURDIR, which resolves as \"$path\", is invalid." as_fn_error $? "The path of CURDIR, which resolves as \"$path\", is not found." "$LINENO" 5 fi - CURDIR="`cd "$path"; $THEPWDCMD`" + CURDIR="`cd "$path"; $THEPWDCMD -L`" fi @@ -7901,60 +7797,9 @@ fi # Test from where we are running configure, in or outside of src root. -# To enable comparison of directories, CURDIR needs to be symlink free -# just like SRC_ROOT already is -NOSYM_CURDIR="$CURDIR" - - if test "x$OPENJDK_BUILD_OS" != xwindows; then - # Follow a chain of symbolic links. Use readlink - # where it exists, else fall back to horribly - # complicated shell code. - if test "x$READLINK_TESTED" != yes; then - # On MacOSX there is a readlink tool with a different - # purpose than the GNU readlink tool. Check the found readlink. - ISGNU=`$READLINK --version 2>&1 | $GREP GNU` - if test "x$ISGNU" = x; then - # A readlink that we do not know how to use. - # Are there other non-GNU readlinks out there? - READLINK_TESTED=yes - READLINK= - fi - fi - - if test "x$READLINK" != x; then - NOSYM_CURDIR=`$READLINK -f $NOSYM_CURDIR` - else - # Save the current directory for restoring afterwards - STARTDIR=$PWD - COUNTER=0 - sym_link_dir=`$DIRNAME $NOSYM_CURDIR` - sym_link_file=`$BASENAME $NOSYM_CURDIR` - # Use the system pwd and not the shell builtin to resolve directory symlinks - cd $sym_link_dir - cd `$THEPWDCMD` - sym_link_dir=`$THEPWDCMD` - # Resolve file symlinks - while test $COUNTER -lt 20; do - ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'` - if test "x$ISLINK" == x; then - # This is not a symbolic link! We are done! - break - fi - # Again resolve directory symlinks since the target of the just found - # link could be in a different directory - cd `$DIRNAME $ISLINK` - sym_link_dir=`$THEPWDCMD` - sym_link_file=`$BASENAME $ISLINK` - let COUNTER=COUNTER+1 - done - cd $STARTDIR - NOSYM_CURDIR=$sym_link_dir/$sym_link_file - fi - fi - -if test "x$NOSYM_CURDIR" = "x$SRC_ROOT" || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common" \ - || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common/autoconf" \ - || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common/makefiles" ; then +if test "x$CURDIR" = "x$SRC_ROOT" || test "x$CURDIR" = "x$SRC_ROOT/common" \ + || test "x$CURDIR" = "x$SRC_ROOT/common/autoconf" \ + || test "x$CURDIR" = "x$SRC_ROOT/common/makefiles" ; then # We are running configure from the src root. # Create a default ./build/target-variant-debuglevel output root. if test "x${CONF_NAME}" = x; then @@ -8129,7 +7974,7 @@ $as_echo "$as_me: The path of OUTPUT_ROOT, which resolves as \"$path\", is inval as_fn_error $? "The path of OUTPUT_ROOT, which resolves as \"$path\", is not found." "$LINENO" 5 fi - OUTPUT_ROOT="`cd "$path"; $THEPWDCMD`" + OUTPUT_ROOT="`cd "$path"; $THEPWDCMD -L`" fi @@ -11245,7 +11090,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -11577,7 +11422,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -11723,7 +11568,7 @@ $as_echo "$as_me: The path of JAVA_HOME_PROCESSED, which resolves as \"$path\", as_fn_error $? "The path of JAVA_HOME_PROCESSED, which resolves as \"$path\", is not found." "$LINENO" 5 fi - JAVA_HOME_PROCESSED="`cd "$path"; $THEPWDCMD`" + JAVA_HOME_PROCESSED="`cd "$path"; $THEPWDCMD -L`" fi if test ! -d "$JAVA_HOME_PROCESSED"; then @@ -11895,7 +11740,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -12083,7 +11928,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -12222,10 +12067,10 @@ fi COUNTER=0 sym_link_dir=`$DIRNAME $BINARY` sym_link_file=`$BASENAME $BINARY` - # Use the system pwd and not the shell builtin to resolve directory symlinks cd $sym_link_dir - cd `$THEPWDCMD` - sym_link_dir=`$THEPWDCMD` + # Use -P flag to resolve symlinks in directories. + cd `$THEPWDCMD -P` + sym_link_dir=`$THEPWDCMD -P` # Resolve file symlinks while test $COUNTER -lt 20; do ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'` @@ -12236,7 +12081,7 @@ fi # Again resolve directory symlinks since the target of the just found # link could be in a different directory cd `$DIRNAME $ISLINK` - sym_link_dir=`$THEPWDCMD` + sym_link_dir=`$THEPWDCMD -P` sym_link_file=`$BASENAME $ISLINK` let COUNTER=COUNTER+1 done @@ -12411,7 +12256,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -12626,7 +12471,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -12806,7 +12651,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -13014,7 +12859,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -13194,7 +13039,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -13402,7 +13247,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -13582,7 +13427,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -13790,7 +13635,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -13970,7 +13815,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -14165,7 +14010,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -14343,7 +14188,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -14539,7 +14384,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -14717,7 +14562,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -14912,7 +14757,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -15090,7 +14935,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -15286,7 +15131,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -15464,7 +15309,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -15641,7 +15486,7 @@ $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid. as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi - BOOT_JDK="`cd "$path"; $THEPWDCMD`" + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 @@ -16445,7 +16290,7 @@ $as_echo "$as_me: The path of JT_HOME, which resolves as \"$path\", is invalid." as_fn_error $? "The path of JT_HOME, which resolves as \"$path\", is not found." "$LINENO" 5 fi - JT_HOME="`cd "$path"; $THEPWDCMD`" + JT_HOME="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JT_HOME" >&5 @@ -17434,7 +17279,7 @@ $as_echo "$as_me: The path of MSVCR_DLL, which resolves as \"$path\", is invalid as_fn_error $? "The path of MSVCR_DLL, which resolves as \"$path\", is not found." "$LINENO" 5 fi - MSVCR_DLL="`cd "$path"; $THEPWDCMD`" + MSVCR_DLL="`cd "$path"; $THEPWDCMD -L`" fi @@ -17591,7 +17436,7 @@ $as_echo "$as_me: The path of dxsdk_path, which resolves as \"$path\", is invali as_fn_error $? "The path of dxsdk_path, which resolves as \"$path\", is not found." "$LINENO" 5 fi - dxsdk_path="`cd "$path"; $THEPWDCMD`" + dxsdk_path="`cd "$path"; $THEPWDCMD -L`" fi @@ -17729,7 +17574,7 @@ $as_echo "$as_me: The path of DXSDK_LIB_PATH, which resolves as \"$path\", is in as_fn_error $? "The path of DXSDK_LIB_PATH, which resolves as \"$path\", is not found." "$LINENO" 5 fi - DXSDK_LIB_PATH="`cd "$path"; $THEPWDCMD`" + DXSDK_LIB_PATH="`cd "$path"; $THEPWDCMD -L`" fi @@ -17865,7 +17710,7 @@ $as_echo "$as_me: The path of DXSDK_INCLUDE_PATH, which resolves as \"$path\", i as_fn_error $? "The path of DXSDK_INCLUDE_PATH, which resolves as \"$path\", is not found." "$LINENO" 5 fi - DXSDK_INCLUDE_PATH="`cd "$path"; $THEPWDCMD`" + DXSDK_INCLUDE_PATH="`cd "$path"; $THEPWDCMD -L`" fi @@ -19452,10 +19297,10 @@ $as_echo_n "checking resolved symbolic links for CC... " >&6; } COUNTER=0 sym_link_dir=`$DIRNAME $TEST_COMPILER` sym_link_file=`$BASENAME $TEST_COMPILER` - # Use the system pwd and not the shell builtin to resolve directory symlinks cd $sym_link_dir - cd `$THEPWDCMD` - sym_link_dir=`$THEPWDCMD` + # Use -P flag to resolve symlinks in directories. + cd `$THEPWDCMD -P` + sym_link_dir=`$THEPWDCMD -P` # Resolve file symlinks while test $COUNTER -lt 20; do ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'` @@ -19466,7 +19311,7 @@ $as_echo_n "checking resolved symbolic links for CC... " >&6; } # Again resolve directory symlinks since the target of the just found # link could be in a different directory cd `$DIRNAME $ISLINK` - sym_link_dir=`$THEPWDCMD` + sym_link_dir=`$THEPWDCMD -P` sym_link_file=`$BASENAME $ISLINK` let COUNTER=COUNTER+1 done @@ -19889,10 +19734,10 @@ $as_echo_n "checking for resolved symbolic links for CC... " >&6; } COUNTER=0 sym_link_dir=`$DIRNAME $PROPER_COMPILER_CC` sym_link_file=`$BASENAME $PROPER_COMPILER_CC` - # Use the system pwd and not the shell builtin to resolve directory symlinks cd $sym_link_dir - cd `$THEPWDCMD` - sym_link_dir=`$THEPWDCMD` + # Use -P flag to resolve symlinks in directories. + cd `$THEPWDCMD -P` + sym_link_dir=`$THEPWDCMD -P` # Resolve file symlinks while test $COUNTER -lt 20; do ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'` @@ -19903,7 +19748,7 @@ $as_echo_n "checking for resolved symbolic links for CC... " >&6; } # Again resolve directory symlinks since the target of the just found # link could be in a different directory cd `$DIRNAME $ISLINK` - sym_link_dir=`$THEPWDCMD` + sym_link_dir=`$THEPWDCMD -P` sym_link_file=`$BASENAME $ISLINK` let COUNTER=COUNTER+1 done @@ -21025,10 +20870,10 @@ $as_echo_n "checking resolved symbolic links for CXX... " >&6; } COUNTER=0 sym_link_dir=`$DIRNAME $TEST_COMPILER` sym_link_file=`$BASENAME $TEST_COMPILER` - # Use the system pwd and not the shell builtin to resolve directory symlinks cd $sym_link_dir - cd `$THEPWDCMD` - sym_link_dir=`$THEPWDCMD` + # Use -P flag to resolve symlinks in directories. + cd `$THEPWDCMD -P` + sym_link_dir=`$THEPWDCMD -P` # Resolve file symlinks while test $COUNTER -lt 20; do ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'` @@ -21039,7 +20884,7 @@ $as_echo_n "checking resolved symbolic links for CXX... " >&6; } # Again resolve directory symlinks since the target of the just found # link could be in a different directory cd `$DIRNAME $ISLINK` - sym_link_dir=`$THEPWDCMD` + sym_link_dir=`$THEPWDCMD -P` sym_link_file=`$BASENAME $ISLINK` let COUNTER=COUNTER+1 done @@ -21462,10 +21307,10 @@ $as_echo_n "checking for resolved symbolic links for CXX... " >&6; } COUNTER=0 sym_link_dir=`$DIRNAME $PROPER_COMPILER_CXX` sym_link_file=`$BASENAME $PROPER_COMPILER_CXX` - # Use the system pwd and not the shell builtin to resolve directory symlinks cd $sym_link_dir - cd `$THEPWDCMD` - sym_link_dir=`$THEPWDCMD` + # Use -P flag to resolve symlinks in directories. + cd `$THEPWDCMD -P` + sym_link_dir=`$THEPWDCMD -P` # Resolve file symlinks while test $COUNTER -lt 20; do ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'` @@ -21476,7 +21321,7 @@ $as_echo_n "checking for resolved symbolic links for CXX... " >&6; } # Again resolve directory symlinks since the target of the just found # link could be in a different directory cd `$DIRNAME $ISLINK` - sym_link_dir=`$THEPWDCMD` + sym_link_dir=`$THEPWDCMD -P` sym_link_file=`$BASENAME $ISLINK` let COUNTER=COUNTER+1 done @@ -31188,7 +31033,7 @@ $as_echo "$as_me: The path of with_freetype, which resolves as \"$path\", is inv as_fn_error $? "The path of with_freetype, which resolves as \"$path\", is not found." "$LINENO" 5 fi - with_freetype="`cd "$path"; $THEPWDCMD`" + with_freetype="`cd "$path"; $THEPWDCMD -L`" fi FREETYPE2_LIBS="-L$with_freetype/lib -lfreetype" @@ -31490,7 +31335,7 @@ $as_echo "$as_me: The path of FREETYPELOCATION, which resolves as \"$path\", is as_fn_error $? "The path of FREETYPELOCATION, which resolves as \"$path\", is not found." "$LINENO" 5 fi - FREETYPELOCATION="`cd "$path"; $THEPWDCMD`" + FREETYPELOCATION="`cd "$path"; $THEPWDCMD -L`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype in some standard windows locations" >&5 From a48b38238f814ac9004ada1817e84e8ecc060013 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Fri, 31 May 2013 17:39:12 +0530 Subject: [PATCH 111/206] 8012164: Error.stack needs trimming Reviewed-by: lagergren, jlaskey --- .../nashorn/internal/objects/NativeError.java | 9 +++- nashorn/test/script/basic/JDK-8012164.js | 46 +++++++++++++++++++ .../test/script/basic/JDK-8012164.js.EXPECTED | 3 ++ .../test/script/basic/NASHORN-108.js.EXPECTED | 4 +- .../test/script/basic/NASHORN-109.js.EXPECTED | 2 +- .../test/script/basic/errorstack.js.EXPECTED | 2 +- 6 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8012164.js create mode 100644 nashorn/test/script/basic/JDK-8012164.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeError.java b/nashorn/src/jdk/nashorn/internal/objects/NativeError.java index 433f9317469..5473c8ef5c7 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeError.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeError.java @@ -32,6 +32,7 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.util.ArrayList; import java.util.List; +import jdk.nashorn.internal.codegen.CompilerConstants; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; import jdk.nashorn.internal.objects.annotations.Function; @@ -248,7 +249,13 @@ public final class NativeError extends ScriptObject { final List filtered = new ArrayList<>(); for (final StackTraceElement st : frames) { if (ECMAErrors.isScriptFrame(st)) { - filtered.add(st); + final String className = "<" + st.getFileName() + ">"; + String methodName = st.getMethodName(); + if (methodName.equals(CompilerConstants.RUN_SCRIPT.symbolName())) { + methodName = ""; + } + filtered.add(new StackTraceElement(className, methodName, + st.getFileName(), st.getLineNumber())); } } res = filtered.toArray(); diff --git a/nashorn/test/script/basic/JDK-8012164.js b/nashorn/test/script/basic/JDK-8012164.js new file mode 100644 index 00000000000..9134d1438dc --- /dev/null +++ b/nashorn/test/script/basic/JDK-8012164.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, 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. + */ + + +/** + * JDK-8012164: Error.stack needs trimming + * + * @test + * @run + */ + +function func() { + error(); +} + +function error() { + try { + throw new Error('foo'); + } catch (e) { + for (i in e.stack) { + print(e.stack[i]); + } + } +} + +func(); diff --git a/nashorn/test/script/basic/JDK-8012164.js.EXPECTED b/nashorn/test/script/basic/JDK-8012164.js.EXPECTED new file mode 100644 index 00000000000..e70edea3c8e --- /dev/null +++ b/nashorn/test/script/basic/JDK-8012164.js.EXPECTED @@ -0,0 +1,3 @@ +.error(test/script/basic/JDK-8012164.js:38) +.func(test/script/basic/JDK-8012164.js:33) +.(test/script/basic/JDK-8012164.js:46) diff --git a/nashorn/test/script/basic/NASHORN-108.js.EXPECTED b/nashorn/test/script/basic/NASHORN-108.js.EXPECTED index 59e90f646e0..066c8ff2ba6 100644 --- a/nashorn/test/script/basic/NASHORN-108.js.EXPECTED +++ b/nashorn/test/script/basic/NASHORN-108.js.EXPECTED @@ -1,3 +1,3 @@ -runScript 33 -runScript 32 + 33 + 32 done diff --git a/nashorn/test/script/basic/NASHORN-109.js.EXPECTED b/nashorn/test/script/basic/NASHORN-109.js.EXPECTED index fca137e214b..9de7b3224fe 100644 --- a/nashorn/test/script/basic/NASHORN-109.js.EXPECTED +++ b/nashorn/test/script/basic/NASHORN-109.js.EXPECTED @@ -1,2 +1,2 @@ -runScript 33 + 33 done diff --git a/nashorn/test/script/basic/errorstack.js.EXPECTED b/nashorn/test/script/basic/errorstack.js.EXPECTED index bb85d4e4efd..8ddae4dfe29 100644 --- a/nashorn/test/script/basic/errorstack.js.EXPECTED +++ b/nashorn/test/script/basic/errorstack.js.EXPECTED @@ -1,4 +1,4 @@ func3 : 40 func2 : 36 func1 : 32 -runScript : 44 + : 44 From d834509ee4408e38fb6557a4b7fda7dba8fade3b Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Fri, 31 May 2013 18:25:38 +0400 Subject: [PATCH 112/206] 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor Reviewed-by: alexsch --- .../share/classes/java/beans/XMLEncoder.java | 19 ++++- .../java/beans/XMLEncoder/Test6989223.java | 60 +++++++++++++ .../java/beans/XMLEncoder/Test7080156.java | 60 +++++++++++++ .../java/beans/XMLEncoder/Test8013557.java | 84 +++++++++++++++++++ 4 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/beans/XMLEncoder/Test6989223.java create mode 100644 jdk/test/java/beans/XMLEncoder/Test7080156.java create mode 100644 jdk/test/java/beans/XMLEncoder/Test8013557.java diff --git a/jdk/src/share/classes/java/beans/XMLEncoder.java b/jdk/src/share/classes/java/beans/XMLEncoder.java index dfccf7af11b..2ac3cdc30b2 100644 --- a/jdk/src/share/classes/java/beans/XMLEncoder.java +++ b/jdk/src/share/classes/java/beans/XMLEncoder.java @@ -487,6 +487,12 @@ public class XMLEncoder extends Encoder implements AutoCloseable { } indentation--; + Statement statement = getMissedStatement(); + while (statement != null) { + outputStatement(statement, this, false); + statement = getMissedStatement(); + } + try { out.flush(); } @@ -503,6 +509,17 @@ public class XMLEncoder extends Encoder implements AutoCloseable { targetToStatementList.clear(); } + Statement getMissedStatement() { + for (List statements : this.targetToStatementList.values()) { + for (int i = 0; i < statements.size(); i++) { + if (Statement.class == statements.get(i).getClass()) { + return statements.remove(i); + } + } + } + return null; + } + /** * This method calls flush, writes the closing @@ -597,7 +614,7 @@ public class XMLEncoder extends Encoder implements AutoCloseable { "methodName") + " should not be null"); } - if (target instanceof Field && methodName.equals("get")) { + if (isArgument && target instanceof Field && methodName.equals("get")) { Field f = (Field)target; writeln(""); diff --git a/jdk/test/java/beans/XMLEncoder/Test6989223.java b/jdk/test/java/beans/XMLEncoder/Test6989223.java new file mode 100644 index 00000000000..57730f1172b --- /dev/null +++ b/jdk/test/java/beans/XMLEncoder/Test6989223.java @@ -0,0 +1,60 @@ +/* + * 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 6989223 + * @summary Tests Rectangle2D.Double encoding + * @author Sergey Malenkov + */ + +import java.awt.geom.Rectangle2D; + +public class Test6989223 extends AbstractTest { + public static void main(String[] args) { + new Test6989223().test(true); + } + + protected Object getObject() { + return new Bean(1, 2, 3, 4); + } + + @Override + protected Object getAnotherObject() { + return new Bean(1, 2, 3, 5); + } + + public static class Bean extends Rectangle2D.Double { + public Bean() { + } + + public Bean(double x, double y, double w, double h) { + super(x, y, w, h); + } + + @Override + public boolean equals(Object object) { + return super.equals(object); // to avoid recursion during validation + } + } +} diff --git a/jdk/test/java/beans/XMLEncoder/Test7080156.java b/jdk/test/java/beans/XMLEncoder/Test7080156.java new file mode 100644 index 00000000000..4cbd6a091f1 --- /dev/null +++ b/jdk/test/java/beans/XMLEncoder/Test7080156.java @@ -0,0 +1,60 @@ +/* + * 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 7080156 7094245 + * @summary Tests beans with public arrays + * @author Sergey Malenkov + */ + +public class Test7080156 extends AbstractTest { + public static void main(String[] args) { + new Test7080156().test(true); + } + + protected Object getObject() { + Bean bean = new Bean(); + bean.setArray("something"); + return bean; + } + + @Override + protected Object getAnotherObject() { + Bean bean = new Bean(); + bean.setArray("some", "thing"); + return bean; + } + + public static class Bean { + public String[] array = {"default"}; + + public void setArray(String... array) { + this.array = array; + } + + public String[] getArray() { + return this.array; + } + } +} diff --git a/jdk/test/java/beans/XMLEncoder/Test8013557.java b/jdk/test/java/beans/XMLEncoder/Test8013557.java new file mode 100644 index 00000000000..75036f80ded --- /dev/null +++ b/jdk/test/java/beans/XMLEncoder/Test8013557.java @@ -0,0 +1,84 @@ +/* + * 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 8013557 + * @summary Tests beans with public fields + * @author Sergey Malenkov + */ + +public class Test8013557 extends AbstractTest { + public static void main(String[] args) { + new Test8013557().test(true); + } + + protected Object getObject() { + return new Bean(new Value("something")); + } + + @Override + protected Object getAnotherObject() { + return new Bean(new Value()); + } + + public static class Bean { + public Value value; + + public Bean() { + this.value = new Value(); + } + + public Bean(Value value) { + this.value = value; + } + + public void setValue(Value value) { + this.value = value; + } + + public Value getValue() { + return this.value; + } + } + + public static class Value { + private String string; + + public Value() { + this.string = "default"; + } + + public Value(String value) { + this.string = value; + } + + public void setString(String string) { + this.string = string; + } + + public String getString() { + return this.string; + } + } +} From 9c64c6f45b85e1c09406d6203803950b98dbbf33 Mon Sep 17 00:00:00 2001 From: Vladislav Karnaukhov Date: Fri, 31 May 2013 18:46:41 +0400 Subject: [PATCH 113/206] 7068740: If you wrap a JTable in a JLayer you can't use the page up and page down cmds Reviewed-by: alexsch, alexp --- .../javax/swing/plaf/basic/BasicTableUI.java | 6 +- .../swing/JTable/7068740/bug7068740.java | 134 ++++++++++++++++++ 2 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 jdk/test/javax/swing/JTable/7068740/bug7068740.java diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java index ad8a34d1e17..f9f9c728ed1 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -419,7 +419,7 @@ public class BasicTableUI extends TableUI } } else { - if (!(table.getParent().getParent() instanceof + if (!(SwingUtilities.getUnwrappedParent(table).getParent() instanceof JScrollPane)) { return; } @@ -1431,7 +1431,7 @@ public class BasicTableUI extends TableUI } // install the scrollpane border - Container parent = table.getParent(); // should be viewport + Container parent = SwingUtilities.getUnwrappedParent(table); // should be viewport if (parent != null) { parent = parent.getParent(); // should be the scrollpane if (parent != null && parent instanceof JScrollPane) { diff --git a/jdk/test/javax/swing/JTable/7068740/bug7068740.java b/jdk/test/javax/swing/JTable/7068740/bug7068740.java new file mode 100644 index 00000000000..7073779f6e6 --- /dev/null +++ b/jdk/test/javax/swing/JTable/7068740/bug7068740.java @@ -0,0 +1,134 @@ +/* + * 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 7068740 + @summary JTable wrapped in JLayer can't use PGUP/PGDOWN keys + @author Vladislav Karnaukhov + @run main bug7068740 +*/ + +import sun.awt.SunToolkit; + +import javax.swing.*; +import javax.swing.plaf.LayerUI; +import javax.swing.plaf.metal.MetalLookAndFeel; +import javax.swing.table.DefaultTableModel; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.lang.reflect.InvocationTargetException; + +public class bug7068740 extends JFrame { + + private static Robot robot = null; + private static JTable table = null; + private static SunToolkit toolkit = null; + + bug7068740() { + super(); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + DefaultTableModel model = new DefaultTableModel() { + @Override + public int getRowCount() { + return 20; + } + + @Override + public int getColumnCount() { + return 2; + } + + @Override + public Object getValueAt(int row, int column) { + return "(" + row + "," + column + ")"; + } + }; + + table = new JTable(model); + LayerUI layerUI = new LayerUI<>(); + JLayer layer = new JLayer<>(table, layerUI); + JScrollPane scrollPane = new JScrollPane(layer); + add(scrollPane); + pack(); + setLocationRelativeTo(null); + } + + private static void setUp() { + try { + if (robot == null) { + robot = new Robot(); + robot.setAutoDelay(20); + } + + if (toolkit == null) { + toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + } + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + bug7068740 test = new bug7068740(); + test.setVisible(true); + } + }); + } catch (InterruptedException e) { + e.printStackTrace(); + throw new RuntimeException("Test failed"); + } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new RuntimeException("Test failed"); + } catch (AWTException e) { + e.printStackTrace(); + throw new RuntimeException("Test failed"); + } + } + + private static void doTest() { + toolkit.realSync(); + table.setRowSelectionInterval(0, 0); + + robot.keyPress(KeyEvent.VK_PAGE_DOWN); + toolkit.realSync(); + if (table.getSelectedRow() != 19) { + throw new RuntimeException("Test failed"); + } + + robot.keyPress(KeyEvent.VK_PAGE_UP); + toolkit.realSync(); + if (table.getSelectedRow() != 0) { + throw new RuntimeException("Test failed"); + } + } + + public static void main(String[] args) { + try { + UIManager.setLookAndFeel(new MetalLookAndFeel()); + setUp(); + doTest(); + } catch (UnsupportedLookAndFeelException e) { + e.printStackTrace(); + throw new RuntimeException("Test failed"); + } + } +} From a754c039beec6142b56aec405d497a7be0c15df2 Mon Sep 17 00:00:00 2001 From: Vladislav Karnaukhov Date: Fri, 31 May 2013 19:34:02 +0400 Subject: [PATCH 114/206] 6436314: Vector could be created with appropriate size in DefaultComboBoxModel Reviewed-by: alexsch, alexp --- jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java b/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java index f0266fc7351..6e35b6156f0 100644 --- a/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java +++ b/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -55,8 +55,7 @@ public class DefaultComboBoxModel extends AbstractListModel implements Mut * @param items an array of Object objects */ public DefaultComboBoxModel(final E items[]) { - objects = new Vector(); - objects.ensureCapacity( items.length ); + objects = new Vector(items.length); int i,c; for ( i=0,c=items.length;i Date: Fri, 31 May 2013 13:04:55 -0300 Subject: [PATCH 115/206] 8015727: Thread safe print function Reviewed-by: sundar --- .../src/jdk/nashorn/internal/objects/Global.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk/nashorn/internal/objects/Global.java index e079248b577..cdd0085f751 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/Global.java +++ b/nashorn/src/jdk/nashorn/internal/objects/Global.java @@ -1628,20 +1628,21 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { @SuppressWarnings("resource") private static Object printImpl(final boolean newLine, final Object... objects) { final PrintWriter out = Global.getEnv().getOut(); + final StringBuilder sb = new StringBuilder(); - boolean first = true; for (final Object object : objects) { - if (first) { - first = false; - } else { - out.print(' '); + if (sb.length() != 0) { + sb.append(' '); } - out.print(JSType.toString(object)); + sb.append(JSType.toString(object)); } + // Print all at once to ensure thread friendly result. if (newLine) { - out.println(); + out.println(sb.toString()); + } else { + out.print(sb.toString()); } out.flush(); From 2cbcc2b315da6cd4d2d1fb70f6a547ca2b68cdc7 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Fri, 31 May 2013 09:25:37 -0700 Subject: [PATCH 116/206] 8015556: [macosx] surrogate pairs do not render properly Reviewed-by: bae, jchen --- .../classes/sun/font/CCharToGlyphMapper.java | 148 ++++++++++-------- .../FontClass/SurrogateTest/SuppCharTest.java | 127 +++++++++++++++ 2 files changed, 208 insertions(+), 67 deletions(-) create mode 100644 jdk/test/java/awt/FontClass/SurrogateTest/SuppCharTest.java diff --git a/jdk/src/macosx/classes/sun/font/CCharToGlyphMapper.java b/jdk/src/macosx/classes/sun/font/CCharToGlyphMapper.java index 70fad4df379..bcad3c08d5c 100644 --- a/jdk/src/macosx/classes/sun/font/CCharToGlyphMapper.java +++ b/jdk/src/macosx/classes/sun/font/CCharToGlyphMapper.java @@ -130,7 +130,17 @@ public class CCharToGlyphMapper extends CharToGlyphMapper { } public synchronized int charToGlyph(int unicode) { - return charToGlyph((char)unicode); + if (unicode >= 0x10000) { + int[] glyphs = new int[2]; + char[] surrogates = new char[2]; + int base = unicode - 0x10000; + surrogates[0] = (char)((base >>> 10) + HI_SURROGATE_START); + surrogates[1] = (char)((base % 0x400) + LO_SURROGATE_START); + charsToGlyphs(2, surrogates, glyphs); + return glyphs[0]; + } else { + return charToGlyph((char)unicode); + } } public synchronized void charsToGlyphs(int count, char[] unicodes, int[] glyphs) { @@ -138,9 +148,9 @@ public class CCharToGlyphMapper extends CharToGlyphMapper { } public synchronized void charsToGlyphs(int count, int[] unicodes, int[] glyphs) { - final char[] unicodeChars = new char[count]; - for (int i = 0; i < count; i++) unicodeChars[i] = (char)unicodes[i]; - cache.get(count, unicodeChars, glyphs); + for (int i = 0; i < count; i++) { + glyphs[i] = charToGlyph(unicodes[i]); + }; } // This mapper returns either the glyph code, or if the character can be @@ -166,7 +176,7 @@ public class CCharToGlyphMapper extends CharToGlyphMapper { firstLayerCache[1] = 1; } - public int get(final char index) { + public synchronized int get(final int index) { if (index < FIRST_LAYER_SIZE) { // catch common glyphcodes return firstLayerCache[index]; @@ -179,12 +189,12 @@ public class CCharToGlyphMapper extends CharToGlyphMapper { } if (generalCache == null) return 0; - final Integer value = generalCache.get(new Integer(index)); + final Integer value = generalCache.get(index); if (value == null) return 0; return value.intValue(); } - public void put(final char index, final int value) { + public synchronized void put(final int index, final int value) { if (index < FIRST_LAYER_SIZE) { // catch common glyphcodes firstLayerCache[index] = value; @@ -204,7 +214,7 @@ public class CCharToGlyphMapper extends CharToGlyphMapper { generalCache = new HashMap(); } - generalCache.put(new Integer(index), new Integer(value)); + generalCache.put(index, value); } private class SparseBitShiftingTwoLayerArray { @@ -220,14 +230,14 @@ public class CCharToGlyphMapper extends CharToGlyphMapper { this.secondLayerLength = size >> shift; } - public int get(final char index) { + public int get(final int index) { final int firstIndex = index >> shift; final int[] firstLayerRow = cache[firstIndex]; if (firstLayerRow == null) return 0; return firstLayerRow[index - (firstIndex * (1 << shift))]; } - public void put(final char index, final int value) { + public void put(final int index, final int value) { final int firstIndex = index >> shift; int[] firstLayerRow = cache[firstIndex]; if (firstLayerRow == null) { @@ -237,77 +247,81 @@ public class CCharToGlyphMapper extends CharToGlyphMapper { } } - public void get(int count, char[] indicies, int[] values){ + public synchronized void get(int count, char[] indicies, int[] values) + { + // "missed" is the count of 'char' that are not mapped. + // Surrogates count for 2. + // unmappedChars is the unique list of these chars. + // unmappedCharIndices is the location in the original array int missed = 0; - for(int i = 0; i < count; i++){ - char code = indicies[i]; + char[] unmappedChars = null; + int [] unmappedCharIndices = null; + + for (int i = 0; i < count; i++){ + int code = indicies[i]; + if (code >= HI_SURROGATE_START && + code <= HI_SURROGATE_END && i < count - 1) + { + char low = indicies[i + 1]; + if (low >= LO_SURROGATE_START && low <= LO_SURROGATE_END) { + code = (code - HI_SURROGATE_START) * 0x400 + + low - LO_SURROGATE_START + 0x10000; + } + } final int value = get(code); - if(value != 0){ + if (value != 0 && value != -1) { values[i] = value; - }else{ - // zero this element out, because the caller does not - // promise to keep it clean + if (code >= 0x10000) { + values[i+1] = INVISIBLE_GLYPH_ID; + i++; + } + } else { values[i] = 0; + put(code, -1); + if (unmappedChars == null) { + // This is likely to be longer than we need, + // but is the simplest and cheapest option. + unmappedChars = new char[indicies.length]; + unmappedCharIndices = new int[indicies.length]; + } + unmappedChars[missed] = indicies[i]; + unmappedCharIndices[missed] = i; + if (code >= 0x10000) { // was a surrogate pair + unmappedChars[++missed] = indicies[++i]; + } missed++; } } - if (missed == 0) return; // horray! everything is already cached! - - final char[] filteredCodes = new char[missed]; // all index codes requested (partially filled) - final int[] filteredIndicies = new int[missed]; // local indicies into filteredCodes array (totally filled) - - // scan, mark, and store the index codes again to send into native - int j = 0; - int dupes = 0; - for (int i = 0; i < count; i++){ - if (values[i] != 0L) continue; // already filled - - final char code = indicies[i]; - - // we have already promised to fill this code - this is a dupe - if (get(code) == -1){ - filteredIndicies[j] = -1; - dupes++; - j++; - continue; - } - - // this is a code we have not obtained before - // mark this one as "promise to get" in the global cache with a -1 - final int k = j - dupes; - filteredCodes[k] = code; - put(code, -1); - filteredIndicies[j] = k; - j++; + if (missed == 0) { + return; } - final int filteredRunLen = j - dupes; - final int[] filteredValues = new int[filteredRunLen]; + final int[] glyphCodes = new int[missed]; - // bulk call to fill in the distinct values - nativeCharsToGlyphs(fFont.getNativeFontPtr(), filteredRunLen, filteredCodes, filteredValues); + // bulk call to fill in the unmapped code points. + nativeCharsToGlyphs(fFont.getNativeFontPtr(), + missed, unmappedChars, glyphCodes); - // scan the requested list, and fill in values from our - // distinct code list which has been filled from "getDistinct" - j = 0; - for (int i = 0; i < count; i++){ - if (values[i] != 0L && values[i] != -1L) continue; // already placed - - final int k = filteredIndicies[j]; // index into filteredImages array - final char code = indicies[i]; - if(k == -1L){ - // we should have already filled the cache with this value - values[i] = get(code); - }else{ - // fill the particular code request, and store in the cache - final int ptr = filteredValues[k]; - values[i] = ptr; - put(code, ptr); + for (int m = 0; m < missed; m++){ + int i = unmappedCharIndices[m]; + int code = unmappedChars[m]; + if (code >= HI_SURROGATE_START && + code <= HI_SURROGATE_END && m < missed - 1) + { + char low = indicies[m + 1]; + if (low >= LO_SURROGATE_START && low <= LO_SURROGATE_END) { + code = (code - HI_SURROGATE_START) * 0x400 + + low - LO_SURROGATE_START + 0x10000; + } + } + values[i] = glyphCodes[m]; + put(code, values[i]); + if (code >= 0x10000) { + m++; + values[i + 1] = INVISIBLE_GLYPH_ID; } - - j++; } } } diff --git a/jdk/test/java/awt/FontClass/SurrogateTest/SuppCharTest.java b/jdk/test/java/awt/FontClass/SurrogateTest/SuppCharTest.java new file mode 100644 index 00000000000..1011b741bba --- /dev/null +++ b/jdk/test/java/awt/FontClass/SurrogateTest/SuppCharTest.java @@ -0,0 +1,127 @@ +/* + * 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 8015556 + * @summary Surrogate pairs do not render properly on MacOS X. + */ + +import java.util.Locale; +import java.awt.*; +import java.awt.font.*; +import javax.swing.*; + +public class SuppCharTest { + + static String str = "ABC\uD840\uDC01\uD840\uDC00AB"; + static String EXTB_FONT = "MingLiU-ExtB"; + + public static void main(String args[]) throws Exception { + + final Font font = new Font(EXTB_FONT, Font.PLAIN, 36); + if (!EXTB_FONT.equalsIgnoreCase(font.getFamily(Locale.ENGLISH))) { + return; + } + + SwingUtilities.invokeLater(new Runnable(){ + @Override + public void run(){ + JFrame f = new JFrame("Test Supplementary Char Support"); + Component c = new SuppCharComp(font, str); + f.add("Center", c); + JButton b = new JButton(str); + b.setFont(font); + f.add("South", b); + f.pack(); + f.setVisible(true); + } + }); + + /* If a supplementary character was found, 'invisible glyphs' + * with value 65535 will be inserted in the place of the 2nd (low) + * char index. So we are looking here to make sure such substitutions + * took place. + */ + FontRenderContext frc = new FontRenderContext(null, false, false); + GlyphVector gv = font.createGlyphVector(frc, str); + int numGlyphs = gv.getNumGlyphs(); + int[] codes = gv.getGlyphCodes(0, numGlyphs, null); + boolean foundInvisibleGlyph = false; + for (int i=0; i Date: Fri, 31 May 2013 09:37:49 -0700 Subject: [PATCH 117/206] Added tag hs25-b35 for changeset 02ffee063e24 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 8fd9b705d0f..d1ed8dd2df0 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -346,3 +346,4 @@ b19517cecc2e91636d7c16ba2f35e3d3dc628099 hs25-b33 7cbdf0e3725c0c56a2ff7540fc70b6d4b5890d04 jdk8-b91 38da9f4f67096745f851318d792d6468aa1f6cf8 hs25-b34 092018493d3bbeb1c24278fd8c40ff3d76e1fed7 jdk8-b92 +b786c04b7be15194febe88dc1f0c9443e737a84b hs25-b35 From f488447accda3119f613ea7bf85082a83f21278d Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Fri, 31 May 2013 10:04:00 -0700 Subject: [PATCH 118/206] 8015690: new hotspot build - hs25-b36 Reviewed-by: jcoomes --- hotspot/make/hotspot_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/make/hotspot_version b/hotspot/make/hotspot_version index 815215f44ec..c88d7286682 100644 --- a/hotspot/make/hotspot_version +++ b/hotspot/make/hotspot_version @@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2013 HS_MAJOR_VER=25 HS_MINOR_VER=0 -HS_BUILD_NUMBER=35 +HS_BUILD_NUMBER=36 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 From 6a7e90e3620a78638d194f4af99a10bbaeb7c1c9 Mon Sep 17 00:00:00 2001 From: Mikhailo Seledtsov Date: Fri, 31 May 2013 20:24:58 +0200 Subject: [PATCH 119/206] 6726963: multi_allocate() call does not CHECK_NULL and causes crash in fastdebug bits Using CHECK_NULL when calling multi_allocate() from the corresponding reflection code; added test for this condition Reviewed-by: dholmes, minqi --- hotspot/src/share/vm/runtime/reflection.cpp | 4 +- .../memory/MultiAllocateNullCheck.java | 45 +++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 hotspot/test/runtime/memory/MultiAllocateNullCheck.java diff --git a/hotspot/src/share/vm/runtime/reflection.cpp b/hotspot/src/share/vm/runtime/reflection.cpp index 5a9b4dd5b12..27e2048efb5 100644 --- a/hotspot/src/share/vm/runtime/reflection.cpp +++ b/hotspot/src/share/vm/runtime/reflection.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -375,7 +375,7 @@ arrayOop Reflection::reflect_new_multi_array(oop element_mirror, typeArrayOop di } } klass = klass->array_klass(dim, CHECK_NULL); - oop obj = ArrayKlass::cast(klass)->multi_allocate(len, dimensions, THREAD); + oop obj = ArrayKlass::cast(klass)->multi_allocate(len, dimensions, CHECK_NULL); assert(obj->is_array(), "just checking"); return arrayOop(obj); } diff --git a/hotspot/test/runtime/memory/MultiAllocateNullCheck.java b/hotspot/test/runtime/memory/MultiAllocateNullCheck.java new file mode 100644 index 00000000000..cc9dac3cdb6 --- /dev/null +++ b/hotspot/test/runtime/memory/MultiAllocateNullCheck.java @@ -0,0 +1,45 @@ +/* + * 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 MultiAllocateNullCheck + * @bug 6726963 + * @summary multi_allocate() call does not CHECK_NULL and causes crash in fastdebug bits + * @run main/othervm -Xmx32m MultiAllocateNullCheck + */ + +import java.lang.reflect.Array; + +public class MultiAllocateNullCheck { + public static void main(String[] args) throws Exception { + Object x = null; + try + { + x = Array.newInstance(String.class, new int[] + {Integer.MAX_VALUE, Integer.MAX_VALUE}); + System.out.println("Array was created"); + } catch (OutOfMemoryError e) { + System.out.println("Out of memory occured, which is OK in this case"); + } + } +} From 0ace868fe4f0bd5ab2a13069b1a5ca8dcbfc4130 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Sat, 1 Jun 2013 21:57:56 +0100 Subject: [PATCH 120/206] 8010737: javac, known parameter's names should be copied to automatically generated constructors for inner classes Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/MemberEnter.java | 78 ++++-- .../MethodParameters/ClassFileVisitor.java | 3 - .../MethodParameters/ReflectionVisitor.java | 3 - ...rNamesAreNotCopiedToAnonymousInitTest.java | 239 ++++++++++++++++++ 4 files changed, 302 insertions(+), 21 deletions(-) create mode 100644 langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java index 74e3d97bd42..62c3fa02e6c 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java @@ -996,8 +996,9 @@ public class MemberEnter extends JCTree.Visitor implements Completer { long ctorFlags = 0; boolean based = false; boolean addConstructor = true; + JCNewClass nc = null; if (c.name.isEmpty()) { - JCNewClass nc = (JCNewClass)env.next.tree; + nc = (JCNewClass)env.next.tree; if (nc.constructor != null) { addConstructor = nc.constructor.kind != ERR; Type superConstrType = types.memberType(c.type, @@ -1013,7 +1014,10 @@ public class MemberEnter extends JCTree.Visitor implements Completer { } } if (addConstructor) { + MethodSymbol basedConstructor = nc != null ? + (MethodSymbol)nc.constructor : null; JCTree constrDef = DefaultConstructor(make.at(tree.pos), c, + basedConstructor, typarams, argtypes, thrown, ctorFlags, based); tree.defs = tree.defs.prepend(constrDef); @@ -1399,34 +1403,78 @@ public class MemberEnter extends JCTree.Visitor implements Completer { */ JCTree DefaultConstructor(TreeMaker make, ClassSymbol c, + MethodSymbol baseInit, List typarams, List argtypes, List thrown, long flags, boolean based) { - List params = make.Params(argtypes, syms.noSymbol); - List stats = List.nil(); - if (c.type != syms.objectType) - stats = stats.prepend(SuperCall(make, typarams, params, based)); + JCTree result; if ((c.flags() & ENUM) != 0 && (types.supertype(c.type).tsym == syms.enumSym)) { // constructors of true enums are private flags = (flags & ~AccessFlags) | PRIVATE | GENERATEDCONSTR; } else flags |= (c.flags() & AccessFlags) | GENERATEDCONSTR; - if (c.name.isEmpty()) flags |= ANONCONSTR; - JCTree result = make.MethodDef( - make.Modifiers(flags), - names.init, - null, - make.TypeParams(typarams), - params, - make.Types(thrown), - make.Block(0, stats), - null); + if (c.name.isEmpty()) { + flags |= ANONCONSTR; + } + Type mType = new MethodType(argtypes, null, thrown, c); + Type initType = typarams.nonEmpty() ? + new ForAll(typarams, mType) : + mType; + MethodSymbol init = new MethodSymbol(flags, names.init, + initType, c); + init.params = createDefaultConstructorParams(make, baseInit, init, + argtypes, based); + List params = make.Params(argtypes, init); + List stats = List.nil(); + if (c.type != syms.objectType) { + stats = stats.prepend(SuperCall(make, typarams, params, based)); + } + result = make.MethodDef(init, make.Block(0, stats)); return result; } + private List createDefaultConstructorParams( + TreeMaker make, + MethodSymbol baseInit, + MethodSymbol init, + List argtypes, + boolean based) { + List initParams = null; + List argTypesList = argtypes; + if (based) { + /* In this case argtypes will have an extra type, compared to baseInit, + * corresponding to the type of the enclosing instance i.e.: + * + * Inner i = outer.new Inner(1){} + * + * in the above example argtypes will be (Outer, int) and baseInit + * will have parameter's types (int). So in this case we have to add + * first the extra type in argtypes and then get the names of the + * parameters from baseInit. + */ + initParams = List.nil(); + VarSymbol param = new VarSymbol(0, make.paramName(0), argtypes.head, init); + initParams = initParams.append(param); + argTypesList = argTypesList.tail; + } + if (baseInit != null && baseInit.params != null && + baseInit.params.nonEmpty() && argTypesList.nonEmpty()) { + initParams = (initParams == null) ? List.nil() : initParams; + List baseInitParams = baseInit.params; + while (baseInitParams.nonEmpty() && argTypesList.nonEmpty()) { + VarSymbol param = new VarSymbol(baseInitParams.head.flags(), + baseInitParams.head.name, argTypesList.head, init); + initParams = initParams.append(param); + baseInitParams = baseInitParams.tail; + argTypesList = argTypesList.tail; + } + } + return initParams; + } + /** Generate call to superclass constructor. This is: * * super(id_0, ..., id_n) diff --git a/langtools/test/tools/javac/MethodParameters/ClassFileVisitor.java b/langtools/test/tools/javac/MethodParameters/ClassFileVisitor.java index 44daed1fc15..c5d1d93ccc9 100644 --- a/langtools/test/tools/javac/MethodParameters/ClassFileVisitor.java +++ b/langtools/test/tools/javac/MethodParameters/ClassFileVisitor.java @@ -316,9 +316,6 @@ class ClassFileVisitor extends Tester.Visitor { } expect = "this\\$[0-n]*"; } - } else if (isAnon) { - // not an implementation gurantee, but okay for now - expect = "x[0-n]*"; } } else if (isEnum && mNumParams == 1 && index == 0 && mName.equals("valueOf")) { expect = "name"; diff --git a/langtools/test/tools/javac/MethodParameters/ReflectionVisitor.java b/langtools/test/tools/javac/MethodParameters/ReflectionVisitor.java index e1b1a32c0b5..a7129ba98e7 100644 --- a/langtools/test/tools/javac/MethodParameters/ReflectionVisitor.java +++ b/langtools/test/tools/javac/MethodParameters/ReflectionVisitor.java @@ -151,9 +151,6 @@ public class ReflectionVisitor extends Tester.Visitor { } expect = "this\\$[0-n]*"; } - } else if (isAnon) { - // not an implementation gurantee, but okay for now - expect = "x[0-n]*"; } // Check expected flags diff --git a/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java b/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java new file mode 100644 index 00000000000..f58d186ffb1 --- /dev/null +++ b/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java @@ -0,0 +1,239 @@ +/* + * 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 8010737 + * @summary javac, known parameter's names should be copied to automatically + * generated constructors for inner classes + * @run main ParameterNamesAreNotCopiedToAnonymousInitTest check_class_file check_init_symbol + */ + +import java.io.File; +import java.io.IOException; +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.nio.file.Paths; +import java.util.Arrays; + +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.Tree; +import com.sun.source.util.JavacTask; +import com.sun.source.util.TaskEvent; +import com.sun.source.util.TaskListener; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.Method; +import com.sun.tools.javac.api.BasicJavacTask; +import com.sun.tools.javac.code.Attribute.Compound; +import com.sun.tools.javac.code.Symbol.ClassSymbol; +import com.sun.tools.javac.code.Symbol.VarSymbol; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.TreeScanner; +import com.sun.tools.javac.util.Assert; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.Names; + +public class ParameterNamesAreNotCopiedToAnonymousInitTest { + + static final String noParamsErrorMsg = + "Test most be invoked with at least one parameter: check_class_file " + + "and/or check_init_symbol"; + static final String wrongParamsErrorMsg = + "Accepted arguments are: check_class_file and check_init_symbol"; + static final String paramNameNotCopiedAssertionMsg = + "The param name hasn't been copied to the init method"; + static final String noAnnotationsForParameterMsg = + "No annotations for seek parameter"; + static final String seekMethodNotFound = + "The seek init method was not found or conditions were not met"; + static final String nonNullParamPositionsMsg = + "Parameter positions shold not be null"; + static final String compilationFailed = + "Compilation failed"; + static final String seekMethodNotFoundMsg = + "The seek method was not found"; + + static final String ParamAnnotationClassName = + ParameterNamesAreNotCopiedToAnonymousInitTest.class.getSimpleName() + "." + + ParamAnnotation.class.getSimpleName(); + + public static void main(String[] args) throws Exception { + if (args.length == 0) { + throw new Error(noParamsErrorMsg); + } + new ParameterNamesAreNotCopiedToAnonymousInitTest().run(args); + } + + void run(String[] args) throws Exception { + for (String arg : args) { + if (arg.equals("check_class_file")) { + checkClassFile(new File(Paths.get(System.getProperty("test.classes"), + this.getClass().getName() + "$initParams$1.class").toUri()), 1); + checkClassFile(new File(Paths.get(System.getProperty("test.classes"), + this.getClass().getName() + "$Generics$1.class").toUri()), 2); + } else if (arg.equals("check_init_symbol")) { + checkInitSymbol("m1", Arrays.asList(0), Arrays.asList("i")); + checkInitSymbol("m2", Arrays.asList(0, 1), Arrays.asList("t1", "t2")); + } else { + error(wrongParamsErrorMsg); + } + } + } + + void checkClassFile(final File cfile, int numberOfParams) throws Exception { + ClassFile classFile = ClassFile.read(cfile); + boolean methodFound = false; + for (Method method : classFile.methods) { + if (method.getName(classFile.constant_pool).equals("")) { + methodFound = true; + } + } + Assert.check(methodFound, seekMethodNotFoundMsg); + } + + /* This method expect a non-null ordered list of integers, listing the + * position of the parameters to be checked on the init method. Position 0 + * corresponds to the first parameter. + * + * As we are looking for a constructor of an anonymous class, the + * classOwnerName parameter must be the name of the method where the + * anonymous class is declared. + */ + void checkInitSymbol( + final String classOwnerName, + final java.util.List paramsToCheck, + final java.util.List paramNames) + throws IOException { + Assert.checkNonNull(paramsToCheck, nonNullParamPositionsMsg); + JavaCompiler c = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = c.getStandardFileManager(null, null, null); + Iterable fos = + fm.getJavaFileObjectsFromFiles( + Arrays.asList(new File(System.getProperty("test.src"), + this.getClass().getName() + ".java"))); + JavacTask task = (JavacTask) c.getTask(null, fm, null, + Arrays.asList("-d", System.getProperty("user.dir")), null, fos); + + BasicJavacTask impl = (BasicJavacTask)task; + Context context = impl.getContext(); + final Names names = Names.instance(context); + + task.addTaskListener(new TaskListener() { + + @Override + public void started(TaskEvent e) {} + + @Override + public void finished(TaskEvent e) { + class TheTreeScanner extends TreeScanner { + boolean foundAndCorrect = false; + + @Override + public void visitMethodDef(JCTree.JCMethodDecl tree) { + ClassSymbol clazz = (ClassSymbol)tree.sym.owner; + if (clazz.owner.name.toString().equals(classOwnerName) && + tree.sym.name == names.init) { + + int currentParamPos = 0; + int paramArrayIndex = 0; + + List params = tree.sym.params; + while (params.nonEmpty() && paramArrayIndex < paramsToCheck.size()) { + VarSymbol param = params.head; + if (currentParamPos == paramsToCheck.get(paramArrayIndex)) { + if (!param.name.toString() + .equals(paramNames.get(paramArrayIndex))) { + error(paramNameNotCopiedAssertionMsg); + } + paramArrayIndex++; + } + currentParamPos++; + params = params.tail; + } + foundAndCorrect = paramArrayIndex >= paramsToCheck.size(); + } + super.visitMethodDef(tree); + } + } + + if (e.getKind() == TaskEvent.Kind.ANALYZE) { + CompilationUnitTree compUnitTree = e.getCompilationUnit(); + boolean foundAndCorrect = false; + for (Tree tree : compUnitTree.getTypeDecls()) { + TheTreeScanner scanner = new TheTreeScanner(); + scanner.scan((JCTree) tree); + foundAndCorrect = foundAndCorrect | scanner.foundAndCorrect; + } + if (!foundAndCorrect) { + error(seekMethodNotFound); + } + } + } + }); + + if (!task.call()) { + error(compilationFailed); + } + } + + void error(String msg) { + throw new AssertionError(msg); + } + + @Target(value = {ElementType.PARAMETER}) + @interface ParamAnnotation {} + + /* If more cases are added in the future, it should be taken into account + * that method checkInitSymbol locates the inner class looking for its + * container method, which in the cases below are m1 and m2. So new cases + * must have different names for container methods or method checkInitSymbol + * should be changed. + */ + public class initParams { + public initParams(@ParamAnnotation int i) {} + + public void m1() { + new initParams(2) {}; + } + } + + class Generics { + T1 obj1; + Object obj2; + Generics(@ParamAnnotation T1 t1, @ParamAnnotation T2 t2) { + obj1 = t1; + obj2 = t2; + } + + void m2() { + Generics a = new Generics( + new Integer(11), "foo") {}; + } + } +} From 7ab75872278b4a72006fffa58f7470dfae780563 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Sat, 1 Jun 2013 22:09:18 +0100 Subject: [PATCH 121/206] 6695379: Copy method annotations and parameter annotations to synthetic bridge methods Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/TransTypes.java | 30 +++++ .../com/sun/tools/javac/jvm/ClassWriter.java | 20 ++-- .../test/tools/javac/6889255/T6889255.java | 6 +- .../MethodParameters/ClassFileVisitor.java | 12 +- .../MethodParameters/ReflectionVisitor.java | 4 +- .../tools/javac/MethodParameters/Tester.java | 1 - ...ationsAreNotCopiedToBridgeMethodsTest.java | 103 ++++++++++++++++++ 7 files changed, 155 insertions(+), 21 deletions(-) create mode 100644 langtools/test/tools/javac/T6695379/AnnotationsAreNotCopiedToBridgeMethodsTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java index 4c227425149..fe46b2913f1 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java @@ -258,6 +258,14 @@ public class TransTypes extends TreeTranslator { meth.name, bridgeType, origin); + /* once JDK-6996415 is solved it should be checked if this approach can + * be applied to method addOverrideBridgesIfNeeded + */ + bridge.params = createBridgeParams(impl, bridge, bridgeType); + if (impl.annotations != null) { + bridge.annotations.setAttributes(impl.annotations); + } + if (!hypothetical) { JCMethodDecl md = make.MethodDef(bridge, null); @@ -292,6 +300,28 @@ public class TransTypes extends TreeTranslator { overridden.put(bridge, meth); } + private List createBridgeParams(MethodSymbol impl, MethodSymbol bridge, + Type bridgeType) { + List bridgeParams = null; + if (impl.params != null) { + bridgeParams = List.nil(); + List implParams = impl.params; + Type.MethodType mType = (Type.MethodType)bridgeType; + List argTypes = mType.argtypes; + while (implParams.nonEmpty() && argTypes.nonEmpty()) { + VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC, + implParams.head.name, argTypes.head, bridge); + if (implParams.head.annotations != null) { + param.annotations.setAttributes(implParams.head.annotations); + } + bridgeParams = bridgeParams.append(param); + implParams = implParams.tail; + argTypes = argTypes.tail; + } + } + return bridgeParams; + } + /** Add bridge if given symbol is a non-private, non-static member * of the given class, which is either defined in the class or non-final * inherited, and one of the two following conditions holds: diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java index 8c020a43343..90aabc61a39 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java @@ -31,7 +31,6 @@ import java.util.Map; import java.util.Set; import java.util.HashSet; -import javax.lang.model.type.TypeKind; import javax.tools.JavaFileManager; import javax.tools.FileObject; import javax.tools.JavaFileObject; @@ -39,9 +38,6 @@ import javax.tools.JavaFileObject; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Attribute.RetentionPolicy; import com.sun.tools.javac.code.Attribute.TypeCompound; -import static com.sun.tools.javac.code.BoundKind.EXTENDS; -import static com.sun.tools.javac.code.BoundKind.SUPER; -import static com.sun.tools.javac.code.BoundKind.UNBOUND; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Type.*; import com.sun.tools.javac.code.Types.UniqueType; @@ -674,13 +670,15 @@ public class ClassWriter extends ClassFile { int writeParameterAttrs(MethodSymbol m) { boolean hasVisible = false; boolean hasInvisible = false; - if (m.params != null) for (VarSymbol s : m.params) { - for (Attribute.Compound a : s.getRawAttributes()) { - switch (types.getRetention(a)) { - case SOURCE: break; - case CLASS: hasInvisible = true; break; - case RUNTIME: hasVisible = true; break; - default: ;// /* fail soft */ throw new AssertionError(vis); + if (m.params != null) { + for (VarSymbol s : m.params) { + for (Attribute.Compound a : s.getRawAttributes()) { + switch (types.getRetention(a)) { + case SOURCE: break; + case CLASS: hasInvisible = true; break; + case RUNTIME: hasVisible = true; break; + default: ;// /* fail soft */ throw new AssertionError(vis); + } } } } diff --git a/langtools/test/tools/javac/6889255/T6889255.java b/langtools/test/tools/javac/6889255/T6889255.java index 8c820bcd3bc..f0b93148c2f 100644 --- a/langtools/test/tools/javac/6889255/T6889255.java +++ b/langtools/test/tools/javac/6889255/T6889255.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -429,9 +429,9 @@ public class T6889255 { // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.flags() & Flags.ABSTRACT) != 0) return "arg" + (i - 1); - // bridge methods use xN + // bridge methods use argN. No LVT for them anymore if ((v.owner.flags() & Flags.BRIDGE) != 0) - return "x" + (i - 1); + return "arg" + (i - 1); // The rest of this method assumes the local conventions in the test program Type t = v.type; diff --git a/langtools/test/tools/javac/MethodParameters/ClassFileVisitor.java b/langtools/test/tools/javac/MethodParameters/ClassFileVisitor.java index c5d1d93ccc9..777a552769a 100644 --- a/langtools/test/tools/javac/MethodParameters/ClassFileVisitor.java +++ b/langtools/test/tools/javac/MethodParameters/ClassFileVisitor.java @@ -21,10 +21,8 @@ * questions. */ -import com.sun.tools.classfile.*; import java.io.*; -import javax.lang.model.element.*; -import java.util.*; +import com.sun.tools.classfile.*; /** * The {@code ClassFileVisitor} reads a class file using the @@ -150,6 +148,7 @@ class ClassFileVisitor extends Tester.Visitor { public int mNumParams; public boolean mSynthetic; public boolean mIsConstructor; + public boolean mIsBridge; public String prefix; void visitMethod(Method method, StringBuilder sb) throws Exception { @@ -162,6 +161,7 @@ class ClassFileVisitor extends Tester.Visitor { mSynthetic = method.access_flags.is(AccessFlags.ACC_SYNTHETIC); mIsConstructor = mName.equals(""); prefix = cname + "." + mName + "() - "; + mIsBridge = method.access_flags.is(AccessFlags.ACC_BRIDGE); sb.append(cname).append(".").append(mName).append("("); @@ -320,6 +320,12 @@ class ClassFileVisitor extends Tester.Visitor { } else if (isEnum && mNumParams == 1 && index == 0 && mName.equals("valueOf")) { expect = "name"; allowMandated = true; + } else if (mIsBridge) { + allowSynthetic = true; + /* you can't expect an special name for bridges' parameters. + * The name of the original parameters are now copied. + */ + expect = null; } if (mandated) sb.append("!"); if (synthetic) sb.append("!!"); diff --git a/langtools/test/tools/javac/MethodParameters/ReflectionVisitor.java b/langtools/test/tools/javac/MethodParameters/ReflectionVisitor.java index a7129ba98e7..841e70cbea2 100644 --- a/langtools/test/tools/javac/MethodParameters/ReflectionVisitor.java +++ b/langtools/test/tools/javac/MethodParameters/ReflectionVisitor.java @@ -22,8 +22,6 @@ */ import java.io.*; -import java.util.*; -import java.net.*; import java.lang.reflect.*; /** @@ -250,7 +248,7 @@ public class ReflectionVisitor extends Tester.Visitor { String expect = m.isSynthetic() ? ("arg" + i) : ((++c) + param); param = p.getName(); sb.append(sep).append(param); - if (!expect.equals(param)) { + if (!m.isBridge() && !expect.equals(param)) { error(prefix + "param[" + i + "]='" + param + "' expected '" + expect + "'"); break; diff --git a/langtools/test/tools/javac/MethodParameters/Tester.java b/langtools/test/tools/javac/MethodParameters/Tester.java index d721390f3b7..84b2dddb5e4 100644 --- a/langtools/test/tools/javac/MethodParameters/Tester.java +++ b/langtools/test/tools/javac/MethodParameters/Tester.java @@ -22,7 +22,6 @@ */ import java.io.*; -import java.util.*; import java.lang.reflect.Constructor; /** diff --git a/langtools/test/tools/javac/T6695379/AnnotationsAreNotCopiedToBridgeMethodsTest.java b/langtools/test/tools/javac/T6695379/AnnotationsAreNotCopiedToBridgeMethodsTest.java new file mode 100644 index 00000000000..e2b503aed5c --- /dev/null +++ b/langtools/test/tools/javac/T6695379/AnnotationsAreNotCopiedToBridgeMethodsTest.java @@ -0,0 +1,103 @@ +/* + * 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 6695379 + * @summary Copy method annotations and parameter annotations to synthetic + * bridge methods + * @run main AnnotationsAreNotCopiedToBridgeMethodsTest + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.io.BufferedInputStream; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import com.sun.tools.classfile.AccessFlags; +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.Attributes; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.Method; +import com.sun.tools.javac.util.Assert; + +public class AnnotationsAreNotCopiedToBridgeMethodsTest { + + public static void main(String[] args) throws Exception { + new AnnotationsAreNotCopiedToBridgeMethodsTest().run(); + } + + void run() throws Exception { + checkClassFile(Paths.get(System.getProperty("test.classes"), + this.getClass().getSimpleName() + "$CovariantReturnType.class")); + checkClassFile(Paths.get(System.getProperty("test.classes"), + this.getClass().getSimpleName() + + "$CovariantReturnType$VisibilityChange.class")); + } + + void checkClassFile(final Path cfilePath) throws Exception { + ClassFile classFile = ClassFile.read( + new BufferedInputStream(Files.newInputStream(cfilePath))); + for (Method method : classFile.methods) { + if (method.access_flags.is(AccessFlags.ACC_BRIDGE)) { + checkForAttr(method.attributes, + "Annotations hasn't been copied to bridge method", + Attribute.RuntimeVisibleAnnotations, + Attribute.RuntimeVisibleParameterAnnotations); + } + } + } + + void checkForAttr(Attributes attrs, String errorMsg, String... attrNames) { + for (String attrName : attrNames) { + Assert.checkNonNull(attrs.get(attrName), errorMsg); + } + } + + @Target(value = {ElementType.PARAMETER}) + @Retention(RetentionPolicy.RUNTIME) + @interface ParamAnnotation {} + + @Target(value = {ElementType.METHOD}) + @Retention(RetentionPolicy.RUNTIME) + @interface MethodAnnotation {} + + abstract class T { + B m(A a){return null;} + } + + class CovariantReturnType extends T { + @MethodAnnotation + Integer m(@ParamAnnotation Integer i) { + return i; + } + + public class VisibilityChange extends CovariantReturnType {} + + } + +} From 05a410aadaef8ef0fb6d540e007dddde5a67ff9f Mon Sep 17 00:00:00 2001 From: Petr Pchelko Date: Mon, 3 Jun 2013 10:14:05 +0400 Subject: [PATCH 122/206] 8015477: Support single threaded AWT/FX mode Reviewed-by: ant, anthony --- .../classes/sun/lwawt/macosx/LWCToolkit.java | 17 +++++- .../native/sun/awt/CDropTargetContextPeer.m | 1 - jdk/src/macosx/native/sun/awt/LWCToolkit.m | 9 ++- .../share/classes/java/awt/EventQueue.java | 44 +++++++++++--- .../share/classes/sun/awt/AWTAccessor.java | 5 ++ .../share/classes/sun/awt/FwDispatcher.java | 59 +++++++++++++++++++ 6 files changed, 119 insertions(+), 16 deletions(-) create mode 100644 jdk/src/share/classes/sun/awt/FwDispatcher.java diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index a15eb46a1d1..fcbd9cb388e 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -77,8 +77,20 @@ public final class LWCToolkit extends LWToolkit { if (!GraphicsEnvironment.isHeadless()) { initIDs(); } + inAWT = AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Boolean run() { + return !Boolean.parseBoolean(System.getProperty("javafx.embed.singleThread", "false")); + } + }); } + /* + * If true we operate in normal mode and nested runloop is executed in JavaRunLoopMode + * If false we operate in singleThreaded FX/AWT interop mode and nested loop uses NSDefaultRunLoopMode + */ + private static final boolean inAWT; + public LWCToolkit() { SunToolkit.setDataTransfererClassName("sun.lwawt.macosx.CDataTransferer"); @@ -701,7 +713,10 @@ public final class LWCToolkit extends LWToolkit { * * if false - all events come after exit form the nested loop */ - static native void doAWTRunLoop(long mediator, boolean processEvents); + static void doAWTRunLoop(long mediator, boolean processEvents) { + doAWTRunLoopImpl(mediator, processEvents, inAWT); + } + static private native void doAWTRunLoopImpl(long mediator, boolean processEvents, boolean inAWT); static native void stopAWTRunLoop(long mediator); private native boolean nativeSyncQueue(long timeout); diff --git a/jdk/src/macosx/native/sun/awt/CDropTargetContextPeer.m b/jdk/src/macosx/native/sun/awt/CDropTargetContextPeer.m index 0e64b072e5f..5621003bf5a 100644 --- a/jdk/src/macosx/native/sun/awt/CDropTargetContextPeer.m +++ b/jdk/src/macosx/native/sun/awt/CDropTargetContextPeer.m @@ -61,7 +61,6 @@ static CDropTarget* GetCDropTarget(jlong jdroptarget) { JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDropTargetContextPeer_startTransfer (JNIEnv *env, jobject jthis, jlong jdroptarget, jlong jformat) { - AWT_ASSERT_NOT_APPKIT_THREAD; jlong result = (jlong) 0L; diff --git a/jdk/src/macosx/native/sun/awt/LWCToolkit.m b/jdk/src/macosx/native/sun/awt/LWCToolkit.m index 47c72abbfa5..6f42c0f9535 100644 --- a/jdk/src/macosx/native/sun/awt/LWCToolkit.m +++ b/jdk/src/macosx/native/sun/awt/LWCToolkit.m @@ -295,11 +295,11 @@ AWT_ASSERT_APPKIT_THREAD; /* * Class: sun_lwawt_macosx_LWCToolkit - * Method: doAWTRunLoop + * Method: doAWTRunLoopImpl * Signature: (JZZ)V */ -JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_doAWTRunLoop -(JNIEnv *env, jclass clz, jlong mediator, jboolean processEvents) +JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_doAWTRunLoopImpl +(JNIEnv *env, jclass clz, jlong mediator, jboolean processEvents, jboolean inAWT) { AWT_ASSERT_APPKIT_THREAD; JNF_COCOA_ENTER(env); @@ -311,7 +311,7 @@ JNF_COCOA_ENTER(env); // Don't use acceptInputForMode because that doesn't setup autorelease pools properly BOOL isRunning = true; while (![mediatorObject shouldEndRunLoop] && isRunning) { - isRunning = [[NSRunLoop currentRunLoop] runMode:[JNFRunLoop javaRunLoopMode] + isRunning = [[NSRunLoop currentRunLoop] runMode:(inAWT ? [JNFRunLoop javaRunLoopMode] : NSDefaultRunLoopMode) beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.010]]; if (processEvents) { //We do not spin a runloop here as date is nil, so does not matter which mode to use @@ -340,7 +340,6 @@ JNF_COCOA_EXIT(env); JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_stopAWTRunLoop (JNIEnv *env, jclass clz, jlong mediator) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); AWTRunLoopObject* mediatorObject = (AWTRunLoopObject*)jlong_to_ptr(mediator); diff --git a/jdk/src/share/classes/java/awt/EventQueue.java b/jdk/src/share/classes/java/awt/EventQueue.java index 5795c37ae91..bf7c426a426 100644 --- a/jdk/src/share/classes/java/awt/EventQueue.java +++ b/jdk/src/share/classes/java/awt/EventQueue.java @@ -37,16 +37,10 @@ import java.security.PrivilegedAction; import java.util.EmptyStackException; +import sun.awt.*; import sun.awt.dnd.SunDropTargetEvent; import sun.util.logging.PlatformLogger; -import sun.awt.AppContext; -import sun.awt.AWTAutoShutdown; -import sun.awt.PeerEvent; -import sun.awt.SunToolkit; -import sun.awt.EventQueueItem; -import sun.awt.AWTAccessor; - import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.atomic.AtomicInteger; @@ -181,6 +175,8 @@ public class EventQueue { private final String name = "AWT-EventQueue-" + threadInitNumber.getAndIncrement(); + private FwDispatcher fwDispatcher; + private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventQueue"); static { @@ -209,6 +205,10 @@ public class EventQueue { { EventQueue.invokeAndWait(source, r); } + public void setFwDispatcher(EventQueue eventQueue, + FwDispatcher dispatcher) { + eventQueue.setFwDispatcher(dispatcher); + } }); } @@ -684,7 +684,16 @@ public class EventQueue { final Object src = event.getSource(); final PrivilegedAction action = new PrivilegedAction() { public Void run() { - dispatchEventImpl(event, src); + if (fwDispatcher == null) { + dispatchEventImpl(event, src); + } else { + fwDispatcher.scheduleDispatch(new Runnable() { + @Override + public void run() { + dispatchEventImpl(event, src); + } + }); + } return null; } }; @@ -844,7 +853,9 @@ public class EventQueue { while (topQueue.nextQueue != null) { topQueue = topQueue.nextQueue; } - + if (topQueue.fwDispatcher != null) { + throw new RuntimeException("push() to queue with fwDispatcher"); + } if ((topQueue.dispatchThread != null) && (topQueue.dispatchThread.getEventQueue() == this)) { @@ -975,6 +986,9 @@ public class EventQueue { // Forward the request to the top of EventQueue stack return nextQueue.createSecondaryLoop(cond, filter, interval); } + if (fwDispatcher != null) { + return fwDispatcher.createSecondaryLoop(); + } if (dispatchThread == null) { initDispatchThread(); } @@ -1018,6 +1032,9 @@ public class EventQueue { eq = next; next = eq.nextQueue; } + if (eq.fwDispatcher != null) { + return eq.fwDispatcher.isDispatchThread(); + } return (Thread.currentThread() == eq.dispatchThread); } finally { pushPopLock.unlock(); @@ -1303,6 +1320,15 @@ public class EventQueue { pushPopLock.unlock(); } } + + // The method is used by AWTAccessor for javafx/AWT single threaded mode. + private void setFwDispatcher(FwDispatcher dispatcher) { + if (nextQueue != null) { + nextQueue.setFwDispatcher(dispatcher); + } else { + fwDispatcher = dispatcher; + } + } } /** diff --git a/jdk/src/share/classes/sun/awt/AWTAccessor.java b/jdk/src/share/classes/sun/awt/AWTAccessor.java index 1907ac4c7c1..781750b0f1c 100644 --- a/jdk/src/share/classes/sun/awt/AWTAccessor.java +++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java @@ -484,6 +484,11 @@ public final class AWTAccessor { */ void invokeAndWait(Object source, Runnable r) throws InterruptedException, InvocationTargetException; + + /** + * Sets the delegate for the EventQueue used by FX/AWT single threaded mode + */ + public void setFwDispatcher(EventQueue eventQueue, FwDispatcher dispatcher); } /* diff --git a/jdk/src/share/classes/sun/awt/FwDispatcher.java b/jdk/src/share/classes/sun/awt/FwDispatcher.java new file mode 100644 index 00000000000..8ceb67e05b1 --- /dev/null +++ b/jdk/src/share/classes/sun/awt/FwDispatcher.java @@ -0,0 +1,59 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.awt; + +import java.awt.*; + +/** + * An interface for the EventQueue delegate. + * This class is added to support JavaFX/AWT interop single threaded mode + * The delegate should be set in EventQueue by {@link EventQueue#setFwDispatcher(FwDispatcher)} + * If the delegate is not null, than it handles supported methods instead of the + * event queue. If it is null than the behaviour of an event queue does not change. + * + * @see EventQueue + * + * @author Petr Pchelko + * + * @since 1.8 + */ +public interface FwDispatcher { + /** + * Delegates the {@link EventQueue#isDispatchThread()} method + */ + boolean isDispatchThread(); + + /** + * Forwards a runnable to the delegate, which executes it on an appropriate thread. + * @param r - a runnable calling {@link EventQueue#dispatchEventImpl(java.awt.AWTEvent, Object)} + */ + void scheduleDispatch(Runnable r); + + /** + * Delegates the {@link java.awt.EventQueue#createSecondaryLoop()} method + */ + SecondaryLoop createSecondaryLoop(); +} From d6efb99686b381dc806ec0f5693c3f11d4604a9c Mon Sep 17 00:00:00 2001 From: Albert Noll Date: Mon, 3 Jun 2013 08:52:20 +0200 Subject: [PATCH 123/206] 8013329: File leak in hotspot/src/share/vm/compiler/compileBroker.cpp Added calling of the destructor of CompileLog so that files are closed. Added/moved memory allocation/deallocation of the string that contains the name of the log file to class CompileLog. Reviewed-by: kvn, roland --- .../src/share/vm/compiler/compileBroker.cpp | 41 ++++++++----------- hotspot/src/share/vm/compiler/compileLog.cpp | 15 +++++-- hotspot/src/share/vm/compiler/compileLog.hpp | 2 +- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index ad097d96a9b..73c00bf11e2 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -1642,42 +1642,37 @@ void CompileBroker::compiler_thread_loop() { // Set up state required by +LogCompilation. void CompileBroker::init_compiler_thread_log() { CompilerThread* thread = CompilerThread::current(); - char fileBuf[4*K]; + char file_name[4*K]; FILE* fp = NULL; - char* file = NULL; intx thread_id = os::current_thread_id(); for (int try_temp_dir = 1; try_temp_dir >= 0; try_temp_dir--) { const char* dir = (try_temp_dir ? os::get_temp_directory() : NULL); if (dir == NULL) { - jio_snprintf(fileBuf, sizeof(fileBuf), "hs_c" UINTX_FORMAT "_pid%u.log", + jio_snprintf(file_name, sizeof(file_name), "hs_c" UINTX_FORMAT "_pid%u.log", thread_id, os::current_process_id()); } else { - jio_snprintf(fileBuf, sizeof(fileBuf), + jio_snprintf(file_name, sizeof(file_name), "%s%shs_c" UINTX_FORMAT "_pid%u.log", dir, os::file_separator(), thread_id, os::current_process_id()); } - fp = fopen(fileBuf, "at"); + + fp = fopen(file_name, "at"); if (fp != NULL) { - file = NEW_C_HEAP_ARRAY(char, strlen(fileBuf)+1, mtCompiler); - strcpy(file, fileBuf); - break; - } - } - if (fp == NULL) { - warning("Cannot open log file: %s", fileBuf); - } else { - if (LogCompilation && Verbose) - tty->print_cr("Opening compilation log %s", file); - CompileLog* log = new(ResourceObj::C_HEAP, mtCompiler) CompileLog(file, fp, thread_id); - thread->init_log(log); - - if (xtty != NULL) { - ttyLocker ttyl; - - // Record any per thread log files - xtty->elem("thread_logfile thread='%d' filename='%s'", thread_id, file); + if (LogCompilation && Verbose) { + tty->print_cr("Opening compilation log %s", file_name); + } + CompileLog* log = new(ResourceObj::C_HEAP, mtCompiler) CompileLog(file_name, fp, thread_id); + thread->init_log(log); + + if (xtty != NULL) { + ttyLocker ttyl; + // Record any per thread log files + xtty->elem("thread_logfile thread='%d' filename='%s'", thread_id, file_name); + } + return; } } + warning("Cannot open log file: %s", file_name); } // ------------------------------------------------------------------ diff --git a/hotspot/src/share/vm/compiler/compileLog.cpp b/hotspot/src/share/vm/compiler/compileLog.cpp index 2201c7f9e16..2cce602f3ed 100644 --- a/hotspot/src/share/vm/compiler/compileLog.cpp +++ b/hotspot/src/share/vm/compiler/compileLog.cpp @@ -34,17 +34,18 @@ CompileLog* CompileLog::_first = NULL; // ------------------------------------------------------------------ // CompileLog::CompileLog -CompileLog::CompileLog(const char* file, FILE* fp, intx thread_id) +CompileLog::CompileLog(const char* file_name, FILE* fp, intx thread_id) : _context(_context_buffer, sizeof(_context_buffer)) { - initialize(new(ResourceObj::C_HEAP, mtCompiler) fileStream(fp)); - _file = file; + initialize(new(ResourceObj::C_HEAP, mtCompiler) fileStream(fp, true)); _file_end = 0; _thread_id = thread_id; _identities_limit = 0; _identities_capacity = 400; _identities = NEW_C_HEAP_ARRAY(char, _identities_capacity, mtCompiler); + _file = NEW_C_HEAP_ARRAY(char, strlen(file_name)+1, mtCompiler); + strcpy((char*)_file, file_name); // link into the global list { MutexLocker locker(CompileTaskAlloc_lock); @@ -57,6 +58,7 @@ CompileLog::~CompileLog() { delete _out; _out = NULL; FREE_C_HEAP_ARRAY(char, _identities, mtCompiler); + FREE_C_HEAP_ARRAY(char, _file, mtCompiler); } @@ -188,7 +190,8 @@ void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen) if (called_exit) return; called_exit = true; - for (CompileLog* log = _first; log != NULL; log = log->_next) { + CompileLog* log = _first; + while (log != NULL) { log->flush(); const char* partial_file = log->file(); int partial_fd = open(partial_file, O_RDONLY); @@ -267,7 +270,11 @@ void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen) close(partial_fd); unlink(partial_file); } + CompileLog* next_log = log->_next; + delete log; + log = next_log; } + _first = NULL; } // ------------------------------------------------------------------ diff --git a/hotspot/src/share/vm/compiler/compileLog.hpp b/hotspot/src/share/vm/compiler/compileLog.hpp index 1af5e91435b..8b740f9f2a2 100644 --- a/hotspot/src/share/vm/compiler/compileLog.hpp +++ b/hotspot/src/share/vm/compiler/compileLog.hpp @@ -57,7 +57,7 @@ class CompileLog : public xmlStream { void va_tag(bool push, const char* format, va_list ap); public: - CompileLog(const char* file, FILE* fp, intx thread_id); + CompileLog(const char* file_name, FILE* fp, intx thread_id); ~CompileLog(); intx thread_id() { return _thread_id; } From 8db7e02270c60ccc4e5fc5630010c88439d327e8 Mon Sep 17 00:00:00 2001 From: Anton Litvinov Date: Mon, 3 Jun 2013 14:05:55 +0400 Subject: [PATCH 124/206] 7151823: The test incorrectly recognizing OS Reviewed-by: serb, alexp --- jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java b/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java index 45ca603447e..d8bf8f621ba 100644 --- a/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java +++ b/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java @@ -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 @@ -37,6 +37,8 @@ import java.awt.*; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.KeyEvent; + +import sun.awt.OSInfo; import sun.awt.SunToolkit; public class bug4624207 implements ChangeListener, FocusListener { @@ -99,7 +101,7 @@ public class bug4624207 implements ChangeListener, FocusListener { toolkit.realSync(); - if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { + if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) { Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B); } else { Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B); From 49c5af63c9ecfc747bb7c1245ce0e78d233afb8f Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Mon, 3 Jun 2013 15:58:14 +0530 Subject: [PATCH 125/206] 8015345: Function("}),print('test'),({") should throw SyntaxError Reviewed-by: lagergren, hannesw, jlaskey --- .../internal/objects/NativeFunction.java | 39 ++++- .../jdk/nashorn/internal/parser/Parser.java | 149 ++++++++++++++---- nashorn/test/script/basic/JDK-8015345.js | 64 ++++++++ .../test/script/basic/JDK-8015345.js.EXPECTED | 15 ++ .../script/basic/funcconstructor.js.EXPECTED | 2 +- 5 files changed, 236 insertions(+), 33 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8015345.js create mode 100644 nashorn/test/script/basic/JDK-8015345.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeFunction.java b/nashorn/src/jdk/nashorn/internal/objects/NativeFunction.java index 13c1bc152ad..528b120a853 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeFunction.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeFunction.java @@ -33,10 +33,14 @@ import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; import jdk.nashorn.internal.objects.annotations.Function; import jdk.nashorn.internal.objects.annotations.ScriptClass; +import jdk.nashorn.internal.parser.Parser; +import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.JSType; +import jdk.nashorn.internal.runtime.ParserException; import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptRuntime; +import jdk.nashorn.internal.runtime.Source; /** * ECMA 15.3 Function Objects @@ -187,16 +191,25 @@ public final class NativeFunction { sb.append("(function ("); if (args.length > 0) { + final StringBuilder paramListBuf = new StringBuilder(); for (int i = 0; i < args.length - 1; i++) { - sb.append(JSType.toString(args[i])); + paramListBuf.append(JSType.toString(args[i])); if (i < args.length - 2) { - sb.append(","); + paramListBuf.append(","); } } + + final String paramList = paramListBuf.toString(); + if (! paramList.isEmpty()) { + checkFunctionParameters(paramList); + sb.append(paramList); + } } sb.append(") {\n"); if (args.length > 0) { - sb.append(JSType.toString(args[args.length - 1])); + final String funcBody = JSType.toString(args[args.length - 1]); + checkFunctionBody(funcBody); + sb.append(funcBody); sb.append('\n'); } sb.append("})"); @@ -205,4 +218,24 @@ public final class NativeFunction { return Global.directEval(global, sb.toString(), global, "", Global.isStrict()); } + + private static void checkFunctionParameters(final String params) { + final Source src = new Source("", params); + final Parser parser = new Parser(Global.getEnv(), src, new Context.ThrowErrorManager()); + try { + parser.parseFormalParameterList(); + } catch (final ParserException pe) { + pe.throwAsEcmaException(); + } + } + + private static void checkFunctionBody(final String funcBody) { + final Source src = new Source("", funcBody); + final Parser parser = new Parser(Global.getEnv(), src, new Context.ThrowErrorManager()); + try { + parser.parseFunctionBody(); + } catch (final ParserException pe) { + pe.throwAsEcmaException(); + } + } } diff --git a/nashorn/src/jdk/nashorn/internal/parser/Parser.java b/nashorn/src/jdk/nashorn/internal/parser/Parser.java index 03f65b86e11..e4dcf1b7424 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/Parser.java +++ b/nashorn/src/jdk/nashorn/internal/parser/Parser.java @@ -192,36 +192,110 @@ public class Parser extends AbstractParser { // Begin parse. return program(scriptName); } catch (final Exception e) { - // Extract message from exception. The message will be in error - // message format. - String message = e.getMessage(); - - // If empty message. - if (message == null) { - message = e.toString(); - } - - // Issue message. - if (e instanceof ParserException) { - errors.error((ParserException)e); - } else { - errors.error(message); - } - - if (env._dump_on_error) { - e.printStackTrace(env.getErr()); - } + handleParseException(e); return null; - } finally { - final String end = this + " end '" + scriptName + "'"; - if (Timing.isEnabled()) { - Timing.accumulateTime(toString(), System.currentTimeMillis() - t0); - LOG.info(end, "' in ", (System.currentTimeMillis() - t0), " ms"); - } else { - LOG.info(end); - } - } + } finally { + final String end = this + " end '" + scriptName + "'"; + if (Timing.isEnabled()) { + Timing.accumulateTime(toString(), System.currentTimeMillis() - t0); + LOG.info(end, "' in ", (System.currentTimeMillis() - t0), " ms"); + } else { + LOG.info(end); + } + } + } + + /** + * Parse and return the list of function parameter list. A comma + * separated list of function parameter identifiers is expected to be parsed. + * Errors will be thrown and the error manager will contain information + * if parsing should fail. This method is used to check if parameter Strings + * passed to "Function" constructor is a valid or not. + * + * @return the list of IdentNodes representing the formal parameter list + */ + public List parseFormalParameterList() { + try { + stream = new TokenStream(); + lexer = new Lexer(source, stream, scripting && !env._no_syntax_extensions); + + // Set up first token (skips opening EOL.) + k = -1; + next(); + + return formalParameterList(TokenType.EOF); + } catch (final Exception e) { + handleParseException(e); + return null; + } + } + + /** + * Execute parse and return the resulting function node. + * Errors will be thrown and the error manager will contain information + * if parsing should fail. This method is used to check if code String + * passed to "Function" constructor is a valid function body or not. + * + * @return function node resulting from successful parse + */ + public FunctionNode parseFunctionBody() { + try { + stream = new TokenStream(); + lexer = new Lexer(source, stream, scripting && !env._no_syntax_extensions); + + // Set up first token (skips opening EOL.) + k = -1; + next(); + + // Make a fake token for the function. + final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); + // Set up the function to append elements. + + FunctionNode function = newFunctionNode( + functionToken, + new IdentNode(functionToken, Token.descPosition(functionToken), RUN_SCRIPT.symbolName()), + new ArrayList(), + FunctionNode.Kind.NORMAL); + + functionDeclarations = new ArrayList<>(); + sourceElements(); + addFunctionDeclarations(function); + functionDeclarations = null; + + expect(EOF); + + function.setFinish(source.getLength() - 1); + + function = restoreFunctionNode(function, token); //commit code + function = function.setBody(lc, function.getBody().setNeedsScope(lc)); + return function; + } catch (final Exception e) { + handleParseException(e); + return null; + } + } + + private void handleParseException(final Exception e) { + // Extract message from exception. The message will be in error + // message format. + String message = e.getMessage(); + + // If empty message. + if (message == null) { + message = e.toString(); + } + + // Issue message. + if (e instanceof ParserException) { + errors.error((ParserException)e); + } else { + errors.error(message); + } + + if (env._dump_on_error) { + e.printStackTrace(env.getErr()); + } } /** @@ -2424,12 +2498,29 @@ loop: * @return List of parameter nodes. */ private List formalParameterList() { + return formalParameterList(RPAREN); + } + + /** + * Same as the other method of the same name - except that the end + * token type expected is passed as argument to this method. + * + * FormalParameterList : + * Identifier + * FormalParameterList , Identifier + * + * See 13 + * + * Parse function parameter list. + * @return List of parameter nodes. + */ + private List formalParameterList(final TokenType endType) { // Prepare to gather parameters. final List parameters = new ArrayList<>(); // Track commas. boolean first = true; - while (type != RPAREN) { + while (type != endType) { // Comma prior to every argument except the first. if (!first) { expect(COMMARIGHT); diff --git a/nashorn/test/script/basic/JDK-8015345.js b/nashorn/test/script/basic/JDK-8015345.js new file mode 100644 index 00000000000..3f551d9e44b --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015345.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8015345: Function("}),print('test'),({") should throw SyntaxError + * + * @test + * @run + */ + +function checkFunction(code) { + try { + Function(code); + fail("should have thrown SyntaxError for :" + code); + } catch (e) { + if (! (e instanceof SyntaxError)) { + fail("SyntaxError expected, but got " + e); + } + print(e); + } +} + +// invalid body +checkFunction("}),print('test'),({"); + +// invalid param list +checkFunction("x**y", "print('x')"); + +// invalid param identifier +checkFunction("in", "print('hello')"); +//checkFunction("<>", "print('hello')") + +// invalid param list and body +checkFunction("x--y", ")"); + +// check few valid cases as well +var f = Function("x", "return x*x"); +print(f(10)) + +f = Function("x", "y", "return x+y"); +print(f(33, 22)); + +f = Function("x,y", "return x/y"); +print(f(24, 2)); diff --git a/nashorn/test/script/basic/JDK-8015345.js.EXPECTED b/nashorn/test/script/basic/JDK-8015345.js.EXPECTED new file mode 100644 index 00000000000..9408699b6bc --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015345.js.EXPECTED @@ -0,0 +1,15 @@ +SyntaxError: :1:0 Expected eof but found } +}),print('test'),({ +^ +SyntaxError: :1:2 Expected an operand but found * +x**y + ^ +SyntaxError: :1:0 Expected an operand but found in +in +^ +SyntaxError: :1:3 Expected ; but found y +x--y + ^ +100 +55 +12 diff --git a/nashorn/test/script/basic/funcconstructor.js.EXPECTED b/nashorn/test/script/basic/funcconstructor.js.EXPECTED index cf537d5ac86..cd7b16dd91e 100644 --- a/nashorn/test/script/basic/funcconstructor.js.EXPECTED +++ b/nashorn/test/script/basic/funcconstructor.js.EXPECTED @@ -4,7 +4,7 @@ function (x) { print('anon func'); return x*x; } syntax error? true -SyntaxError: :2:13 Missing close quote +SyntaxError: :1:13 Missing close quote print('hello) ^ done From b7ee1a873e544693e68e64bc054caf37060b0052 Mon Sep 17 00:00:00 2001 From: James Laskey Date: Mon, 3 Jun 2013 08:34:29 -0300 Subject: [PATCH 126/206] 8015741: Need a global.load function that starts with a new global scope Reviewed-by: sundar, lagergren --- .../jdk/nashorn/internal/objects/Global.java | 31 ++++++++-- .../jdk/nashorn/internal/runtime/Context.java | 22 +++++++ nashorn/test/script/basic/JDK-8015741.js | 57 +++++++++++++++++++ .../test/script/basic/JDK-8015741.js.EXPECTED | 12 ++++ 4 files changed, 117 insertions(+), 5 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8015741.js create mode 100644 nashorn/test/script/basic/JDK-8015741.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk/nashorn/internal/objects/Global.java index cdd0085f751..04daa8b58cc 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/Global.java +++ b/nashorn/src/jdk/nashorn/internal/objects/Global.java @@ -119,6 +119,10 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { @Property(attributes = Attribute.NOT_ENUMERABLE) public Object load; + /** Nashorn extension: global.loadWithNewGlobal */ + @Property(attributes = Attribute.NOT_ENUMERABLE) + public Object loadWithNewGlobal; + /** Nashorn extension: global.exit */ @Property(attributes = Attribute.NOT_ENUMERABLE) public Object exit; @@ -364,11 +368,12 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { // Used to store the last RegExp result to support deprecated RegExp constructor properties private RegExpResult lastRegExpResult; - private static final MethodHandle EVAL = findOwnMH("eval", Object.class, Object.class, Object.class); - private static final MethodHandle PRINT = findOwnMH("print", Object.class, Object.class, Object[].class); - private static final MethodHandle PRINTLN = findOwnMH("println", Object.class, Object.class, Object[].class); - private static final MethodHandle LOAD = findOwnMH("load", Object.class, Object.class, Object.class); - private static final MethodHandle EXIT = findOwnMH("exit", Object.class, Object.class, Object.class); + private static final MethodHandle EVAL = findOwnMH("eval", Object.class, Object.class, Object.class); + private static final MethodHandle PRINT = findOwnMH("print", Object.class, Object.class, Object[].class); + private static final MethodHandle PRINTLN = findOwnMH("println", Object.class, Object.class, Object[].class); + private static final MethodHandle LOAD = findOwnMH("load", Object.class, Object.class, Object.class); + private static final MethodHandle LOADWITHNEWGLOBAL = findOwnMH("loadWithNewGlobal", Object.class, Object.class, Object.class); + private static final MethodHandle EXIT = findOwnMH("exit", Object.class, Object.class, Object.class); private final Context context; @@ -742,6 +747,21 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { return global.context.load(scope, source); } + /** + * Global loadWithNewGlobal implementation - Nashorn extension + * + * @param self scope + * @param source source to load + * + * @return result of load (undefined) + * + * @throws IOException if source could not be read + */ + public static Object loadWithNewGlobal(final Object self, final Object source) throws IOException { + final Global global = Global.instance(); + return global.context.loadWithNewGlobal(source); + } + /** * Global exit and quit implementation - Nashorn extension: perform a {@code System.exit} call from the script * @@ -1387,6 +1407,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { this.unescape = ScriptFunctionImpl.makeFunction("unescape", GlobalFunctions.UNESCAPE); this.print = ScriptFunctionImpl.makeFunction("print", env._print_no_newline ? PRINT : PRINTLN); this.load = ScriptFunctionImpl.makeFunction("load", LOAD); + this.loadWithNewGlobal = ScriptFunctionImpl.makeFunction("loadWithNewGlobal", LOADWITHNEWGLOBAL); this.exit = ScriptFunctionImpl.makeFunction("exit", EXIT); this.quit = ScriptFunctionImpl.makeFunction("quit", EXIT); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index 338a8264d8f..392d6f432e2 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -490,6 +490,28 @@ public final class Context { throw typeError("cant.load.script", ScriptRuntime.safeToString(from)); } + /** + * Implementation of {@code loadWithNewGlobal} Nashorn extension. Load a script file from a source + * expression, after creating a new global scope. + * + * @param from source expression for script + * + * @return return value for load call (undefined) + * + * @throws IOException if source cannot be found or loaded + */ + public Object loadWithNewGlobal(final Object from) throws IOException { + final ScriptObject oldGlobal = getGlobalTrusted(); + final ScriptObject newGlobal = createGlobal(); + setGlobalTrusted(newGlobal); + + try { + return load(newGlobal, from); + } finally { + setGlobalTrusted(oldGlobal); + } + } + /** * Load or get a structure class. Structure class names are based on the number of parameter fields * and {@link AccessorProperty} fields in them. Structure classes are used to represent ScriptObjects diff --git a/nashorn/test/script/basic/JDK-8015741.js b/nashorn/test/script/basic/JDK-8015741.js new file mode 100644 index 00000000000..fdecee26842 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015741.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8015741 : Need a global.load function that starts with a new global scope. + * + * @test + * @run + */ + +var Thread = java.lang.Thread; + +myGlobal = "#0"; +var script1 = {name: "script 1", script: 'myGlobal = "#1"; print(myGlobal);'}; +var script2 = {name: "script 2", script: 'myGlobal = "#2"; print(myGlobal);'}; +var script3 = {name: "script 3", script: 'myGlobal = "#3"; print(myGlobal);'}; +var script4 = {name: "script 4", script: 'myGlobal = "#4"; print(myGlobal);'}; + +print(myGlobal); +load(script1); +print(myGlobal); + +print(myGlobal); +var thread1 = new Thread(function() { load(script2); }); +thread1.start(); +thread1.join(); +print(myGlobal); + +print(myGlobal); +loadWithNewGlobal(script3); +print(myGlobal); + +print(myGlobal); +var thread2 = new Thread(function() { loadWithNewGlobal(script4); }); +thread2.start(); +thread2.join(); +print(myGlobal); diff --git a/nashorn/test/script/basic/JDK-8015741.js.EXPECTED b/nashorn/test/script/basic/JDK-8015741.js.EXPECTED new file mode 100644 index 00000000000..46bb114336d --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015741.js.EXPECTED @@ -0,0 +1,12 @@ +#0 +#1 +#1 +#1 +#2 +#2 +#2 +#3 +#2 +#2 +#4 +#2 From 8c13d6cecfb1323f2722213075adcfb8a0cf144b Mon Sep 17 00:00:00 2001 From: Jose Luis Martin Date: Mon, 3 Jun 2013 16:27:44 +0400 Subject: [PATCH 127/206] 8015500: Prevent sending multiple WINDOW_CLOSED events for already disposed windows Reviewed-by: anthony, serb --- jdk/src/share/classes/java/awt/Window.java | 5 +- .../WindowClosedEventOnDispose.java | 203 ++++++++++++++++++ 2 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/awt/Window/WindowClosedEvents/WindowClosedEventOnDispose.java diff --git a/jdk/src/share/classes/java/awt/Window.java b/jdk/src/share/classes/java/awt/Window.java index 6428019f643..657092b68ef 100644 --- a/jdk/src/share/classes/java/awt/Window.java +++ b/jdk/src/share/classes/java/awt/Window.java @@ -1200,6 +1200,7 @@ public class Window extends Container implements Accessible { } } } + boolean fireWindowClosedEvent = isDisplayable(); DisposeAction action = new DisposeAction(); if (EventQueue.isDispatchThread()) { action.run(); @@ -1220,7 +1221,9 @@ public class Window extends Container implements Accessible { // Execute outside the Runnable because postWindowEvent is // synchronized on (this). We don't need to synchronize the call // on the EventQueue anyways. - postWindowEvent(WindowEvent.WINDOW_CLOSED); + if (fireWindowClosedEvent) { + postWindowEvent(WindowEvent.WINDOW_CLOSED); + } } /* diff --git a/jdk/test/java/awt/Window/WindowClosedEvents/WindowClosedEventOnDispose.java b/jdk/test/java/awt/Window/WindowClosedEvents/WindowClosedEventOnDispose.java new file mode 100644 index 00000000000..2bb42fc1fcc --- /dev/null +++ b/jdk/test/java/awt/Window/WindowClosedEvents/WindowClosedEventOnDispose.java @@ -0,0 +1,203 @@ +/* + * 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 8015500 + @summary DisposeAction multiplies the WINDOW_CLOSED event. + @author jlm@joseluismartin.info + @run main WindowClosedEventOnDispose + */ + + +import java.awt.Toolkit; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +/** + * WindowClosedEventOnDispose.java + * Summary: tests that Window don't multiplies the WINDOW_CLOSED event + * on dispose. + * Test fails if fire more events that expected; + */ +public class WindowClosedEventOnDispose { + + private static int N_LOOPS = 5; + private static int N_DIALOGS = 2; + + public static void main(String args[]) throws Exception { + tesWithFrame(); + testWithoutFrame(); + testHidenChildDispose(); + testHidenWindowDispose(); + } + + /** + * Test WINDOW_CLOSED event received by a dialog + * that have a owner window. + * @throws Exception + */ + public static void tesWithFrame() throws Exception { + doTest(true); + } + + /** + * Test WINDOW_CLOSED event received by a dialog + * that don't have a owner window. + * @throws Exception + */ + public static void testWithoutFrame() throws Exception { + System.out.println("Run without owner Frame"); + doTest(false); + } + + /** + * Test if a dialog that has never been shown fire + * the WINDOW_CLOSED event on parent dispose(). + * @throws Exception + */ + public static void testHidenChildDispose() throws Exception { + JFrame f = new JFrame(); + JDialog dlg = new JDialog(f); + Listener l = new Listener(); + dlg.addWindowListener(l); + f.dispose(); + waitEvents(); + + assertEquals(0, l.getCount()); + } + + /** + * Test if a dialog fire the WINDOW_CLOSED event + * on parent dispose(). + * @throws Exception + */ + public static void testVisibleChildParentDispose() throws Exception { + JFrame f = new JFrame(); + JDialog dlg = new JDialog(f); + Listener l = new Listener(); + dlg.addWindowListener(l); + dlg.setVisible(true); + f.dispose(); + waitEvents(); + + assertEquals(1, l.getCount()); + } + + /** + * Test if a Window that has never been shown fire the + * WINDOW_CLOSED event on dispose() + */ + public static void testHidenWindowDispose() throws Exception { + JFrame f = new JFrame(); + Listener l = new Listener(); + f.addWindowListener(l); + f.dispose(); + waitEvents(); + + assertEquals(0, l.getCount()); + } + + /** + * Test if a JDialog receive the correct number + * of WINDOW_CLOSED_EVENT + * @param useFrame true if use a owner frame + * @throws Exception + */ + private static void doTest(final boolean useFrame) throws Exception { + final Listener l = new Listener(); + final JFrame f = new JFrame(); + + for (int i = 0; i < N_LOOPS; i++) { + + SwingUtilities.invokeLater(new Runnable() { + + public void run() { + JDialog[] dialogs = new JDialog[N_DIALOGS]; + for (int i = 0; i < N_DIALOGS; i++) { + if (useFrame) { + dialogs[i]= new JDialog(f); + } + else { + dialogs[i] = new JDialog(); + } + + dialogs[i].addWindowListener(l); + dialogs[i].setVisible(true); + } + + // Dispose all + for (JDialog d : dialogs) + d.dispose(); + + f.dispose(); + } + }); + } + + waitEvents(); + + assertEquals(N_DIALOGS * N_LOOPS, l.getCount()); + } + + private static void waitEvents() throws InterruptedException { + // Wait until events are dispatched + while (Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent() != null) + Thread.sleep(100); + } + + /** + * @param expected the expected value + * @param real the real value + */ + private static void assertEquals(int expected, int real) throws Exception { + if (expected != real) { + throw new Exception("Expected events: " + expected + " Received Events: " + real); + } + } + +} + +/** + * Listener to count events + */ +class Listener extends WindowAdapter { + + private volatile int count = 0; + + public void windowClosed(WindowEvent e) { + count++; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} From fb8bd30b8e691f5cc1fa6860b9c7ca0d8f00e96a Mon Sep 17 00:00:00 2001 From: Anton Litvinov Date: Mon, 3 Jun 2013 16:37:13 +0400 Subject: [PATCH 128/206] 6337518: Null Arrow Button Throws Exception in BasicComboBoxUI Reviewed-by: alexp, alexsch --- .../swing/plaf/basic/BasicComboBoxUI.java | 2 +- .../swing/JComboBox/6337518/bug6337518.java | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 jdk/test/javax/swing/JComboBox/6337518/bug6337518.java diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java index b31f7606b8e..331c5674ad3 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java @@ -692,9 +692,9 @@ public class BasicComboBoxUI extends ComboBoxUI { */ protected void installComponents() { arrowButton = createArrowButton(); - comboBox.add( arrowButton ); if (arrowButton != null) { + comboBox.add(arrowButton); configureArrowButton(); } diff --git a/jdk/test/javax/swing/JComboBox/6337518/bug6337518.java b/jdk/test/javax/swing/JComboBox/6337518/bug6337518.java new file mode 100644 index 00000000000..91444692930 --- /dev/null +++ b/jdk/test/javax/swing/JComboBox/6337518/bug6337518.java @@ -0,0 +1,48 @@ +/* + * 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 6337518 + @summary Null Arrow Button Throws Exception in BasicComboBoxUI + @author Anton Litvinov +*/ + +import javax.swing.*; +import javax.swing.plaf.basic.*; + +public class bug6337518 extends BasicComboBoxUI { + @Override + protected JButton createArrowButton() { + return null; + } + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + JComboBox comboBox = new JComboBox(); + comboBox.setUI(new bug6337518()); + } + }); + } +} From 02a27e282493b9b7bf848e37d88d7fda83065677 Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Mon, 3 Jun 2013 10:00:10 -0400 Subject: [PATCH 129/206] 8015385: Remove RelaxAccessControlCheck for JDK 8 bytecodes Check bytecode versions along with RelaxAccessControlCheck version Reviewed-by: dholmes, acorn --- hotspot/src/share/vm/classfile/verifier.hpp | 4 +++- hotspot/src/share/vm/runtime/reflection.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hotspot/src/share/vm/classfile/verifier.hpp b/hotspot/src/share/vm/classfile/verifier.hpp index bfab2c83085..34a1e0b3aff 100644 --- a/hotspot/src/share/vm/classfile/verifier.hpp +++ b/hotspot/src/share/vm/classfile/verifier.hpp @@ -36,8 +36,10 @@ class Verifier : AllStatic { public: enum { + STRICTER_ACCESS_CTRL_CHECK_VERSION = 49, STACKMAP_ATTRIBUTE_MAJOR_VERSION = 50, - INVOKEDYNAMIC_MAJOR_VERSION = 51 + INVOKEDYNAMIC_MAJOR_VERSION = 51, + NO_RELAX_ACCESS_CTRL_CHECK_VERSION = 52 }; typedef enum { ThrowException, NoException } Mode; diff --git a/hotspot/src/share/vm/runtime/reflection.cpp b/hotspot/src/share/vm/runtime/reflection.cpp index 27e2048efb5..15869cc5c0e 100644 --- a/hotspot/src/share/vm/runtime/reflection.cpp +++ b/hotspot/src/share/vm/runtime/reflection.cpp @@ -44,8 +44,6 @@ #include "runtime/signature.hpp" #include "runtime/vframe.hpp" -#define JAVA_1_5_VERSION 49 - static void trace_class_resolution(Klass* to_class) { ResourceMark rm; int line_number = -1; @@ -507,9 +505,11 @@ bool Reflection::can_relax_access_check_for( under_host_klass(accessee_ik, accessor)) return true; - if (RelaxAccessControlCheck || - (accessor_ik->major_version() < JAVA_1_5_VERSION && - accessee_ik->major_version() < JAVA_1_5_VERSION)) { + if ((RelaxAccessControlCheck && + accessor_ik->major_version() < Verifier::NO_RELAX_ACCESS_CTRL_CHECK_VERSION && + accessee_ik->major_version() < Verifier::NO_RELAX_ACCESS_CTRL_CHECK_VERSION) || + (accessor_ik->major_version() < Verifier::STRICTER_ACCESS_CTRL_CHECK_VERSION && + accessee_ik->major_version() < Verifier::STRICTER_ACCESS_CTRL_CHECK_VERSION)) { return classloader_only && Verifier::relax_verify_for(accessor_ik->class_loader()) && accessor_ik->protection_domain() == accessee_ik->protection_domain() && From b73369b1fe5fcbfa84014be3657f02a7c0de49ba Mon Sep 17 00:00:00 2001 From: James Laskey Date: Mon, 3 Jun 2013 11:16:33 -0300 Subject: [PATCH 130/206] 8015796: Race condition in RuntimeCallsites Reviewed-by: lagergren, attila --- .../internal/codegen/RuntimeCallSite.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java b/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java index 1731da8ef7a..5bbec96266a 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java @@ -59,12 +59,10 @@ import jdk.nashorn.internal.lookup.MethodHandleFactory; public final class RuntimeCallSite extends MutableCallSite { static final Call BOOTSTRAP = staticCallNoLookup(Bootstrap.class, "runtimeBootstrap", CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class); - private static final MethodHandle NEXT = findOwnMH("next", MethodHandle.class); + private static final MethodHandle NEXT = findOwnMH("next", MethodHandle.class, String.class); private final RuntimeNode.Request request; - private String name; - /** * A specialized runtime node, i.e. on where we know at least one more specific type than object */ @@ -203,7 +201,6 @@ public final class RuntimeCallSite extends MutableCallSite { */ public RuntimeCallSite(final MethodType type, final String name) { super(type); - this.name = name; this.request = Request.valueOf(name.substring(0, name.indexOf(SpecializedRuntimeNode.REQUEST_SEPARATOR))); setTarget(makeMethod(name)); } @@ -292,7 +289,7 @@ public final class RuntimeCallSite extends MutableCallSite { mh = MH.explicitCastArguments(mh, type()); } - final MethodHandle fallback = MH.foldArguments(MethodHandles.exactInvoker(type()), MH.bindTo(NEXT, this)); + final MethodHandle fallback = MH.foldArguments(MethodHandles.exactInvoker(type()), MH.insertArguments(NEXT, 0, this, requestName)); MethodHandle guard; if (type().parameterType(0).isPrimitive()) { @@ -338,18 +335,12 @@ public final class RuntimeCallSite extends MutableCallSite { * * @return next wider specialization method for this RuntimeCallSite */ - public MethodHandle next() { - this.name = nextName(name); - final MethodHandle next = makeMethod(name); + public MethodHandle next(final String name) { + final MethodHandle next = makeMethod(nextName(name)); setTarget(next); return next; } - @Override - public String toString() { - return super.toString() + " " + name; - } - /** Method cache */ private static final Map METHODS; From fcf3353ddf82aa287b5c279c8c4373078541c388 Mon Sep 17 00:00:00 2001 From: James Laskey Date: Mon, 3 Jun 2013 12:57:53 -0300 Subject: [PATCH 131/206] 8015814: loadWithNewGlobal needs to wrap createGlobal in AccessController.doPrivileged Reviewed-by: sundar --- .../jdk/nashorn/internal/runtime/Context.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index 392d6f432e2..e75bb1b51e2 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -500,9 +500,21 @@ public final class Context { * * @throws IOException if source cannot be found or loaded */ - public Object loadWithNewGlobal(final Object from) throws IOException { + public Object loadWithNewGlobal(final Object from) throws IOException, RuntimeException { final ScriptObject oldGlobal = getGlobalTrusted(); - final ScriptObject newGlobal = createGlobal(); + final ScriptObject newGlobal = AccessController.doPrivileged(new PrivilegedAction() { + @Override + public ScriptObject run() { + try { + return createGlobal(); + } catch (final RuntimeException e) { + if (Context.DEBUG) { + e.printStackTrace(); + } + throw e; + } + } + }); setGlobalTrusted(newGlobal); try { From f4682b75e5b933169976fa2d06daa6fd3b95f840 Mon Sep 17 00:00:00 2001 From: Niclas Adlertz Date: Mon, 3 Jun 2013 12:39:33 -0700 Subject: [PATCH 132/206] 8005956: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block Disable re-materialization of reaching definitions (which have live inputs) for phi nodes when spilling. Reviewed-by: twisti, kvn --- hotspot/src/share/vm/opto/reg_split.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/opto/reg_split.cpp b/hotspot/src/share/vm/opto/reg_split.cpp index edd614987ea..30ac26ba989 100644 --- a/hotspot/src/share/vm/opto/reg_split.cpp +++ b/hotspot/src/share/vm/opto/reg_split.cpp @@ -51,6 +51,15 @@ static const char out_of_nodes[] = "out of nodes during split"; +static bool contains_no_live_range_input(const Node* def) { + for (uint i = 1; i < def->req(); ++i) { + if (def->in(i) != NULL && def->in_RegMask(i).is_NotEmpty()) { + return false; + } + } + return true; +} + //------------------------------get_spillcopy_wide----------------------------- // Get a SpillCopy node with wide-enough masks. Use the 'wide-mask', the // wide ideal-register spill-mask if possible. If the 'wide-mask' does @@ -1312,7 +1321,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { Node *def = Reaches[pidx][slidx]; assert( def, "must have reaching def" ); // If input up/down sense and reg-pressure DISagree - if( def->rematerialize() ) { + if (def->rematerialize() && contains_no_live_range_input(def)) { // Place the rematerialized node above any MSCs created during // phi node splitting. end_idx points at the insertion point // so look at the node before it. From 6d485348e1a1c473ff15c5e6eca21da52d22c6f3 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Mon, 3 Jun 2013 14:28:37 -0700 Subject: [PATCH 133/206] 8014052: JSR292: assert(end_offset == next_offset) failed: matched ending A call to the finalize_operands_merge() must be unconditional Reviewed-by: kvn, twisti --- hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp index c5715345f72..e9279697262 100644 --- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp @@ -1349,12 +1349,11 @@ bool VM_RedefineClasses::merge_constant_pools(constantPoolHandle old_cp, CHECK_0); } - finalize_operands_merge(*merge_cp_p, THREAD); - RC_TRACE_WITH_THREAD(0x00020000, THREAD, ("after pass 1b: merge_cp_len=%d, scratch_i=%d, index_map_len=%d", *merge_cp_length_p, scratch_i, _index_map_count)); } + finalize_operands_merge(*merge_cp_p, THREAD); return true; } // end merge_constant_pools() From 07ed2c141fa474009bdba683b4dc680c71e691e2 Mon Sep 17 00:00:00 2001 From: Tao Mao Date: Mon, 3 Jun 2013 14:37:13 -0700 Subject: [PATCH 134/206] 6976350: G1: deal with fragmentation while copying objects during GC Create G1ParGCAllocBufferContainer to contain two buffers instead of previously using one buffer, in order to hold the first priority buffer longer. Thus, when some large objects hits the value of free space left in the first priority buffer it has an alternative to fit in the second priority buffer while the first priority buffer is given more chances to try allocating smaller objects. Overall, it will improve heap space efficiency. Reviewed-by: johnc, jmasa, brutisso --- .../gc_implementation/g1/g1CollectedHeap.hpp | 113 +++++++++++++++--- .../shared/parGCAllocBuffer.hpp | 2 +- 2 files changed, 98 insertions(+), 17 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index 1b817a9da2d..3f22247e8e1 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -593,11 +593,6 @@ protected: // may not be a humongous - it must fit into a single heap region. HeapWord* par_allocate_during_gc(GCAllocPurpose purpose, size_t word_size); - HeapWord* allocate_during_gc_slow(GCAllocPurpose purpose, - HeapRegion* alloc_region, - bool par, - size_t word_size); - // Ensure that no further allocations can happen in "r", bearing in mind // that parallel threads might be attempting allocations. void par_allocate_remaining_space(HeapRegion* r); @@ -1733,6 +1728,95 @@ public: ParGCAllocBuffer::retire(end_of_gc, retain); _retired = true; } + + bool is_retired() { + return _retired; + } +}; + +class G1ParGCAllocBufferContainer { +protected: + static int const _priority_max = 2; + G1ParGCAllocBuffer* _priority_buffer[_priority_max]; + +public: + G1ParGCAllocBufferContainer(size_t gclab_word_size) { + for (int pr = 0; pr < _priority_max; ++pr) { + _priority_buffer[pr] = new G1ParGCAllocBuffer(gclab_word_size); + } + } + + ~G1ParGCAllocBufferContainer() { + for (int pr = 0; pr < _priority_max; ++pr) { + assert(_priority_buffer[pr]->is_retired(), "alloc buffers should all retire at this point."); + delete _priority_buffer[pr]; + } + } + + HeapWord* allocate(size_t word_sz) { + HeapWord* obj; + for (int pr = 0; pr < _priority_max; ++pr) { + obj = _priority_buffer[pr]->allocate(word_sz); + if (obj != NULL) return obj; + } + return obj; + } + + bool contains(void* addr) { + for (int pr = 0; pr < _priority_max; ++pr) { + if (_priority_buffer[pr]->contains(addr)) return true; + } + return false; + } + + void undo_allocation(HeapWord* obj, size_t word_sz) { + bool finish_undo; + for (int pr = 0; pr < _priority_max; ++pr) { + if (_priority_buffer[pr]->contains(obj)) { + _priority_buffer[pr]->undo_allocation(obj, word_sz); + finish_undo = true; + } + } + if (!finish_undo) ShouldNotReachHere(); + } + + size_t words_remaining() { + size_t result = 0; + for (int pr = 0; pr < _priority_max; ++pr) { + result += _priority_buffer[pr]->words_remaining(); + } + return result; + } + + size_t words_remaining_in_retired_buffer() { + G1ParGCAllocBuffer* retired = _priority_buffer[0]; + return retired->words_remaining(); + } + + void flush_stats_and_retire(PLABStats* stats, bool end_of_gc, bool retain) { + for (int pr = 0; pr < _priority_max; ++pr) { + _priority_buffer[pr]->flush_stats_and_retire(stats, end_of_gc, retain); + } + } + + void update(bool end_of_gc, bool retain, HeapWord* buf, size_t word_sz) { + G1ParGCAllocBuffer* retired_and_set = _priority_buffer[0]; + retired_and_set->retire(end_of_gc, retain); + retired_and_set->set_buf(buf); + retired_and_set->set_word_size(word_sz); + adjust_priority_order(); + } + +private: + void adjust_priority_order() { + G1ParGCAllocBuffer* retired_and_set = _priority_buffer[0]; + + int last = _priority_max - 1; + for (int pr = 0; pr < last; ++pr) { + _priority_buffer[pr] = _priority_buffer[pr + 1]; + } + _priority_buffer[last] = retired_and_set; + } }; class G1ParScanThreadState : public StackObj { @@ -1743,9 +1827,9 @@ protected: CardTableModRefBS* _ct_bs; G1RemSet* _g1_rem; - G1ParGCAllocBuffer _surviving_alloc_buffer; - G1ParGCAllocBuffer _tenured_alloc_buffer; - G1ParGCAllocBuffer* _alloc_buffers[GCAllocPurposeCount]; + G1ParGCAllocBufferContainer _surviving_alloc_buffer; + G1ParGCAllocBufferContainer _tenured_alloc_buffer; + G1ParGCAllocBufferContainer* _alloc_buffers[GCAllocPurposeCount]; ageTable _age_table; size_t _alloc_buffer_waste; @@ -1809,7 +1893,7 @@ public: RefToScanQueue* refs() { return _refs; } ageTable* age_table() { return &_age_table; } - G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) { + G1ParGCAllocBufferContainer* alloc_buffer(GCAllocPurpose purpose) { return _alloc_buffers[purpose]; } @@ -1839,15 +1923,13 @@ public: HeapWord* obj = NULL; size_t gclab_word_size = _g1h->desired_plab_sz(purpose); if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { - G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose); - add_to_alloc_buffer_waste(alloc_buf->words_remaining()); - alloc_buf->retire(false /* end_of_gc */, false /* retain */); + G1ParGCAllocBufferContainer* alloc_buf = alloc_buffer(purpose); HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size); if (buf == NULL) return NULL; // Let caller handle allocation failure. - // Otherwise. - alloc_buf->set_word_size(gclab_word_size); - alloc_buf->set_buf(buf); + + add_to_alloc_buffer_waste(alloc_buf->words_remaining_in_retired_buffer()); + alloc_buf->update(false /* end_of_gc */, false /* retain */, buf, gclab_word_size); obj = alloc_buf->allocate(word_sz); assert(obj != NULL, "buffer was definitely big enough..."); @@ -1959,7 +2041,6 @@ public: } } -public: void trim_queue(); }; diff --git a/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp b/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp index 0666353aa59..aced447c9a1 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp @@ -158,7 +158,7 @@ public: // Fills in the unallocated portion of the buffer with a garbage object. // If "end_of_gc" is TRUE, is after the last use in the GC. IF "retain" // is true, attempt to re-use the unused portion in the next GC. - void retire(bool end_of_gc, bool retain); + virtual void retire(bool end_of_gc, bool retain); void print() PRODUCT_RETURN; }; From c594d824a49d2093909de20ed6f7b9fc52296f3b Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Mon, 3 Jun 2013 16:22:27 -0700 Subject: [PATCH 135/206] 8013405: DocLint should support
  • Reviewed-by: ksrini --- .../com/sun/tools/doclint/Checker.java | 13 ++++++++ .../com/sun/tools/doclint/HtmlTag.java | 4 ++- .../doclint/resources/doclint.properties | 1 + .../test/tools/doclint/html/ListTagsTest.java | 32 ++++--------------- .../test/tools/doclint/html/ListTagsTest.out | 7 ++++ 5 files changed, 30 insertions(+), 27 deletions(-) create mode 100644 langtools/test/tools/doclint/html/ListTagsTest.out diff --git a/langtools/src/share/classes/com/sun/tools/doclint/Checker.java b/langtools/src/share/classes/com/sun/tools/doclint/Checker.java index 701813dfae1..d7b185900ba 100644 --- a/langtools/src/share/classes/com/sun/tools/doclint/Checker.java +++ b/langtools/src/share/classes/com/sun/tools/doclint/Checker.java @@ -531,6 +531,17 @@ public class Checker extends DocTreePathScanner { } } break; + + case VALUE: + if (currTag == HtmlTag.LI) { + String v = getAttrValue(tree); + if (v == null || v.isEmpty()) { + env.messages.error(HTML, tree, "dc.attr.lacks.value"); + } else if (!validNumber.matcher(v).matches()) { + env.messages.error(HTML, tree, "dc.attr.not.number"); + } + } + break; } } } @@ -543,6 +554,8 @@ public class Checker extends DocTreePathScanner { // http://www.w3.org/TR/html401/types.html#type-name private static final Pattern validName = Pattern.compile("[A-Za-z][A-Za-z0-9-_:.]*"); + private static final Pattern validNumber = Pattern.compile("-?[0-9]+"); + // pattern to remove leading {@docRoot}/? private static final Pattern docRoot = Pattern.compile("(?i)(\\{@docRoot *\\}/?)?(.*)"); diff --git a/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java b/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java index 058c65c01e8..04753149340 100644 --- a/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java +++ b/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java @@ -131,7 +131,8 @@ public enum HtmlTag { attrs(AttrKind.USE_CSS, ALIGN, HSPACE, VSPACE, BORDER)), LI(BlockType.LIST_ITEM, EndKind.OPTIONAL, - EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)), + EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE), + attrs(AttrKind.OK, VALUE)), LINK(BlockType.OTHER, EndKind.NONE), @@ -339,6 +340,7 @@ public enum HtmlTag { TARGET, TYPE, VALIGN, + VALUE, VSPACE, WIDTH; diff --git a/langtools/src/share/classes/com/sun/tools/doclint/resources/doclint.properties b/langtools/src/share/classes/com/sun/tools/doclint/resources/doclint.properties index f71dbe0f5b1..960ec65cd24 100644 --- a/langtools/src/share/classes/com/sun/tools/doclint/resources/doclint.properties +++ b/langtools/src/share/classes/com/sun/tools/doclint/resources/doclint.properties @@ -26,6 +26,7 @@ dc.anchor.already.defined = anchor already defined: {0} dc.anchor.value.missing = no value given for anchor dc.attr.lacks.value = attribute lacks value +dc.attr.not.number = attribute value is not a number dc.attr.obsolete = attribute obsolete: {0} dc.attr.obsolete.use.css = attribute obsolete, use CSS instead: {0} dc.attr.repeated = repeated attribute: {0} diff --git a/langtools/test/tools/doclint/html/ListTagsTest.java b/langtools/test/tools/doclint/html/ListTagsTest.java index c7d2080611c..571c8f9e6f6 100644 --- a/langtools/test/tools/doclint/html/ListTagsTest.java +++ b/langtools/test/tools/doclint/html/ListTagsTest.java @@ -1,33 +1,10 @@ /* - * 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 8006251 + * @test /nodynamiccopyright/ + * @bug 8006251 8013405 * @summary test list tags * @library .. * @build DocLintTester - * @run main DocLintTester -Xmsgs ListTagsTest.java + * @run main DocLintTester -Xmsgs -ref ListTagsTest.out ListTagsTest.java */ /** */ @@ -35,6 +12,9 @@ public class ListTagsTest { /** *
    abc
    def
    *
    1. abc
    + *
    1. abc
    + *
    1. bad
    + *
    1. bad
    *
    • abc
    */ public void supportedTags() { } diff --git a/langtools/test/tools/doclint/html/ListTagsTest.out b/langtools/test/tools/doclint/html/ListTagsTest.out new file mode 100644 index 00000000000..2b619198f83 --- /dev/null +++ b/langtools/test/tools/doclint/html/ListTagsTest.out @@ -0,0 +1,7 @@ +ListTagsTest.java:16: error: attribute lacks value + *
    1. bad
    + ^ +ListTagsTest.java:17: error: attribute value is not a number + *
    1. bad
    + ^ +2 errors From a850ba134de0c17726ffb3b511c8a6abe2917ce6 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Mon, 3 Jun 2013 17:09:26 -0700 Subject: [PATCH 136/206] 8006615: [doclint] move remaining messages into resource bundle Reviewed-by: mcimadamore, vromero --- .../com/sun/tools/doclint/DocLint.java | 61 ++++---------- .../doclint/resources/doclint.properties | 47 +++++++++++ .../test/tools/doclint/ResourceTest.java | 81 +++++++++++++++++++ .../test/tools/doclint/tool/RunTest.java | 2 +- 4 files changed, 143 insertions(+), 48 deletions(-) create mode 100644 langtools/test/tools/doclint/ResourceTest.java diff --git a/langtools/src/share/classes/com/sun/tools/doclint/DocLint.java b/langtools/src/share/classes/com/sun/tools/doclint/DocLint.java index 8b4e7404ddc..c1d8d994316 100644 --- a/langtools/src/share/classes/com/sun/tools/doclint/DocLint.java +++ b/langtools/src/share/classes/com/sun/tools/doclint/DocLint.java @@ -77,13 +77,14 @@ public class DocLint implements Plugin { // public static void main(String... args) { + DocLint dl = new DocLint(); try { - new DocLint().run(args); + dl.run(args); } catch (BadArgs e) { System.err.println(e.getMessage()); System.exit(1); } catch (IOException e) { - System.err.println(e); + System.err.println(dl.localize("dc.main.ioerror", e.getLocalizedMessage())); System.exit(2); } } @@ -92,9 +93,10 @@ public class DocLint implements Plugin { // - public static class BadArgs extends Exception { + public class BadArgs extends Exception { private static final long serialVersionUID = 0; BadArgs(String code, Object... args) { + super(localize(code, args)); this.code = code; this.args = args; } @@ -124,7 +126,7 @@ public class DocLint implements Plugin { if (javacFiles.isEmpty()) { if (!needHelp) - out.println("no files given"); + out.println(localize("dc.main.no.files.given")); } JavacTool tool = JavacTool.create(); @@ -204,49 +206,9 @@ public class DocLint implements Plugin { } void showHelp(PrintWriter out) { - out.println("Usage:"); - out.println(" doclint [options] source-files..."); - out.println(""); - out.println("Options:"); - out.println(" -Xmsgs "); - out.println(" Same as -Xmsgs:all"); - out.println(" -Xmsgs:values"); - out.println(" Specify categories of issues to be checked, where 'values'"); - out.println(" is a comma-separated list of any of the following:"); - out.println(" reference show places where comments contain incorrect"); - out.println(" references to Java source code elements"); - out.println(" syntax show basic syntax errors within comments"); - out.println(" html show issues with HTML tags and attributes"); - out.println(" accessibility show issues for accessibility"); - out.println(" missing show issues with missing documentation"); - out.println(" all all of the above"); - out.println(" Precede a value with '-' to negate it"); - out.println(" Categories may be qualified by one of:"); - out.println(" /public /protected /package /private"); - out.println(" For positive categories (not beginning with '-')"); - out.println(" the qualifier applies to that access level and above."); - out.println(" For negative categories (beginning with '-')"); - out.println(" the qualifier applies to that access level and below."); - out.println(" If a qualifier is missing, the category applies to"); - out.println(" all access levels."); - out.println(" For example, -Xmsgs:all,-syntax/private"); - out.println(" This will enable all messages, except syntax errors"); - out.println(" in the doc comments of private methods."); - out.println(" If no -Xmsgs options are provided, the default is"); - out.println(" equivalent to -Xmsgs:all/protected, meaning that"); - out.println(" all messages are reported for protected and public"); - out.println(" declarations only. "); - out.println(" -stats"); - out.println(" Report statistics on the reported issues."); - out.println(" -h -help --help -usage -?"); - out.println(" Show this message."); - out.println(""); - out.println("The following javac options are also supported"); - out.println(" -bootclasspath, -classpath, -sourcepath, -Xmaxerrs, -Xmaxwarns"); - out.println(""); - out.println("To run doclint on part of a project, put the compiled classes for your"); - out.println("project on the classpath (or bootclasspath), then specify the source files"); - out.println("to be checked on the command line."); + String msg = localize("dc.main.usage"); + for (String line: msg.split("\n")) + out.println(line); } List splitPath(String path) { @@ -353,6 +315,11 @@ public class DocLint implements Plugin { return false; } + private String localize(String code, Object... args) { + Messages m = (env != null) ? env.messages : new Messages(null); + return m.localize(code, args); + } + // static abstract class DeclScanner extends TreePathScanner { diff --git a/langtools/src/share/classes/com/sun/tools/doclint/resources/doclint.properties b/langtools/src/share/classes/com/sun/tools/doclint/resources/doclint.properties index 960ec65cd24..995cb335087 100644 --- a/langtools/src/share/classes/com/sun/tools/doclint/resources/doclint.properties +++ b/langtools/src/share/classes/com/sun/tools/doclint/resources/doclint.properties @@ -67,3 +67,50 @@ dc.tag.self.closing = self-closing element not allowed dc.tag.start.unmatched = end tag missing: dc.tag.unknown = unknown tag: {0} dc.text.not.allowed = text not allowed in <{0}> element + +dc.main.ioerror=IO error: {0} +dc.main.no.files.given=No files given +dc.main.usage=\ +Usage:\n\ +\ doclint [options] source-files...\n\ +\n\ +Options:\n\ +\ -Xmsgs \n\ +\ Same as -Xmsgs:all\n\ +\ -Xmsgs:values\n\ +\ Specify categories of issues to be checked, where ''values''\n\ +\ is a comma-separated list of any of the following:\n\ +\ reference show places where comments contain incorrect\n\ +\ references to Java source code elements\n\ +\ syntax show basic syntax errors within comments\n\ +\ html show issues with HTML tags and attributes\n\ +\ accessibility show issues for accessibility\n\ +\ missing show issues with missing documentation\n\ +\ all all of the above\n\ +\ Precede a value with ''-'' to negate it\n\ +\ Categories may be qualified by one of:\n\ +\ /public /protected /package /private\n\ +\ For positive categories (not beginning with ''-'')\n\ +\ the qualifier applies to that access level and above.\n\ +\ For negative categories (beginning with ''-'')\n\ +\ the qualifier applies to that access level and below.\n\ +\ If a qualifier is missing, the category applies to\n\ +\ all access levels.\n\ +\ For example, -Xmsgs:all,-syntax/private\n\ +\ This will enable all messages, except syntax errors\n\ +\ in the doc comments of private methods.\n\ +\ If no -Xmsgs options are provided, the default is\n\ +\ equivalent to -Xmsgs:all/protected, meaning that\n\ +\ all messages are reported for protected and public\n\ +\ declarations only. \n\ +\ -stats\n\ +\ Report statistics on the reported issues.\n\ +\ -h -help --help -usage -?\n\ +\ Show this message.\n\ +\n\ +The following javac options are also supported\n\ +\ -bootclasspath, -classpath, -sourcepath, -Xmaxerrs, -Xmaxwarns\n\ +\n\ +To run doclint on part of a project, put the compiled classes for your\n\ +project on the classpath (or bootclasspath), then specify the source files\n\ +to be checked on the command line. diff --git a/langtools/test/tools/doclint/ResourceTest.java b/langtools/test/tools/doclint/ResourceTest.java new file mode 100644 index 00000000000..46f79adb775 --- /dev/null +++ b/langtools/test/tools/doclint/ResourceTest.java @@ -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. + */ + +/* + * @test + * @bug 8006615 + * @summary move remaining messages into resource bundle + */ + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + +import com.sun.tools.doclint.DocLint; + +public class ResourceTest { + public static void main(String... args) throws Exception { + Locale prev = Locale.getDefault(); + Locale.setDefault(Locale.ENGLISH); + try { + new ResourceTest().run(); + } finally { + Locale.setDefault(prev); + } + } + + public void run() throws Exception { + test(Arrays.asList("-help"), + Arrays.asList("Usage:", "Options")); + test(Arrays.asList("-foo"), + Arrays.asList("bad option: -foo")); + } + + void test(List opts, List expects) throws Exception { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + try { + new DocLint().run(pw, opts.toArray(new String[opts.size()])); + } catch (DocLint.BadArgs e) { + pw.println("BadArgs: " + e.getMessage()); + } catch (IOException e) { + pw.println("IOException: " + e.getMessage()); + } finally { + pw.close(); + } + + String out = sw.toString(); + if (!out.isEmpty()) { + System.err.println(out); + } + + for (String e: expects) { + if (!out.contains(e)) + throw new Exception("expected string not found: " + e); + } + } +} + diff --git a/langtools/test/tools/doclint/tool/RunTest.java b/langtools/test/tools/doclint/tool/RunTest.java index e7dfa2da78e..5f357f06f3a 100644 --- a/langtools/test/tools/doclint/tool/RunTest.java +++ b/langtools/test/tools/doclint/tool/RunTest.java @@ -173,7 +173,7 @@ public class RunTest { pw.close(); String out = sw.toString(); - String expect = "no files given"; + String expect = "No files given"; if (!Objects.equals(out.trim(), expect)) { error("unexpected output"); System.err.println("EXPECT>>" + expect + "<<"); From a282ed392389297604b27379fa15d1f495cbb711 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Mon, 3 Jun 2013 17:24:47 -0700 Subject: [PATCH 137/206] 8007687: javadoc -X does not include -Xdoclint Reviewed-by: darcy --- .../formats/html/ConfigurationImpl.java | 11 +++ .../html/resources/standard.properties | 85 ++++++++++--------- .../tools/javac/resources/javac.properties | 10 ++- .../classes/com/sun/tools/javadoc/Start.java | 46 +++++----- .../javadoc/resources/javadoc.properties | 60 +++++++------ .../testHelpOption/TestHelpOption.java | 3 +- .../sun/javadoc/testXOption/TestXOption.java | 85 +++++++++++++++++++ 7 files changed, 206 insertions(+), 94 deletions(-) create mode 100644 langtools/test/com/sun/javadoc/testXOption/TestXOption.java diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java index 2b37dd66481..5d84c8064db 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java @@ -324,8 +324,19 @@ public class ConfigurationImpl extends Configuration { option.startsWith("-xdoclint:")) { return 1; } else if (option.equals("-help")) { + // Uugh: first, this should not be hidden inside optionLength, + // and second, we should not be writing directly to stdout. + // But we have no access to a DocErrorReporter, which would + // allow use of reporter.printNotice System.out.println(getText("doclet.usage")); return 1; + } else if (option.equals("-x")) { + // Uugh: first, this should not be hidden inside optionLength, + // and second, we should not be writing directly to stdout. + // But we have no access to a DocErrorReporter, which would + // allow use of reporter.printNotice + System.out.println(getText("doclet.X.usage")); + return 1; } else if (option.equals("-footer") || option.equals("-header") || option.equals("-packagesheader") || diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties index f288579d392..9951877f8bc 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties @@ -186,45 +186,50 @@ doclet.Groupname_already_used=In -group option, groupname already used: {0} doclet.Same_package_name_used=Package name format used twice: {0} doclet.exception_encountered=Exception encountered while processing {1}\n{0} doclet.usage=Provided by Standard doclet:\n\ - -d Destination directory for output files\n\ - -use Create class and package usage pages\n\ - -version Include @version paragraphs\n\ - -author Include @author paragraphs\n\ - -docfilessubdirs Recursively copy doc-file subdirectories\n\ - -splitindex Split index into one file per letter\n\ - -windowtitle Browser window title for the documenation\n\ - -doctitle Include title for the overview page\n\ - -header Include header text for each page\n\ - -footer Include footer text for each page\n\ - -top Include top text for each page\n\ - -bottom Include bottom text for each page\n\ - -link Create links to javadoc output at \n\ - -linkoffline Link to docs at using package list at \n\ - -excludedocfilessubdir :.. Exclude any doc-files subdirectories with given name.\n\ - -group :.. Group specified packages together in overview page\n\ - -nocomment Supress description and tags, generate only declarations.\n\ - -nodeprecated Do not include @deprecated information\n\ - -noqualifier ::... Exclude the list of qualifiers from the output.\n\ - -nosince Do not include @since information\n\ - -notimestamp Do not include hidden time stamp\n\ - -nodeprecatedlist Do not generate deprecated list\n\ - -notree Do not generate class hierarchy\n\ - -noindex Do not generate index\n\ - -nohelp Do not generate help link\n\ - -nonavbar Do not generate navigation bar\n\ - -serialwarn Generate warning about @serial tag\n\ - -tag ::
    Specify single argument custom tags\n\ - -taglet The fully qualified name of Taglet to register\n\ - -tagletpath The path to Taglets\n\ - -Xdocrootparent Replaces all appearances of @docRoot followed by /.. in doc comments with \n\ - -charset Charset for cross-platform viewing of generated documentation.\n\ - -helpfile Include file that help link links to\n\ - -linksource Generate source in HTML\n\ - -sourcetab Specify the number of spaces each tab takes up in the source\n\ - -keywords Include HTML meta tags with package, class and member info\n\ - -stylesheetfile File to change style of the generated documentation\n\ - -docencoding Output encoding name - - +\ -d Destination directory for output files\n\ +\ -use Create class and package usage pages\n\ +\ -version Include @version paragraphs\n\ +\ -author Include @author paragraphs\n\ +\ -docfilessubdirs Recursively copy doc-file subdirectories\n\ +\ -splitindex Split index into one file per letter\n\ +\ -windowtitle Browser window title for the documentation\n\ +\ -doctitle Include title for the overview page\n\ +\ -header Include header text for each page\n\ +\ -footer Include footer text for each page\n\ +\ -top Include top text for each page\n\ +\ -bottom Include bottom text for each page\n\ +\ -link Create links to javadoc output at \n\ +\ -linkoffline Link to docs at using package list at \n\ +\ -excludedocfilessubdir :.. Exclude any doc-files subdirectories with given name.\n\ +\ -group :.. Group specified packages together in overview page\n\ +\ -nocomment Suppress description and tags, generate only declarations.\n\ +\ -nodeprecated Do not include @deprecated information\n\ +\ -noqualifier ::... Exclude the list of qualifiers from the output.\n\ +\ -nosince Do not include @since information\n\ +\ -notimestamp Do not include hidden time stamp\n\ +\ -nodeprecatedlist Do not generate deprecated list\n\ +\ -notree Do not generate class hierarchy\n\ +\ -noindex Do not generate index\n\ +\ -nohelp Do not generate help link\n\ +\ -nonavbar Do not generate navigation bar\n\ +\ -serialwarn Generate warning about @serial tag\n\ +\ -tag ::
    Specify single argument custom tags\n\ +\ -taglet The fully qualified name of Taglet to register\n\ +\ -tagletpath The path to Taglets\n\ +\ -charset Charset for cross-platform viewing of generated documentation.\n\ +\ -helpfile Include file that help link links to\n\ +\ -linksource Generate source in HTML\n\ +\ -sourcetab Specify the number of spaces each tab takes up in the source\n\ +\ -keywords Include HTML meta tags with package, class and member info\n\ +\ -stylesheetfile File to change style of the generated documentation\n\ +\ -docencoding Specify the character encoding for the output +# L10N: do not localize these words: all none accessibility html missing reference syntax +doclet.X.usage=Provided by standard doclet:\n\ +\ -Xdocrootparent Replaces all appearances of @docRoot followed\n\ +\ by /.. in doc comments with \n\ +\ -Xdoclint Enable recommended checks for problems in javadoc comments\n\ +\ -Xdoclint:(all|none|[-]) \n\ +\ Enable or disable specific checks for problems in javadoc comments,\n\ +\ where is one of accessibility, html, missing, reference, or syntax.\n diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties index caf67462a82..f32c2291748 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties @@ -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 @@ -146,11 +146,15 @@ javac.opt.Xlint.suboptlist=\ Enable or disable specific warnings javac.opt.Xdoclint=\ Enable recommended checks for problems in javadoc comments +# L10N: do not localize: all none javac.opt.Xdoclint.subopts = \ - (all|[-])[/] + (all|none|[-])[/] + +# L10N: do not localize: accessibility html missing reference syntax +# L10N: do not localize: public protected package private javac.opt.Xdoclint.custom=\n\ \ Enable or disable specific checks for problems in javadoc comments,\n\ -\ where is one of accessibility, html, reference, or syntax,\n\ +\ where is one of accessibility, html, missing, reference, or syntax,\n\ \ and is one of public, protected, package, or private. javac.opt.Xstdout=\ Redirect standard output diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/Start.java b/langtools/src/share/classes/com/sun/tools/javadoc/Start.java index 4efb9324e26..7cee9aa26e3 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/Start.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/Start.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -156,21 +156,8 @@ public class Start extends ToolOption.Helper { usage(true); } - - /** - * Usage - */ - private void usage(boolean exit) { - // RFE: it would be better to replace the following with code to - // write a header, then help for each option, then a footer. - messager.notice("main.usage"); - - // let doclet print usage information (does nothing on error) - if (docletInvoker != null) { - docletInvoker.optionLength("-help"); - } - - if (exit) exit(); + void usage(boolean exit) { + usage("main.usage", "-help", null, exit); } @Override @@ -178,11 +165,28 @@ public class Start extends ToolOption.Helper { Xusage(true); } - /** - * Usage - */ - private void Xusage(boolean exit) { - messager.notice("main.Xusage"); + void Xusage(boolean exit) { + usage("main.Xusage", "-X", "main.Xusage.foot", exit); + } + + private void usage(String main, String doclet, String foot, boolean exit) { + // RFE: it would be better to replace the following with code to + // write a header, then help for each option, then a footer. + messager.notice(main); + + // let doclet print usage information (does nothing on error) + if (docletInvoker != null) { + // RFE: this is a pretty bad way to get the doclet to show + // help info. Moreover, the output appears on stdout, + // and not on any of the standard streams passed + // to javadoc, and in particular, not to the noticeWriter + // But, to fix this, we need to fix the Doclet API. + docletInvoker.optionLength(doclet); + } + + if (foot != null) + messager.notice(foot); + if (exit) exit(); } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties b/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties index 4189f6ba7e7..3e384a165de 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties +++ b/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 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 @@ -27,35 +27,39 @@ main.errors={0} errors main.error={0} error main.warnings={0} warnings main.warning={0} warning -main.usage=usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\ - -overview Read overview documentation from HTML file\n\ - -public Show only public classes and members\n\ - -protected Show protected/public classes and members (default)\n\ - -package Show package/protected/public classes and members\n\ - -private Show all classes and members\n\ - -help Display command line options and exit\n\ - -doclet Generate output via alternate doclet\n\ - -docletpath Specify where to find doclet class files\n\ - -sourcepath Specify where to find source files\n\ - -classpath Specify where to find user class files\n\ - -exclude Specify a list of packages to exclude\n\ - -subpackages Specify subpackages to recursively load\n\ - -breakiterator Compute 1st sentence with BreakIterator\n\ - -bootclasspath Override location of class files loaded\n\ -\t\t\t by the bootstrap class loader\n\ - -source Provide source compatibility with specified release\n\ - -extdirs Override location of installed extensions\n\ - -verbose Output messages about what Javadoc is doing\n\ - -locale Locale to be used, e.g. en_US or en_US_WIN\n\ - -encoding Source file encoding name\n\ - -quiet Do not display status messages\n\ - -J Pass directly to the runtime system\n\ - -X Print a synopsis of nonstandard options\n + +main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\ +\ -overview Read overview documentation from HTML file\n\ +\ -public Show only public classes and members\n\ +\ -protected Show protected/public classes and members (default)\n\ +\ -package Show package/protected/public classes and members\n\ +\ -private Show all classes and members\n\ +\ -help Display command line options and exit\n\ +\ -doclet Generate output via alternate doclet\n\ +\ -docletpath Specify where to find doclet class files\n\ +\ -sourcepath Specify where to find source files\n\ +\ -classpath Specify where to find user class files\n\ +\ -exclude Specify a list of packages to exclude\n\ +\ -subpackages Specify subpackages to recursively load\n\ +\ -breakiterator Compute first sentence with BreakIterator\n\ +\ -bootclasspath Override location of class files loaded\n\ +\ by the bootstrap class loader\n\ +\ -source Provide source compatibility with specified release\n\ +\ -extdirs Override location of installed extensions\n\ +\ -verbose Output messages about what Javadoc is doing\n\ +\ -locale Locale to be used, e.g. en_US or en_US_WIN\n\ +\ -encoding Source file encoding name\n\ +\ -quiet Do not display status messages\n\ +\ -J Pass directly to the runtime system\n\ +\ -X Print a synopsis of nonstandard options and exit\n + main.Xusage=\ - -Xmaxerrs Set the maximum number of errors to print\n\ - -Xmaxwarns Set the maximum number of warnings to print\n\ -\n\ +\ -Xmaxerrs Set the maximum number of errors to print\n\ +\ -Xmaxwarns Set the maximum number of warnings to print\n + +main.Xusage.foot=\ These options are non-standard and subject to change without notice. + main.option.already.seen=The {0} option may be specified no more than once. main.requires_argument=option {0} requires an argument. main.locale_first=option -locale must be first on the command line. diff --git a/langtools/test/com/sun/javadoc/testHelpOption/TestHelpOption.java b/langtools/test/com/sun/javadoc/testHelpOption/TestHelpOption.java index f817596a4fb..e85ffd73339 100644 --- a/langtools/test/com/sun/javadoc/testHelpOption/TestHelpOption.java +++ b/langtools/test/com/sun/javadoc/testHelpOption/TestHelpOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, 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 @@ -78,7 +78,6 @@ public class TestHelpOption extends JavadocTester { {STANDARD_OUTPUT, "-tag "}, {STANDARD_OUTPUT, "-taglet "}, {STANDARD_OUTPUT, "-tagletpath "}, - {STANDARD_OUTPUT, "-Xdocrootparent "}, {STANDARD_OUTPUT, "-charset "}, {STANDARD_OUTPUT, "-helpfile "}, {STANDARD_OUTPUT, "-linksource "}, diff --git a/langtools/test/com/sun/javadoc/testXOption/TestXOption.java b/langtools/test/com/sun/javadoc/testXOption/TestXOption.java new file mode 100644 index 00000000000..c66c84d2334 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testXOption/TestXOption.java @@ -0,0 +1,85 @@ +/* + * 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 + * 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 8007687 + * @summary Make sure that the -X option works properly. + * @library ../lib/ + * @build JavadocTester TestXOption + * @run main TestXOption + */ + +public class TestXOption extends JavadocTester { + + //Test information. + private static final String BUG_ID = "8007687"; + + //Javadoc arguments. + private static final String[] ARGS = new String[] { + "-d", BUG_ID, "-sourcepath", SRC_DIR, "-X", + SRC_DIR + FS + "TestXOption.java" + }; + + private static final String[] ARGS2 = new String[] { + "-d", BUG_ID, "-sourcepath", SRC_DIR, + SRC_DIR + FS + "TestXOption.java" + }; + + private static final String[][] TEST = { + {NOTICE_OUTPUT, "-Xmaxerrs "}, + {NOTICE_OUTPUT, "-Xmaxwarns "}, + {STANDARD_OUTPUT, "-Xdocrootparent "}, + {STANDARD_OUTPUT, "-Xdoclint "}, + {STANDARD_OUTPUT, "-Xdoclint:"}, + }; + private static final String[][] NEGATED_TEST = NO_TEST; + + //The help option should not crash the doclet. + private static final int EXPECTED_EXIT_CODE = 0; + + /** + * The entry point of the test. + * @param args the array of command line arguments. + */ + public static void main(String[] args) { + TestXOption tester = new TestXOption(); + int actualExitCode = run(tester, ARGS, TEST, NEGATED_TEST); + tester.checkExitCode(EXPECTED_EXIT_CODE, actualExitCode); + tester.printSummary(); + } + + /** + * {@inheritDoc} + */ + public String getBugId() { + return BUG_ID; + } + + /** + * {@inheritDoc} + */ + public String getBugName() { + return getClass().getName(); + } +} From e609456b0e70b134ee34ec9541e1ef2dc8e69bfb Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Tue, 4 Jun 2013 01:06:50 -0700 Subject: [PATCH 138/206] 8015803: Test8015436.java fails 'can not access a member of class Test8015436 with modifiers "public static"' Newly added test has an issue: the main class must be public Reviewed-by: kvn, jbachorik, coleenp --- hotspot/test/compiler/8015436/Test8015436.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/test/compiler/8015436/Test8015436.java b/hotspot/test/compiler/8015436/Test8015436.java index 5037a7a73af..268e04acbe7 100644 --- a/hotspot/test/compiler/8015436/Test8015436.java +++ b/hotspot/test/compiler/8015436/Test8015436.java @@ -48,7 +48,7 @@ interface InterfaceWithDefaultMethod { } } -class Test8015436 implements InterfaceWithDefaultMethod { +public class Test8015436 implements InterfaceWithDefaultMethod { @Override public void someMethod() { System.out.println("someMethod() invoked"); From 0a8d4b90f52f1548e8339d3e38e4ad561091fb29 Mon Sep 17 00:00:00 2001 From: Tristan Yan Date: Tue, 4 Jun 2013 10:23:37 +0200 Subject: [PATCH 139/206] 8015784: Add configure parameter --with-update-version Reviewed-by: tbell, katleman, erikj --- common/autoconf/generated-configure.sh | 16 +++++++++++++++- common/autoconf/jdk-options.m4 | 8 ++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 6922b152d76..b60cf9f95b4 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -988,6 +988,7 @@ enable_hotspot_test_in_build with_cacerts_file enable_unlimited_crypto with_milestone +with_update_version with_build_number with_user_release_suffix with_boot_jdk @@ -1727,6 +1728,7 @@ Optional Packages: group --with-cacerts-file specify alternative cacerts file --with-milestone Set milestone value for build [internal] + --with-update-version Set update version value for build [b00] --with-build-number Set build number value for build [b00] --with-user-release-suffix Add a custom string to the version string if build @@ -3780,7 +3782,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1370001995 +DATE_WHEN_GENERATED=1370333982 ############################################################################### # @@ -10841,6 +10843,18 @@ if test "x$MILESTONE" = x; then fi +# Check whether --with-update-version was given. +if test "${with_update_version+set}" = set; then : + withval=$with_update_version; +fi + +if test "x$with_update_version" = xyes; then + as_fn_error $? "Update version must have a value" "$LINENO" 5 +elif test "x$with_update_version" != x; then + JDK_UPDATE_VERSION="$with_update_version" +fi + + # Check whether --with-build-number was given. if test "${with_build_number+set}" = set; then : withval=$with_build_number; diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 index 268bd842f10..7f7467318f5 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 @@ -422,6 +422,14 @@ if test "x$MILESTONE" = x; then MILESTONE=internal fi +AC_ARG_WITH(update-version, [AS_HELP_STRING([--with-update-version], + [Set update version value for build @<:@b00@:>@])]) +if test "x$with_update_version" = xyes; then + AC_MSG_ERROR([Update version must have a value]) +elif test "x$with_update_version" != x; then + JDK_UPDATE_VERSION="$with_update_version" +fi + AC_ARG_WITH(build-number, [AS_HELP_STRING([--with-build-number], [Set build number value for build @<:@b00@:>@])]) if test "x$with_build_number" = xyes; then From 22dc46d3cdcfcb286f18d83a32887c8ceb212ab4 Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Tue, 4 Jun 2013 10:36:00 +0200 Subject: [PATCH 140/206] 8015510: (s) Improve JTReg location detection and provide location to test/Makefile Reviewed-by: erikj --- common/autoconf/generated-configure.sh | 106 +++++++++++++++++++++---- common/autoconf/toolchain.m4 | 97 ++++++++++++---------- common/makefiles/Main.gmk | 2 +- 3 files changed, 149 insertions(+), 56 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index b60cf9f95b4..2e36a524275 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -681,8 +681,8 @@ STATIC_LIBRARY SHARED_LIBRARY OBJ_SUFFIX COMPILER_NAME -JTREGEXE JT_HOME +JTREGEXE LIPO ac_ct_OBJDUMP OBJDUMP @@ -3782,7 +3782,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1370333982 +DATE_WHEN_GENERATED=1370334570 ############################################################################### # @@ -16177,14 +16177,28 @@ AR_OUT_OPTION='rcs$(SPACE)' # Check whether --with-jtreg was given. if test "${with_jtreg+set}" = set; then : withval=$with_jtreg; +else + with_jtreg=no fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for JTReg Regression Test Harness" >&5 -$as_echo_n "checking for JTReg Regression Test Harness... " >&6; } + if test "x$with_jtreg" = xno; then + # jtreg disabled + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jtreg" >&5 +$as_echo_n "checking for jtreg... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + else + if test "x$with_jtreg" != xyes; then + # with path specified. + JT_HOME="$with_jtreg" + fi - if test "x$with_jtreg" != x; then - JT_HOME="$with_jtreg" + if test "x$JT_HOME" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jtreg" >&5 +$as_echo_n "checking for jtreg... " >&6; } + + # use JT_HOME enviroment var. if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -16307,17 +16321,79 @@ $as_echo "$as_me: The path of JT_HOME, which resolves as \"$path\", is invalid." JT_HOME="`cd "$path"; $THEPWDCMD -L`" fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JT_HOME" >&5 -$as_echo "$JT_HOME" >&6; } - # jtreg win32 script works for everybody - JTREGEXE="$JT_HOME/win32/bin/jtreg" - if test ! -f "$JTREGEXE"; then - as_fn_error $? "JTReg executable does not exist: $JTREGEXE" "$LINENO" 5 - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + # jtreg win32 script works for everybody + JTREGEXE="$JT_HOME/win32/bin/jtreg" + + if test ! -f "$JTREGEXE"; then + as_fn_error $? "JTReg executable does not exist: $JTREGEXE" "$LINENO" 5 + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JTREGEXE" >&5 +$as_echo "$JTREGEXE" >&6; } + else + # try to find jtreg on path + + for ac_prog in jtreg +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_JTREGEXE+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $JTREGEXE in + [\\/]* | ?:[\\/]*) + ac_cv_path_JTREGEXE="$JTREGEXE" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_JTREGEXE="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +JTREGEXE=$ac_cv_path_JTREGEXE +if test -n "$JTREGEXE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JTREGEXE" >&5 +$as_echo "$JTREGEXE" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } +fi + + + test -n "$JTREGEXE" && break +done + + + if test "x$JTREGEXE" = x; then + if test "xjtreg" = x; then + PROG_NAME=jtregexe + else + PROG_NAME=jtreg + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 +$as_echo "$as_me: Could not find $PROG_NAME!" >&6;} + as_fn_error $? "Cannot continue" "$LINENO" 5 + fi + + + JT_HOME="`$DIRNAME $JTREGEXE`" + fi fi diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index 723d96a22e1..eb6c375f397 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -36,7 +36,7 @@ AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION], $ECHO $COMPILER_VERSION_TEST | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null if test $? -ne 0; then GCC_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1` - + AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required Sun Studio compiler.]) AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_TEST" and with --version: "$GCC_VERSION_TEST"]) AC_MSG_ERROR([Sun Studio compiler is required. Try setting --with-tools-dir.]) @@ -69,7 +69,7 @@ AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION], AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_TEST"]) AC_MSG_ERROR([GCC compiler is required. Try setting --with-tools-dir.]) fi - + # First line typically looks something like: # gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/p"` @@ -142,7 +142,7 @@ AC_DEFUN([TOOLCHAIN_FIND_COMPILER], BASIC_REMOVE_SYMBOLIC_LINKS(TEST_COMPILER) AC_MSG_RESULT([$TEST_COMPILER]) AC_MSG_CHECKING([if $1 is disguised ccache]) - + COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"` if test "x$COMPILER_BASENAME" = "xccache"; then AC_MSG_RESULT([yes, trying to find proper $COMPILER_NAME compiler]) @@ -226,11 +226,11 @@ BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx, ], []) -if test "x$SYS_ROOT" != "x/" ; then +if test "x$SYS_ROOT" != "x/" ; then CFLAGS="--sysroot=$SYS_ROOT $CFLAGS" CXXFLAGS="--sysroot=$SYS_ROOT $CXXFLAGS" - OBJCFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" - OBJCXXFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" + OBJCFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" + OBJCXXFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" CPPFLAGS="--sysroot=$SYS_ROOT $CPPFLAGS" LDFLAGS="--sysroot=$SYS_ROOT $LDFLAGS" fi @@ -330,7 +330,7 @@ AC_SUBST(HOTSPOT_LD) COMPILER_NAME=gcc COMPILER_TYPE=CC AS_IF([test "x$OPENJDK_TARGET_OS" = xwindows], [ - # For now, assume that we are always compiling using cl.exe. + # For now, assume that we are always compiling using cl.exe. CC_OUT_OPTION=-Fo EXE_OUT_OPTION=-out: LD_OUT_OPTION=-out: @@ -491,7 +491,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_LIBS], ############################################################################### # -# How to compile shared libraries. +# How to compile shared libraries. # if test "x$GCC" = xyes; then @@ -525,7 +525,7 @@ if test "x$GCC" = xyes; then SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG" SHARED_LIBRARY_SUFFIX='.dylib' EXE_SUFFIX='' - SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1' + SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1' SET_SHARED_LIBRARY_MAPFILE='' SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.' SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN" @@ -676,7 +676,7 @@ case $COMPILER_TYPE in # Use single precision floating point with 'float' CC_HIGHEST="$CC_HIGHEST -fsingle" # Assume memory references via basic pointer types do not alias - # (Source with excessing pointer casting and data access with mixed + # (Source with excessing pointer casting and data access with mixed # pointer types are not recommended) CC_HIGHEST="$CC_HIGHEST -xalias_level=basic" # Use intrinsic or inline versions for math/std functions @@ -892,7 +892,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris; then fi if test "x$OPENJDK_TARGET_OS" = xmacosx; then CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE" - # Setting these parameters makes it an error to link to macosx APIs that are + # Setting these parameters makes it an error to link to macosx APIs that are # newer than the given OS version and makes the linked binaries compatible even # if built on a newer version of the OS. # The expected format is X.Y.Z @@ -940,12 +940,12 @@ CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK" # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library # is identical for client and server? Yes. Which is picked at runtime (client or server)? # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following -# libraries will link to whatever is in memory. Yuck. +# libraries will link to whatever is in memory. Yuck. # # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh. if test "x$COMPILER_NAME" = xcl; then LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no" - if test "x$OPENJDK_TARGET_CPU" = xx86; then + if test "x$OPENJDK_TARGET_CPU" = xx86; then LDFLAGS_JDK="$LDFLAGS_JDK -safeseh" fi # TODO: make -debug optional "--disable-full-debug-symbols" @@ -965,7 +965,7 @@ else if test -n "$HAS_GNU_HASH"; then LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both " fi - if test "x$OPENJDK_TARGET_OS" = xlinux; then + if test "x$OPENJDK_TARGET_OS" = xlinux; then # And since we now know that the linker is gnu, then add -z defs, to forbid # undefined symbols in object files. LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs" @@ -1006,7 +1006,7 @@ fi # Adjust flags according to debug level. case $DEBUG_LEVEL in - fastdebug ) + fastdebug ) CFLAGS="$CFLAGS $D_FLAG" JAVAC_FLAGS="$JAVAC_FLAGS -g" ;; @@ -1018,9 +1018,9 @@ case $DEBUG_LEVEL in CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE" JAVAC_FLAGS="$JAVAC_FLAGS -g" ;; -esac +esac + - AC_SUBST(CFLAGS_JDKLIB) AC_SUBST(CFLAGS_JDKEXE) @@ -1092,28 +1092,45 @@ AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_MISC], AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG) ]) -# Setup the JTREG paths -AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG], -[ - AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg], - [Regression Test Harness @<:@probed@:>@])]) - - AC_MSG_CHECKING([for JTReg Regression Test Harness]) - - if test "x$with_jtreg" != x; then - JT_HOME="$with_jtreg" - BASIC_FIXUP_PATH([JT_HOME]) - AC_MSG_RESULT($JT_HOME) - - # jtreg win32 script works for everybody - JTREGEXE="$JT_HOME/win32/bin/jtreg" - if test ! -f "$JTREGEXE"; then - AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE]) - fi - else +# Setup the JTREG paths +AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG], +[ + AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg], + [Regression Test Harness @<:@probed@:>@])], + [], + [with_jtreg=no]) + + if test "x$with_jtreg" = xno; then + # jtreg disabled + AC_MSG_CHECKING([for jtreg]) AC_MSG_RESULT(no) - fi - - AC_SUBST(JT_HOME) - AC_SUBST(JTREGEXE) + else + if test "x$with_jtreg" != xyes; then + # with path specified. + JT_HOME="$with_jtreg" + fi + + if test "x$JT_HOME" != x; then + AC_MSG_CHECKING([for jtreg]) + + # use JT_HOME enviroment var. + BASIC_FIXUP_PATH([JT_HOME]) + + # jtreg win32 script works for everybody + JTREGEXE="$JT_HOME/win32/bin/jtreg" + + if test ! -f "$JTREGEXE"; then + AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE]) + fi + + AC_MSG_RESULT($JTREGEXE) + else + # try to find jtreg on path + BASIC_REQUIRE_PROG(JTREGEXE, jtreg) + JT_HOME="`$DIRNAME $JTREGEXE`" + fi + fi + + AC_SUBST(JT_HOME) + AC_SUBST(JTREGEXE) ]) diff --git a/common/makefiles/Main.gmk b/common/makefiles/Main.gmk index d07f3e2b386..0120c1f33f3 100644 --- a/common/makefiles/Main.gmk +++ b/common/makefiles/Main.gmk @@ -183,7 +183,7 @@ bootcycle-images-only: start-make test: images test-only test-only: start-make @$(call TargetEnter) - @($(CD) $(SRC_ROOT)/test && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 -k MAKEFLAGS= PRODUCT_HOME=$(JDK_IMAGE_DIR) JPRT_JAVA_HOME=$(JDK_IMAGE_DIR) ALT_OUTPUTDIR=$(OUTPUT_ROOT) $(TEST)) || true + @($(CD) $(SRC_ROOT)/test && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 -k JT_HOME=$(JT_HOME) MAKEFLAGS= PRODUCT_HOME=$(JDK_IMAGE_DIR) JPRT_JAVA_HOME=$(JDK_IMAGE_DIR) ALT_OUTPUTDIR=$(OUTPUT_ROOT) $(TEST)) || true @$(call TargetExit) # Stores the tips for each repository. This file is be used when constructing the jdk image and can be From f0112464e0dbe5b6f029de66f1fd6aa190c11daa Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 4 Jun 2013 11:30:51 +0100 Subject: [PATCH 141/206] 7116676: RichDiagnosticFormatter throws NPE when formatMessage is called directly Fix NPE in RichDiagnosticFormatter.formatMessage Reviewed-by: jjg --- .../javac/util/RichDiagnosticFormatter.java | 7 ++ .../javac/Diagnostics/7116676/T7116676.java | 109 ++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 langtools/test/tools/javac/Diagnostics/7116676/T7116676.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java index 517d01984c5..b142df2ccc8 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java @@ -125,6 +125,13 @@ public class RichDiagnosticFormatter extends return sb.toString(); } + @Override + public String formatMessage(JCDiagnostic diag, Locale l) { + nameSimplifier = new ClassNameSimplifier(); + preprocessDiagnostic(diag); + return super.formatMessage(diag, l); + } + /** * Sets the type/symbol printer used by this formatter. * @param printer the rich printer to be set diff --git a/langtools/test/tools/javac/Diagnostics/7116676/T7116676.java b/langtools/test/tools/javac/Diagnostics/7116676/T7116676.java new file mode 100644 index 00000000000..40acc7854ed --- /dev/null +++ b/langtools/test/tools/javac/Diagnostics/7116676/T7116676.java @@ -0,0 +1,109 @@ +/* + * 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 7116676 + * @summary RichDiagnosticFormatter throws NPE when formatMessage is called directly + */ + +import com.sun.source.util.JavacTask; +import com.sun.tools.javac.api.ClientCodeWrapper.Trusted; +import com.sun.tools.javac.api.DiagnosticFormatter; +import com.sun.tools.javac.api.JavacTaskImpl; +import com.sun.tools.javac.util.Assert; +import com.sun.tools.javac.util.JCDiagnostic; +import com.sun.tools.javac.util.Log; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import javax.tools.Diagnostic; +import javax.tools.DiagnosticListener; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +public class T7116676 { + + public static void main(String[] args) throws Exception { + T7116676 test = new T7116676(); + test.testThroughFormatterFormat(); + } + + static class JavaSource extends SimpleJavaFileObject { + private String text = "package test;\n" + + "public class Test {\n" + + " private void t(java.util.List l) {\n" + + " t(java.util.Collections.singleton(l));\n" + + "} }"; + + public JavaSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + } + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return text; + } + } + + void assertEquals(String req, String found) { + if (!found.equals(req)) { + throw new AssertionError(String.format("Error. Found: \n\n%s ; Expected: \n\n%s", found, req)); + } + } + + public void testThroughFormatterFormat() throws IOException { + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + DiagnosticChecker dc = new DiagnosticChecker("compiler.err.prob.found.req"); + JavacTask ct = (JavacTask)tool.getTask(null, null, dc, null, null, Arrays.asList(new JavaSource())); + ct.analyze(); + DiagnosticFormatter formatter = + Log.instance(((JavacTaskImpl) ct).getContext()).getDiagnosticFormatter(); + String msg = formatter.formatMessage(dc.diag, Locale.getDefault()); + //no redundant package qualifiers + Assert.check(msg.indexOf("java.") == -1, msg); + } + + @Trusted + private static final class DiagnosticChecker implements DiagnosticListener { + + String expectedKey; + JCDiagnostic diag; + + DiagnosticChecker(String expectedKey) { + this.expectedKey = expectedKey; + } + + @Override + public void report(Diagnostic diagnostic) { + JCDiagnostic diag = (JCDiagnostic)diagnostic; + if (diagnostic.getCode().equals(expectedKey)) { + this.diag = diag; + } + } + } +} From 1c6a680e66865b5fd6f55730f2cd3ff83c367617 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 4 Jun 2013 11:31:12 +0100 Subject: [PATCH 142/206] 8008160: Five lambda TargetType tests have @ignore Remove @ignore flags from tests that now pass Reviewed-by: jjg --- langtools/test/tools/javac/lambda/TargetType53.java | 1 - langtools/test/tools/javac/lambda/TargetType54.java | 1 - langtools/test/tools/javac/lambda/TargetType58.java | 1 - langtools/test/tools/javac/lambda/TargetType59.java | 1 - langtools/test/tools/javac/lambda/TargetType62.java | 1 - 5 files changed, 5 deletions(-) diff --git a/langtools/test/tools/javac/lambda/TargetType53.java b/langtools/test/tools/javac/lambda/TargetType53.java index 6b0da2f00b7..30f1a37ddd4 100644 --- a/langtools/test/tools/javac/lambda/TargetType53.java +++ b/langtools/test/tools/javac/lambda/TargetType53.java @@ -26,7 +26,6 @@ * @bug 8007464 * @summary Add graph inference support * smoke test for graph inference - * @ignore 8008682: Core stream API classes * @compile TargetType53.java */ import java.util.*; diff --git a/langtools/test/tools/javac/lambda/TargetType54.java b/langtools/test/tools/javac/lambda/TargetType54.java index 30bbf8a006d..5c62016adca 100644 --- a/langtools/test/tools/javac/lambda/TargetType54.java +++ b/langtools/test/tools/javac/lambda/TargetType54.java @@ -26,7 +26,6 @@ * @bug 8007464 * @summary Add graph inference support * smoke test for graph inference - * @ignore 8008682: Core stream API classes * @compile TargetType54.java */ import java.util.stream.*; diff --git a/langtools/test/tools/javac/lambda/TargetType58.java b/langtools/test/tools/javac/lambda/TargetType58.java index 50a8d996ee0..cb3ca9027e4 100644 --- a/langtools/test/tools/javac/lambda/TargetType58.java +++ b/langtools/test/tools/javac/lambda/TargetType58.java @@ -26,7 +26,6 @@ * @bug 8007464 * @summary Add graph inference support * more smoke tests for graph inference - * @ignore 8008682: Core stream API classes * @compile TargetType58.java */ import java.util.*; diff --git a/langtools/test/tools/javac/lambda/TargetType59.java b/langtools/test/tools/javac/lambda/TargetType59.java index 1bae37441be..f366179f0c9 100644 --- a/langtools/test/tools/javac/lambda/TargetType59.java +++ b/langtools/test/tools/javac/lambda/TargetType59.java @@ -26,7 +26,6 @@ * @bug 8007464 * @summary Add graph inference support * more smoke tests for graph inference - * @ignore 8008682: Core stream API classes * @compile TargetType59.java */ import java.util.*; diff --git a/langtools/test/tools/javac/lambda/TargetType62.java b/langtools/test/tools/javac/lambda/TargetType62.java index dec14bb5189..9bf79bbc699 100644 --- a/langtools/test/tools/javac/lambda/TargetType62.java +++ b/langtools/test/tools/javac/lambda/TargetType62.java @@ -26,7 +26,6 @@ * @bug 8007464 * @summary Add graph inference support * check that new wildcards inference strategy doesn't run into 7190296 - * @ignore 8008682: Core stream API classes * @compile TargetType62.java */ import java.util.*; From 5d6029baacd8b3efe5d99b5bb3102cba316e1fe9 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 4 Jun 2013 11:34:31 +0100 Subject: [PATCH 143/206] 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target Use check context compatibility during 15.12.2.8 check (only when JDK 8 inference is enabled) Reviewed-by: jjg --- .../com/sun/tools/javac/comp/Infer.java | 4 +- .../generics/inference/8015505/T8015505.java | 18 +++++++++ .../generics/inference/8015505/T8015505.out | 2 + .../7062745/GenericOverrideTest.java | 37 ++++++++++++++----- 4 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 langtools/test/tools/javac/generics/inference/8015505/T8015505.java create mode 100644 langtools/test/tools/javac/generics/inference/8015505/T8015505.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java index d696a928857..21014afa71b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java @@ -218,8 +218,8 @@ public class Infer { //we need to skip capture? Warner retWarn = new Warner(); if (!resultInfo.checkContext.compatible(qtype1, resultInfo.checkContext.inferenceContext().asFree(to), retWarn) || - //unchecked conversion is not allowed - retWarn.hasLint(Lint.LintCategory.UNCHECKED)) { + //unchecked conversion is not allowed in source 7 mode + (!allowGraphInference && retWarn.hasLint(Lint.LintCategory.UNCHECKED))) { throw inferenceException .setMessage("infer.no.conforming.instance.exists", inferenceContext.restvars(), mt.getReturnType(), to); diff --git a/langtools/test/tools/javac/generics/inference/8015505/T8015505.java b/langtools/test/tools/javac/generics/inference/8015505/T8015505.java new file mode 100644 index 00000000000..3b214027444 --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/8015505/T8015505.java @@ -0,0 +1,18 @@ +/** + * @test /nodynamiccopyright/ + * @bug 8015505 + * @summary Spurious inference error when return type of generic method requires unchecked conversion to target + * @compile/fail/ref=T8015505.out -Xlint:-options -source 7 -XDrawDiagnostics T8015505.java + * @compile T8015505.java + */ + +import java.util.List; + +class T8015505 { + + List m() { return null; } + + void test() { + List l = m(); + } +} diff --git a/langtools/test/tools/javac/generics/inference/8015505/T8015505.out b/langtools/test/tools/javac/generics/inference/8015505/T8015505.out new file mode 100644 index 00000000000..4742a1716eb --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/8015505/T8015505.out @@ -0,0 +1,2 @@ +T8015505.java:16:22: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.instance.exists: Z, java.util.List, java.util.List) +1 error diff --git a/langtools/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java b/langtools/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java index f18106838be..404ae3675b0 100644 --- a/langtools/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java +++ b/langtools/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java @@ -46,6 +46,17 @@ public class GenericOverrideTest extends JavacTestingAbstractThreadedTest implements Runnable { + enum SourceLevel { + SOURCE_7("-source", "7"), + SOURCE_DEFAULT(); + + String[] opts; + + SourceLevel(String... opts) { + this.opts = opts; + } + } + enum SignatureKind { NON_GENERIC(""), GENERIC(""); @@ -112,12 +123,13 @@ public class GenericOverrideTest } } - boolean assignableTo(TypeArgumentKind that, SignatureKind sig) { + boolean assignableTo(TypeArgumentKind that, SignatureKind sig, SourceLevel level) { switch (this) { case NONE: //this case needs to workaround to javac's impl of 15.12.2.8 being too strict - //ideally should be just 'return true' (see 7067746) - return sig == SignatureKind.NON_GENERIC || that == NONE; + //ideally should be just 'return true' (see 7067746/8015505) + return level == SourceLevel.SOURCE_DEFAULT || + sig == SignatureKind.NON_GENERIC || that == NONE; case UNBOUND: return that == this || that == NONE; case INTEGER: @@ -143,10 +155,12 @@ public class GenericOverrideTest for (TypeArgumentKind ta3 : TypeArgumentKind.values()) { if (!ta3.compatibleWith(SignatureKind.NON_GENERIC)) continue; - pool.execute( - new GenericOverrideTest(sig1, - rt1, ta1, sig2, rt2, - ta2, rt3, ta3)); + for (SourceLevel level : SourceLevel.values()) { + pool.execute( + new GenericOverrideTest(sig1, + rt1, ta1, sig2, rt2, + ta2, rt3, ta3, level)); + } } } } @@ -162,12 +176,13 @@ public class GenericOverrideTest SignatureKind sig1, sig2; ReturnTypeKind rt1, rt2, rt3; TypeArgumentKind ta1, ta2, ta3; + SourceLevel level; JavaSource source; DiagnosticChecker diagChecker; GenericOverrideTest(SignatureKind sig1, ReturnTypeKind rt1, TypeArgumentKind ta1, SignatureKind sig2, ReturnTypeKind rt2, TypeArgumentKind ta2, - ReturnTypeKind rt3, TypeArgumentKind ta3) { + ReturnTypeKind rt3, TypeArgumentKind ta3, SourceLevel level) { this.sig1 = sig1; this.sig2 = sig2; this.rt1 = rt1; @@ -176,6 +191,7 @@ public class GenericOverrideTest this.ta1 = ta1; this.ta2 = ta2; this.ta3 = ta3; + this.level = level; this.source = new JavaSource(); this.diagChecker = new DiagnosticChecker(); } @@ -213,7 +229,8 @@ public class GenericOverrideTest @Override public void run() { JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker, - null, null, Arrays.asList(source)); + level.opts != null ? Arrays.asList(level.opts) : null, + null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) { @@ -271,7 +288,7 @@ public class GenericOverrideTest SignatureKind mssig = mostSpecific == 1 ? sig1 : sig2; if (!msrt.moreSpecificThan(rt3) || - !msta.assignableTo(ta3, mssig)) { + !msta.assignableTo(ta3, mssig, level)) { errorExpected = true; } } From 5817f439abcb815827c6436e2688ea3420ea6001 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 4 Jun 2013 17:33:14 +0530 Subject: [PATCH 144/206] 8015855: test/script/basic/JDK-8012164.js fails on Windows Reviewed-by: hannesw, lagergren, jlaskey --- nashorn/test/script/basic/JDK-8012164.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nashorn/test/script/basic/JDK-8012164.js b/nashorn/test/script/basic/JDK-8012164.js index 9134d1438dc..6416cfadfdb 100644 --- a/nashorn/test/script/basic/JDK-8012164.js +++ b/nashorn/test/script/basic/JDK-8012164.js @@ -38,9 +38,18 @@ function error() { throw new Error('foo'); } catch (e) { for (i in e.stack) { - print(e.stack[i]); + printFrame(e.stack[i]); } } } func(); + +// See JDK-8015855: test/script/basic/JDK-8012164.js fails on Windows +// Replace '\' to '/' in class and file names of StackFrameElement objects +function printFrame(stack) { + var fileName = stack.fileName.replace(/\\/g, '/'); + var className = stack.className.replace(/\\/g, '/'); + print(className + '.' + stack.methodName + '(' + + fileName + ':' + stack.lineNumber + ')'); +} From aeb1c4b67e4e0caeaf1b8c68312e7284900f5c16 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Tue, 4 Jun 2013 13:21:41 +0100 Subject: [PATCH 145/206] 7165659: javac incorrectly sets strictfp access flag on inner-classes Reviewed-by: jjg, mcimadamore --- .../com/sun/tools/javac/jvm/ClassWriter.java | 1 + ...rClassAttrMustNotHaveStrictFPFlagTest.java | 71 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 langtools/test/tools/javac/T7165659/InnerClassAttrMustNotHaveStrictFPFlagTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java index 90aabc61a39..ac8b94a8310 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java @@ -1024,6 +1024,7 @@ public class ClassWriter extends ClassFile { char flags = (char) adjustFlags(inner.flags_field); if ((flags & INTERFACE) != 0) flags |= ABSTRACT; // Interfaces are always ABSTRACT if (inner.name.isEmpty()) flags &= ~FINAL; // Anonymous class: unset FINAL flag + flags &= ~STRICTFP; //inner classes should not have the strictfp flag set. if (dumpInnerClassModifiers) { PrintWriter pw = log.getWriter(Log.WriterKind.ERROR); pw.println("INNERCLASS " + inner.name); diff --git a/langtools/test/tools/javac/T7165659/InnerClassAttrMustNotHaveStrictFPFlagTest.java b/langtools/test/tools/javac/T7165659/InnerClassAttrMustNotHaveStrictFPFlagTest.java new file mode 100644 index 00000000000..442923d17ce --- /dev/null +++ b/langtools/test/tools/javac/T7165659/InnerClassAttrMustNotHaveStrictFPFlagTest.java @@ -0,0 +1,71 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7165659 + * @summary javac incorrectly sets strictfp access flag on inner-classes + */ + +import java.io.File; + +import com.sun.tools.classfile.AccessFlags; +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.InnerClasses_attribute; +import com.sun.tools.classfile.InnerClasses_attribute.Info; +import com.sun.tools.javac.util.Assert; + +public class InnerClassAttrMustNotHaveStrictFPFlagTest { + + public static void main(String[] args) throws Exception { + new InnerClassAttrMustNotHaveStrictFPFlagTest().run(); + } + + private void run() throws Exception { + File classPath = new File(System.getProperty("test.classes"), getClass().getSimpleName() + ".class"); + analyzeClassFile(classPath); + } + + void analyzeClassFile(File path) throws Exception { + ClassFile classFile = ClassFile.read(path); + InnerClasses_attribute innerClasses = + (InnerClasses_attribute) classFile.attributes.get(Attribute.InnerClasses); + for (Info classInfo : innerClasses.classes) { + Assert.check(!classInfo.inner_class_access_flags.is(AccessFlags.ACC_STRICT), + "Inner classes attribute must not have the ACC_STRICT flag set"); + } + } + + strictfp void m() { + new Runnable() { + @Override + public void run() {} + }; + } + + static strictfp class Strict extends InnerClassAttrMustNotHaveStrictFPFlagTest {} + +} From 53ba53a9419139b2764bedb103074535827650c8 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Tue, 4 Jun 2013 09:35:12 -0700 Subject: [PATCH 146/206] 8015630: Remove default restriction settings of jaxp 1.5 properties in JDK8 Reviewed-by: alanb --- .../apache/xalan/internal/XalanConstants.java | 55 +------------------ .../xsltc/trax/TransformerFactoryImpl.java | 1 - .../xerces/internal/impl/Constants.java | 54 +----------------- .../jaxp/validation/XMLSchemaFactory.java | 11 +++- 4 files changed, 10 insertions(+), 111 deletions(-) diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java b/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java index 82756c198ea..9667b544944 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java @@ -80,59 +80,6 @@ public final class XalanConstants { /** * FEATURE_SECURE_PROCESSING (FSP) is false by default */ - public static final String EXTERNAL_ACCESS_DEFAULT = getExternalAccessDefault(false); - - /** - * Determine the default value of the external access properties - * - * jaxp 1.5 does not require implementations to restrict by default - * - * For JDK8: - * The default value is 'file' (including jar:file); The keyword "all" grants permission - * to all protocols. When {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} is on, - * the default value is an empty string indicating no access is allowed. - * - * For JDK7: - * The default value is 'all' granting permission to all protocols. If by default, - * {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} is true, it should - * not change the default value. However, if {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} - * is set explicitly, the values of the properties shall be set to an empty string - * indicating no access is allowed. - * - * @param isSecureProcessing indicating if Secure Processing is set - * @return default value - */ - public static String getExternalAccessDefault(boolean isSecureProcessing) { - String defaultValue = "all"; - if (isJDKandAbove(RESTRICT_BY_DEFAULT_JDK_VERSION)) { - defaultValue = "file"; - if (isSecureProcessing) { - defaultValue = EXTERNAL_ACCESS_DEFAULT_FSP; - } - } - return defaultValue; - } - - /* - * Check the version of the current JDK against that specified in the - * parameter - * - * There is a proposal to change the java version string to: - * MAJOR.MINOR.FU.CPU.PSU-BUILDNUMBER_BUGIDNUMBER_OPTIONAL - * This method would work with both the current format and that proposed - * - * @param compareTo a JDK version to be compared to - * @return true if the current version is the same or above that represented - * by the parameter - */ - public static boolean isJDKandAbove(int compareTo) { - String javaVersion = SecuritySupport.getSystemProperty("java.version"); - String versions[] = javaVersion.split("\\.", 3); - if (Integer.parseInt(versions[0]) >= compareTo || - Integer.parseInt(versions[1]) >= compareTo) { - return true; - } - return false; - } + public static final String EXTERNAL_ACCESS_DEFAULT = ACCESS_EXTERNAL_ALL; } // class Constants diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java index 2675268d555..a15d8fad536 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java @@ -253,7 +253,6 @@ public class TransformerFactoryImpl if (System.getSecurityManager() != null) { _isSecureMode = true; _isNotSecureProcessing = false; - defaultAccess = XalanConstants.getExternalAccessDefault(true); } _accessExternalStylesheet = SecuritySupport.getDefaultAccessProperty( XalanConstants.SP_ACCESS_EXTERNAL_STYLESHEET, defaultAccess); diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java index ec8a1117ebc..01328adf012 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java @@ -202,7 +202,7 @@ public final class Constants { /** * FEATURE_SECURE_PROCESSING (FSP) is true by default */ - public static final String EXTERNAL_ACCESS_DEFAULT = getExternalAccessDefault(true); + public static final String EXTERNAL_ACCESS_DEFAULT = ACCESS_EXTERNAL_ALL; // // DOM features @@ -697,58 +697,6 @@ public final class Constants { ? new ArrayEnumeration(fgXercesProperties) : fgEmptyEnumeration; } // getXercesProperties():Enumeration - /** - * Determine the default value of the external access properties - * - * jaxp 1.5 does not require implementations to restrict by default - * - * For JDK8: - * The default value is 'file' (including jar:file); The keyword "all" grants permission - * to all protocols. When {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} is on, - * the default value is an empty string indicating no access is allowed. - * - * For JDK7: - * The default value is 'all' granting permission to all protocols. If by default, - * {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} is true, it should - * not change the default value. However, if {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} - * is set explicitly, the values of the properties shall be set to an empty string - * indicating no access is allowed. - * - * @param isSecureProcessing indicating if Secure Processing is set - * @return default value - */ - public static String getExternalAccessDefault(boolean isSecureProcessing) { - String defaultValue = "all"; - if (isJDKandAbove(RESTRICT_BY_DEFAULT_JDK_VERSION)) { - defaultValue = "file"; - if (isSecureProcessing) { - defaultValue = EXTERNAL_ACCESS_DEFAULT_FSP; - } - } - return defaultValue; - } - - /* - * Check the version of the current JDK against that specified in the - * parameter - * - * There is a proposal to change the java version string to: - * MAJOR.MINOR.FU.CPU.PSU-BUILDNUMBER_BUGIDNUMBER_OPTIONAL - * This method would work with both the current format and that proposed - * - * @param compareTo a JDK version to be compared to - * @return true if the current version is the same or above that represented - * by the parameter - */ - public static boolean isJDKandAbove(int compareTo) { - String javaVersion = SecuritySupport.getSystemProperty("java.version"); - String versions[] = javaVersion.split("\\.", 3); - if (Integer.parseInt(versions[0]) >= compareTo || - Integer.parseInt(versions[1]) >= compareTo) { - return true; - } - return false; - } // // Classes diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java index 4cac487362f..763fcdbd29f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java @@ -364,10 +364,15 @@ public final class XMLSchemaFactory extends SchemaFactory { SAXMessageFormatter.formatMessage(null, "jaxp-secureprocessing-feature", null)); } - fSecurityManager = value ? new SecurityManager() : null; + if (value) { + fSecurityManager = new SecurityManager(); + fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_DTD, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); + fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_SCHEMA, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); + } else { + fSecurityManager = null; + } + fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager); - fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_DTD, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); - fXMLSchemaLoader.setProperty(ACCESS_EXTERNAL_SCHEMA, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); return; } else if (name.equals(Constants.ORACLE_FEATURE_SERVICE_MECHANISM)) { //in secure mode, let _useServicesMechanism be determined by the constructor From 7ee2adb4d72d2b9e627e4fc9d4d518990516bd36 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 4 Jun 2013 22:31:48 +0530 Subject: [PATCH 147/206] 8015830: Javascript mapping of ScriptEngine bindings does not expose keys Reviewed-by: jlaskey, lagergren --- .../api/scripting/ScriptObjectMirror.java | 23 ++++++-- .../internal/runtime/ScriptObject.java | 11 ++++ .../internal/runtime/ScriptRuntime.java | 13 +++++ nashorn/test/script/basic/JDK-8015830.js | 56 +++++++++++++++++++ .../test/script/basic/JDK-8015830.js.EXPECTED | 4 ++ 5 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8015830.js create mode 100644 nashorn/test/script/basic/JDK-8015830.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java index e53903d3c3f..59ac5fec042 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java +++ b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java @@ -31,7 +31,7 @@ import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -48,7 +48,7 @@ import jdk.nashorn.internal.runtime.ScriptRuntime; * access ScriptObject via the javax.script.Bindings interface or * netscape.javascript.JSObject interface. */ -final class ScriptObjectMirror extends JSObject implements Bindings { +public final class ScriptObjectMirror extends JSObject implements Bindings { private final ScriptObject sobj; private final ScriptObject global; @@ -217,7 +217,7 @@ final class ScriptObjectMirror extends JSObject implements Bindings { return inGlobal(new Callable>>() { @Override public Set> call() { final Iterator iter = sobj.propertyIterator(); - final Set> entries = new HashSet<>(); + final Set> entries = new LinkedHashSet<>(); while (iter.hasNext()) { final String key = iter.next(); @@ -253,7 +253,7 @@ final class ScriptObjectMirror extends JSObject implements Bindings { return inGlobal(new Callable>() { @Override public Set call() { final Iterator iter = sobj.propertyIterator(); - final Set keySet = new HashSet<>(); + final Set keySet = new LinkedHashSet<>(); while (iter.hasNext()) { keySet.add(iter.next()); @@ -302,6 +302,21 @@ final class ScriptObjectMirror extends JSObject implements Bindings { }); } + /** + * Delete a property from this object. + * + * @param key the property to be deleted + * + * @return if the delete was successful or not + */ + public boolean delete(final Object key) { + return inGlobal(new Callable() { + @Override public Boolean call() { + return sobj.delete(unwrap(key, global)); + } + }); + } + @Override public int size() { return inGlobal(new Callable() { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java index cf89c545f98..331687ad3c9 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java @@ -1511,6 +1511,17 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return oldValue; } + /** + * Delete a property from the ScriptObject. + * (to help ScriptObjectMirror implementation) + * + * @param key the key of the property + * @return if the delete was successful or not + */ + public boolean delete(final Object key) { + return delete(key, getContext()._strict); + } + /** * Return the size of the ScriptObject - i.e. the number of properties * it contains diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java index 25dccb7b658..d5ab68b2ed2 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java @@ -40,6 +40,7 @@ import java.util.Locale; import java.util.NoSuchElementException; import java.util.Objects; import jdk.internal.dynalink.beans.StaticClass; +import jdk.nashorn.api.scripting.ScriptObjectMirror; import jdk.nashorn.internal.codegen.CompilerConstants.Call; import jdk.nashorn.internal.ir.debug.JSONWriter; import jdk.nashorn.internal.parser.Lexer; @@ -240,6 +241,10 @@ public final class ScriptRuntime { }; } + if (obj instanceof ScriptObjectMirror) { + return ((ScriptObjectMirror)obj).keySet().iterator(); + } + return Collections.emptyIterator(); } @@ -280,6 +285,10 @@ public final class ScriptRuntime { }; } + if (obj instanceof ScriptObjectMirror) { + return ((ScriptObjectMirror)obj).values().iterator(); + } + if (obj instanceof Iterable) { return ((Iterable)obj).iterator(); } @@ -591,6 +600,10 @@ public final class ScriptRuntime { throw typeError("cant.delete.property", safeToString(property), "null"); } + if (obj instanceof ScriptObjectMirror) { + return ((ScriptObjectMirror)obj).delete(property); + } + if (JSType.isPrimitive(obj)) { return ((ScriptObject) JSType.toScriptObject(obj)).delete(property, Boolean.TRUE.equals(strict)); } diff --git a/nashorn/test/script/basic/JDK-8015830.js b/nashorn/test/script/basic/JDK-8015830.js new file mode 100644 index 00000000000..314a73a4acf --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015830.js @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8015830: Javascript mapping of ScriptEngine bindings does not expose keys + * + * @test + * @run + */ + +var m = new javax.script.ScriptEngineManager(); +var engine = m.getEngineByName("nashorn"); + +engine.eval("x = 100; doit = function () { }"); + +var global = engine.getBindings(javax.script.ScriptContext.ENGINE_SCOPE); + +for(k in global){ + print(k + " = " + global[k]); +} + +for each (k in global) { + print(k); +} + +for(k in global) { + delete global[k]; +} + +for(k in global){ + print(k + " = " + global[k]); +} + +for each(k in global) { + print(k); +} diff --git a/nashorn/test/script/basic/JDK-8015830.js.EXPECTED b/nashorn/test/script/basic/JDK-8015830.js.EXPECTED new file mode 100644 index 00000000000..8f98a2243f3 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015830.js.EXPECTED @@ -0,0 +1,4 @@ +x = 100 +doit = function () { } +100 +function () { } From c3d6abc4e11fbe4808147956ee4c7b6ef2c6d71d Mon Sep 17 00:00:00 2001 From: John Cuthbertson Date: Tue, 4 Jun 2013 10:04:06 -0700 Subject: [PATCH 148/206] 8015244: G1: Verification after a full GC is incorrectly placed In a full GC, move the verification after the GC to after RSet rebuilding. Verify RSet entries during a full GC under control of a flag. Reviewed-by: tschatzl, brutisso --- .../src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp | 4 ++-- hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp | 2 +- hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp | 6 +++++- hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index aff2d5da607..0505822e873 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -1417,8 +1417,6 @@ bool G1CollectedHeap::do_collection(bool explicit_gc, MemoryService::track_memory_usage(); - verify_after_gc(); - assert(!ref_processor_stw()->discovery_enabled(), "Postcondition"); ref_processor_stw()->verify_no_references_recorded(); @@ -1521,6 +1519,8 @@ bool G1CollectedHeap::do_collection(bool explicit_gc, _hrs.verify_optional(); verify_region_sets_optional(); + verify_after_gc(); + // Start a new incremental collection set for the next pause assert(g1_policy()->collection_set() == NULL, "must be"); g1_policy()->start_incremental_cset_building(); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp index ae4c6b63510..673814ce971 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp @@ -736,7 +736,7 @@ void G1RemSet::print_summary_info(G1RemSetSummary * summary, const char * header void G1RemSet::prepare_for_verify() { if (G1HRRSFlushLogBuffersOnVerify && (VerifyBeforeGC || VerifyAfterGC) - && !_g1->full_collection()) { + && (!_g1->full_collection() || G1VerifyRSetsDuringFullGC)) { cleanupHRRS(); _g1->set_refine_cte_cl_concurrency(false); if (SafepointSynchronize::is_at_safepoint()) { diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp index 7e62b70cdca..36dfdce6d25 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp @@ -329,7 +329,11 @@ \ develop(bool, G1EvacuationFailureALotDuringMixedGC, true, \ "Force use of evacuation failure handling during mixed " \ - "evacuation pauses") + "evacuation pauses") \ + \ + diagnostic(bool, G1VerifyRSetsDuringFullGC, false, \ + "If true, perform verification of each heap region's " \ + "remembered set when verifying the heap during a full GC.") G1_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_DIAGNOSTIC_FLAG, DECLARE_EXPERIMENTAL_FLAG, DECLARE_NOTPRODUCT_FLAG, DECLARE_MANAGEABLE_FLAG, DECLARE_PRODUCT_RW_FLAG) diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp index f33e0456e64..7ef24358e15 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp @@ -139,7 +139,7 @@ public: _n_failures++; } - if (!_g1h->full_collection()) { + if (!_g1h->full_collection() || G1VerifyRSetsDuringFullGC) { HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p); HeapRegion* to = _g1h->heap_region_containing(obj); if (from != NULL && to != NULL && From a28a9d6551308a0748748295db7ebe5aa1cef33b Mon Sep 17 00:00:00 2001 From: Morris Meyer Date: Tue, 4 Jun 2013 12:06:54 -0700 Subject: [PATCH 149/206] 8010724: [parfait] Null pointer dereference in hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Added guarantee() Reviewed-by: kvn --- hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index abb4914fbfa..fcd6910ed95 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -2232,6 +2232,7 @@ void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) { // We still need to continue with the checks. if (src.is_constant()) { ciObject* src_con = src.get_jobject_constant(); + guarantee(src_con != NULL, "no source constant"); if (src_con->is_null_object()) { // The constant src object is null - We can skip From 50cbe913caa7473fc22ec828a7917b5207d3a5b7 Mon Sep 17 00:00:00 2001 From: Amy Wang Date: Tue, 4 Jun 2013 14:11:50 -0700 Subject: [PATCH 150/206] 8015644: makefile changes to allow integration of new features Reviewed-by: tbell, erikj, dholmes --- jdk/makefiles/Images.gmk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/makefiles/Images.gmk b/jdk/makefiles/Images.gmk index a1db8b9a148..d265f4cd587 100644 --- a/jdk/makefiles/Images.gmk +++ b/jdk/makefiles/Images.gmk @@ -50,8 +50,6 @@ images:: jre-image jdk-image overlay-images: jre-overlay-image jdk-overlay-image --include $(CUSTOM_MAKE_DIR)/Images.gmk - # Processing license files from source area to image area # These will be modified to have the platform specific EOL chars. @@ -774,3 +772,5 @@ endif # Profile ################################################################################ .PHONY: default images jre-image jdk-image + +-include $(CUSTOM_MAKE_DIR)/Images.gmk From bdfb93ee25ec36c266256b09422d05801e0e07a8 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 4 Jun 2013 14:17:50 -0700 Subject: [PATCH 151/206] 8004643: Reduce javac space overhead introduced with compiler support for repeating annotations Reviewed-by: mcimadamore, jfranck --- .../com/sun/tools/javac/code/Lint.java | 16 +- .../com/sun/tools/javac/code/Symbol.java | 179 +++++++++++++++--- .../sun/tools/javac/code/TypeAnnotations.java | 12 +- .../com/sun/tools/javac/comp/Attr.java | 15 +- .../com/sun/tools/javac/comp/Enter.java | 2 +- .../com/sun/tools/javac/comp/Flow.java | 18 +- .../sun/tools/javac/comp/LambdaToMethod.java | 14 +- .../com/sun/tools/javac/comp/Lower.java | 4 +- .../com/sun/tools/javac/comp/MemberEnter.java | 12 +- .../com/sun/tools/javac/comp/TransTypes.java | 8 +- .../com/sun/tools/javac/jvm/ClassReader.java | 9 +- .../classes/com/sun/tools/javac/jvm/Code.java | 7 +- .../classes/com/sun/tools/javac/jvm/Gen.java | 12 +- .../com/sun/tools/javac/jvm/JNIWriter.java | 2 +- .../sun/tools/javac/sym/CreateSymbols.java | 6 +- .../com/sun/tools/javac/tree/TreeInfo.java | 8 + langtools/test/tools/javac/lib/DPrinter.java | 2 +- 17 files changed, 218 insertions(+), 108 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java b/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java index a80d654898c..a6956f341ec 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java @@ -68,19 +68,11 @@ public class Lint /** * Returns the result of combining the values in this object with - * the given annotations. + * the metadata on the given symbol. */ - public Lint augment(Annotations annots) { - return augmentor.augment(this, annots.getDeclarationAttributes()); - } - - /** - * Returns the result of combining the values in this object with - * the given annotations and flags. - */ - public Lint augment(Annotations annots, long flags) { - Lint l = augmentor.augment(this, annots.getDeclarationAttributes()); - if ((flags & DEPRECATED) != 0) { + public Lint augment(Symbol sym) { + Lint l = augmentor.augment(this, sym.getDeclarationAttributes()); + if (sym.isDeprecated()) { if (l == this) l = new Lint(this); l.values.remove(LintCategory.DEPRECATION); diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java index 4072a948a7f..b301cb858bd 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java @@ -32,6 +32,7 @@ import javax.lang.model.element.*; import javax.tools.JavaFileObject; import com.sun.tools.javac.code.Type.*; +import com.sun.tools.javac.comp.Annotate; import com.sun.tools.javac.comp.Attr; import com.sun.tools.javac.comp.AttrContext; import com.sun.tools.javac.comp.Env; @@ -74,35 +75,6 @@ public abstract class Symbol implements Element { */ public long flags() { return flags_field; } - /** The attributes of this symbol are contained in this - * Annotations. The Annotations instance is NOT immutable. - */ - public final Annotations annotations = new Annotations(this); - - /** An accessor method for the attributes of this symbol. - * Attributes of class symbols should be accessed through the accessor - * method to make sure that the class symbol is loaded. - */ - public List getRawAttributes() { - return annotations.getDeclarationAttributes(); - } - - /** An accessor method for the type attributes of this symbol. - * Attributes of class symbols should be accessed through the accessor - * method to make sure that the class symbol is loaded. - */ - public List getRawTypeAttributes() { - return annotations.getTypeAttributes(); - } - - /** Fetch a particular annotation from a symbol. */ - public Attribute.Compound attribute(Symbol anno) { - for (Attribute.Compound a : getRawAttributes()) { - if (a.type.tsym == anno) return a; - } - return null; - } - /** The name of this symbol in Utf8 representation. */ public Name name; @@ -123,6 +95,146 @@ public abstract class Symbol implements Element { */ public Type erasure_field; + // + + /** The attributes of this symbol are contained in this + * Annotations. The Annotations instance is NOT immutable. + */ + protected Annotations annotations; + + /** An accessor method for the attributes of this symbol. + * Attributes of class symbols should be accessed through the accessor + * method to make sure that the class symbol is loaded. + */ + public List getRawAttributes() { + return (annotations == null) + ? List.nil() + : annotations.getDeclarationAttributes(); + } + + /** An accessor method for the type attributes of this symbol. + * Attributes of class symbols should be accessed through the accessor + * method to make sure that the class symbol is loaded. + */ + public List getRawTypeAttributes() { + return (annotations == null) + ? List.nil() + : annotations.getTypeAttributes(); + } + + /** Fetch a particular annotation from a symbol. */ + public Attribute.Compound attribute(Symbol anno) { + for (Attribute.Compound a : getRawAttributes()) { + if (a.type.tsym == anno) return a; + } + return null; + } + + public boolean annotationsPendingCompletion() { + return annotations == null ? false : annotations.pendingCompletion(); + } + + public void appendAttributes(List l) { + if (l.nonEmpty()) { + initedAnnos().append(l); + } + } + + public void appendClassInitTypeAttributes(List l) { + if (l.nonEmpty()) { + initedAnnos().appendClassInitTypeAttributes(l); + } + } + + public void appendInitTypeAttributes(List l) { + if (l.nonEmpty()) { + initedAnnos().appendInitTypeAttributes(l); + } + } + + public void appendTypeAttributesWithCompletion(final Annotate.AnnotateRepeatedContext ctx) { + initedAnnos().appendTypeAttributesWithCompletion(ctx); + } + + public void appendUniqueTypeAttributes(List l) { + if (l.nonEmpty()) { + initedAnnos().appendUniqueTypes(l); + } + } + + public List getClassInitTypeAttributes() { + return (annotations == null) + ? List.nil() + : annotations.getClassInitTypeAttributes(); + } + + public List getInitTypeAttributes() { + return (annotations == null) + ? List.nil() + : annotations.getInitTypeAttributes(); + } + + public List getDeclarationAttributes() { + return (annotations == null) + ? List.nil() + : annotations.getDeclarationAttributes(); + } + + public boolean hasAnnotations() { + return (annotations != null && !annotations.isEmpty()); + } + + public boolean hasTypeAnnotations() { + return (annotations != null && !annotations.isTypesEmpty()); + } + + public void prependAttributes(List l) { + if (l.nonEmpty()) { + initedAnnos().prepend(l); + } + } + + public void resetAnnotations() { + initedAnnos().reset(); + } + + public void setAttributes(Symbol other) { + if (annotations != null || other.annotations != null) { + initedAnnos().setAttributes(other.annotations); + } + } + + public void setDeclarationAttributes(List a) { + if (annotations != null || a.nonEmpty()) { + initedAnnos().setDeclarationAttributes(a); + } + } + + public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext ctx) { + initedAnnos().setDeclarationAttributesWithCompletion(ctx); + } + + public void setTypeAttributes(List a) { + if (annotations != null || a.nonEmpty()) { + if (annotations == null) + annotations = new Annotations(this); + annotations.setTypeAttributes(a); + } + } + + private Annotations initedAnnos() { + if (annotations == null) + annotations = new Annotations(this); + return annotations; + } + + /** This method is intended for debugging only. */ + public Annotations getAnnotations() { + return annotations; + } + + // + /** Construct a symbol with given kind, flags, name, type and owner. */ public Symbol(int kind, long flags, Name name, Type type, Symbol owner) { @@ -207,6 +319,10 @@ public abstract class Symbol implements Element { } } + public boolean isDeprecated() { + return (flags_field & DEPRECATED) != 0; + } + public boolean isStatic() { return (flags() & STATIC) != 0 || @@ -726,8 +842,9 @@ public abstract class Symbol implements Element { } private void mergeAttributes() { - if (annotations.isEmpty() && - !package_info.annotations.isEmpty()) { + if (annotations == null && + package_info.annotations != null) { + annotations = new Annotations(this); annotations.setAttributes(package_info.annotations); } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java index 6ac82e5cfa5..260715dff64 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java @@ -271,8 +271,8 @@ public class TypeAnnotations { } } - sym.annotations.reset(); - sym.annotations.setDeclarationAttributes(declAnnos.toList()); + sym.resetAnnotations(); + sym.setDeclarationAttributes(declAnnos.toList()); if (typeAnnos.isEmpty()) { return; @@ -284,7 +284,7 @@ public class TypeAnnotations { // When type is null, put the type annotations to the symbol. // This is used for constructor return annotations, for which // no appropriate type exists. - sym.annotations.appendUniqueTypes(typeAnnotations); + sym.appendUniqueTypeAttributes(typeAnnotations); return; } @@ -318,7 +318,7 @@ public class TypeAnnotations { sym.type = type; } - sym.annotations.appendUniqueTypes(typeAnnotations); + sym.appendUniqueTypeAttributes(typeAnnotations); if (sym.getKind() == ElementKind.PARAMETER || sym.getKind() == ElementKind.LOCAL_VARIABLE || @@ -326,7 +326,7 @@ public class TypeAnnotations { sym.getKind() == ElementKind.EXCEPTION_PARAMETER) { // Make sure all type annotations from the symbol are also // on the owner. - sym.owner.annotations.appendUniqueTypes(sym.getRawTypeAttributes()); + sym.owner.appendUniqueTypeAttributes(sym.getRawTypeAttributes()); } } @@ -855,7 +855,7 @@ public class TypeAnnotations { Assert.error("Found unexpected type annotation for variable: " + v + " with kind: " + v.getKind()); } if (v.getKind() != ElementKind.FIELD) { - v.owner.annotations.appendUniqueTypes(v.getRawTypeAttributes()); + v.owner.appendUniqueTypeAttributes(v.getRawTypeAttributes()); } return; diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 98195d2622a..475ebcf7b04 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -757,11 +757,10 @@ public class Attr extends JCTree.Visitor { // env.info.enclVar.attributes_field might not yet have been evaluated, and so might be // null. In that case, calling augment will throw an NPE. To avoid this, for now we // revert to the jdk 6 behavior and ignore the (unevaluated) attributes. - if (env.info.enclVar.annotations.pendingCompletion()) { + if (env.info.enclVar.annotationsPendingCompletion()) { env.info.lint = lintEnv.info.lint; } else { - env.info.lint = lintEnv.info.lint.augment(env.info.enclVar.annotations, - env.info.enclVar.flags()); + env.info.lint = lintEnv.info.lint.augment(env.info.enclVar); } Lint prevLint = chk.setLint(env.info.lint); @@ -881,7 +880,7 @@ public class Attr extends JCTree.Visitor { MethodSymbol m = tree.sym; boolean isDefaultMethod = (m.flags() & DEFAULT) != 0; - Lint lint = env.info.lint.augment(m.annotations, m.flags()); + Lint lint = env.info.lint.augment(m); Lint prevLint = chk.setLint(lint); MethodSymbol prevMethod = chk.setMethod(m); try { @@ -1052,7 +1051,7 @@ public class Attr extends JCTree.Visitor { } VarSymbol v = tree.sym; - Lint lint = env.info.lint.augment(v.annotations, v.flags()); + Lint lint = env.info.lint.augment(v); Lint prevLint = chk.setLint(lint); // Check that the variable's declared type is well-formed. @@ -1121,9 +1120,9 @@ public class Attr extends JCTree.Visitor { ClassSymbol cs = (ClassSymbol)env.info.scope.owner; List tas = localEnv.info.scope.owner.getRawTypeAttributes(); if ((tree.flags & STATIC) != 0) { - cs.annotations.appendClassInitTypeAttributes(tas); + cs.appendClassInitTypeAttributes(tas); } else { - cs.annotations.appendInitTypeAttributes(tas); + cs.appendInitTypeAttributes(tas); } } @@ -4118,7 +4117,7 @@ public class Attr extends JCTree.Visitor { lintEnv = lintEnv.next; // Having found the enclosing lint value, we can initialize the lint value for this class - env.info.lint = lintEnv.info.lint.augment(c.annotations, c.flags()); + env.info.lint = lintEnv.info.lint.augment(c); Lint prevLint = chk.setLint(env.info.lint); JavaFileObject prev = log.useSource(c.sourcefile); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java index 1165a151aa2..e1094b6f9d1 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java @@ -161,7 +161,7 @@ public class Enter extends JCTree.Visitor { Env lintEnv = localEnv; while (lintEnv.info.lint == null) lintEnv = lintEnv.next; - localEnv.info.lint = lintEnv.info.lint.augment(sym.annotations, sym.flags()); + localEnv.info.lint = lintEnv.info.lint.augment(sym); return localEnv; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java index 85ce604ff4f..d1280935955 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -434,7 +434,7 @@ public class Flow { Lint lintPrev = lint; pendingExits = new ListBuffer(); - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); try { // process all the static initializers @@ -470,7 +470,7 @@ public class Flow { if (tree.body == null) return; Lint lintPrev = lint; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); Assert.check(pendingExits.isEmpty()); @@ -496,7 +496,7 @@ public class Flow { public void visitVarDef(JCVariableDecl tree) { if (tree.init != null) { Lint lintPrev = lint; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); try{ scan(tree.init); } finally { @@ -836,7 +836,7 @@ public class Flow { } classDef = tree; thrown = List.nil(); - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); try { // process all the static initializers @@ -916,7 +916,7 @@ public class Flow { List mthrown = tree.sym.type.getThrownTypes(); Lint lintPrev = lint; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); Assert.check(pendingExits.isEmpty()); @@ -955,7 +955,7 @@ public class Flow { public void visitVarDef(JCVariableDecl tree) { if (tree.init != null) { Lint lintPrev = lint; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); try{ scan(tree.init); } finally { @@ -1580,7 +1580,7 @@ public class Flow { firstadr = nextadr; } classDef = tree; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); try { // define all the static fields @@ -1648,7 +1648,7 @@ public class Flow { int returnadrPrev = returnadr; Lint lintPrev = lint; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); Assert.check(pendingExits.isEmpty()); @@ -1700,7 +1700,7 @@ public class Flow { if (track && tree.sym.owner.kind == MTH) newVar(tree.sym); if (tree.init != null) { Lint lintPrev = lint; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); try{ scanExpr(tree.init); if (track) letInit(tree.pos(), tree.sym); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index a7d98fdac8e..a8ce9494776 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -249,8 +249,8 @@ public class LambdaToMethod extends TreeTranslator { } } if (lambdaTypeAnnos.nonEmpty()) { - owner.annotations.setTypeAttributes(ownerTypeAnnos.toList()); - sym.annotations.setTypeAttributes(lambdaTypeAnnos.toList()); + owner.setTypeAttributes(ownerTypeAnnos.toList()); + sym.setTypeAttributes(lambdaTypeAnnos.toList()); } } @@ -389,15 +389,15 @@ public class LambdaToMethod extends TreeTranslator { if (lambdaContext.getSymbolMap(PARAM).containsKey(tree.sym)) { Symbol translatedSym = lambdaContext.getSymbolMap(PARAM).get(tree.sym); result = make.Ident(translatedSym).setType(tree.type); - translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes()); + translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes()); } else if (lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) { Symbol translatedSym = lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym); result = make.Ident(translatedSym).setType(tree.type); - translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes()); + translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes()); } else if (lambdaContext.getSymbolMap(TYPE_VAR).containsKey(tree.sym)) { Symbol translatedSym = lambdaContext.getSymbolMap(TYPE_VAR).get(tree.sym); result = make.Ident(translatedSym).setType(translatedSym.type); - translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes()); + translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes()); } else if (lambdaContext.getSymbolMap(CAPTURED_VAR).containsKey(tree.sym)) { Symbol translatedSym = lambdaContext.getSymbolMap(CAPTURED_VAR).get(tree.sym); result = make.Ident(translatedSym).setType(tree.type); @@ -1715,8 +1715,8 @@ public class LambdaToMethod extends TreeTranslator { ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym); } if (ret != sym) { - ret.annotations.setDeclarationAttributes(sym.getRawAttributes()); - ret.annotations.setTypeAttributes(sym.getRawTypeAttributes()); + ret.setDeclarationAttributes(sym.getRawAttributes()); + ret.setTypeAttributes(sym.getRawTypeAttributes()); } return ret; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java index 2e08b47b618..fb31aa3134f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java @@ -2360,7 +2360,7 @@ public class Lower extends TreeTranslator { null, List.nil(), List.nil()); ClassSymbol c = tree.packge.package_info; c.flags_field |= flags; - c.annotations.setAttributes(tree.packge.annotations); + c.setAttributes(tree.packge); ClassType ctype = (ClassType) c.type; ctype.supertype_field = syms.objectType; ctype.interfaces_field = List.nil(); @@ -2378,7 +2378,7 @@ public class Lower extends TreeTranslator { return tree.packageAnnotations.nonEmpty(); case NONEMPTY: for (Attribute.Compound a : - tree.packge.annotations.getDeclarationAttributes()) { + tree.packge.getDeclarationAttributes()) { Attribute.RetentionPolicy p = types.getRetention(a); if (p != Attribute.RetentionPolicy.SOURCE) return true; diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java index 62c3fa02e6c..589f2669182 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java @@ -712,7 +712,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { public Env getMethodEnv(JCMethodDecl tree, Env env) { Env mEnv = methodEnv(tree, env); - mEnv.info.lint = mEnv.info.lint.augment(tree.sym.annotations, tree.sym.flags()); + mEnv.info.lint = mEnv.info.lint.augment(tree.sym); for (List l = tree.typarams; l.nonEmpty(); l = l.tail) mEnv.info.scope.enterIfAbsent(l.head.type.tsym); for (List l = tree.params; l.nonEmpty(); l = l.tail) @@ -753,7 +753,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { return; } if (s.kind != PCK) { - s.annotations.reset(); // mark Annotations as incomplete for now + s.resetAnnotations(); // mark Annotations as incomplete for now } annotate.normal(new Annotate.Annotator() { @Override @@ -763,10 +763,10 @@ public class MemberEnter extends JCTree.Visitor implements Completer { @Override public void enterAnnotation() { - Assert.check(s.kind == PCK || s.annotations.pendingCompletion()); + Assert.check(s.kind == PCK || s.annotationsPendingCompletion()); JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile); try { - if (!s.annotations.isEmpty() && + if (s.hasAnnotations() && annotations.nonEmpty()) log.error(annotations.head.pos, "already.annotated", @@ -832,7 +832,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { } } - s.annotations.setDeclarationAttributesWithCompletion( + s.setDeclarationAttributesWithCompletion( annotate.new AnnotateRepeatedContext(env, annotated, pos, log, false)); } @@ -1107,7 +1107,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { } if (s != null) { - s.annotations.appendTypeAttributesWithCompletion( + s.appendTypeAttributesWithCompletion( annotate.new AnnotateRepeatedContext(env, annotated, pos, log, true)); } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java index fe46b2913f1..61761ba9b35 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java @@ -262,9 +262,7 @@ public class TransTypes extends TreeTranslator { * be applied to method addOverrideBridgesIfNeeded */ bridge.params = createBridgeParams(impl, bridge, bridgeType); - if (impl.annotations != null) { - bridge.annotations.setAttributes(impl.annotations); - } + bridge.setAttributes(impl); if (!hypothetical) { JCMethodDecl md = make.MethodDef(bridge, null); @@ -311,9 +309,7 @@ public class TransTypes extends TreeTranslator { while (implParams.nonEmpty() && argTypes.nonEmpty()) { VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC, implParams.head.name, argTypes.head, bridge); - if (implParams.head.annotations != null) { - param.annotations.setAttributes(implParams.head.annotations); - } + param.setAttributes(implParams.head); bridgeParams = bridgeParams.append(param); implParams = implParams.tail; argTypes = argTypes.tail; diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java index ca6ebbb872d..e532eea8595 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -1896,12 +1896,11 @@ public class ClassReader implements Completer { JavaFileObject previousClassFile = currentClassFile; try { currentClassFile = classFile; - Annotations annotations = sym.annotations; List newList = deproxyCompoundList(l); - if (annotations.pendingCompletion()) { - annotations.setDeclarationAttributes(newList); + if (sym.annotationsPendingCompletion()) { + sym.setDeclarationAttributes(newList); } else { - annotations.append(newList); + sym.appendAttributes(newList); } } finally { currentClassFile = previousClassFile; @@ -1935,7 +1934,7 @@ public class ClassReader implements Completer { try { currentClassFile = classFile; List newList = deproxyTypeCompoundList(proxies); - sym.annotations.setTypeAttributes(newList.prependList(sym.getRawTypeAttributes())); + sym.setTypeAttributes(newList.prependList(sym.getRawTypeAttributes())); } finally { currentClassFile = previousClassFile; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java index 90fc63f9e1c..63cff9ffba6 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java @@ -1960,8 +1960,7 @@ public class Code { } private void fillLocalVarPosition(LocalVar lv) { - if (lv == null || lv.sym == null - || lv.sym.annotations.isTypesEmpty()) + if (lv == null || lv.sym == null || !lv.sym.hasTypeAnnotations()) return; for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) { TypeAnnotationPosition p = ta.position; @@ -1979,7 +1978,7 @@ public class Code { for (int i = 0; i < varBufferSize; ++i) { LocalVar lv = varBuffer[i]; if (lv == null || lv.sym == null - || lv.sym.annotations.isTypesEmpty() + || !lv.sym.hasTypeAnnotations() || !lv.sym.isExceptionParameter()) continue; @@ -2028,7 +2027,7 @@ public class Code { // 2) it is an exception type and it contains type annotations if (!varDebugInfo && (!var.sym.isExceptionParameter() || - var.sym.annotations.isTypesEmpty())) return; + var.sym.hasTypeAnnotations())) return; if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return; if (varBuffer == null) varBuffer = new LocalVar[20]; diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java index 739f49db084..f9ceb77d33b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -518,7 +518,7 @@ public class Gen extends JCTree.Visitor { // Insert any instance initializers into all constructors. if (initCode.length() != 0) { List inits = initCode.toList(); - initTAs.addAll(c.annotations.getInitTypeAttributes()); + initTAs.addAll(c.getInitTypeAttributes()); List initTAlist = initTAs.toList(); for (JCTree t : methodDefs) { normalizeMethod((JCMethodDecl)t, inits, initTAlist); @@ -541,9 +541,9 @@ public class Gen extends JCTree.Visitor { methodDefs.append(make.MethodDef(clinit, block)); if (!clinitTAs.isEmpty()) - clinit.annotations.appendUniqueTypes(clinitTAs.toList()); - if (!c.annotations.getClassInitTypeAttributes().isEmpty()) - clinit.annotations.appendUniqueTypes(c.annotations.getClassInitTypeAttributes()); + clinit.appendUniqueTypeAttributes(clinitTAs.toList()); + if (!c.getClassInitTypeAttributes().isEmpty()) + clinit.appendUniqueTypeAttributes(c.getClassInitTypeAttributes()); } // Return all method definitions. return methodDefs.toList(); @@ -560,7 +560,7 @@ public class Gen extends JCTree.Visitor { nonfieldTAs.add(ta); } } - sym.annotations.setTypeAttributes(fieldTAs.toList()); + sym.setTypeAttributes(fieldTAs.toList()); return nonfieldTAs.toList(); } @@ -618,7 +618,7 @@ public class Gen extends JCTree.Visitor { if (md.body.endpos == Position.NOPOS) md.body.endpos = TreeInfo.endPos(md.body.stats.last()); - md.sym.annotations.appendUniqueTypes(initTAs); + md.sym.appendUniqueTypeAttributes(initTAs); } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java index bd8e340b974..be3fe22c1cc 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java @@ -160,7 +160,7 @@ public class JNIWriter { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; - for (Attribute.Compound a: i.sym.annotations.getDeclarationAttributes()) { + for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java b/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java index 98ed8fa5af9..6ee1a188c85 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java +++ b/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -225,11 +225,11 @@ public class CreateSymbols extends AbstractProcessor { } ClassSymbol cs = (ClassSymbol) sym; if (addLegacyAnnotation) { - cs.annotations.prepend(List.of(proprietaryAnno)); + cs.prependAttributes(List.of(proprietaryAnno)); } int p = profiles.getProfile(cs.fullname.toString().replace(".", "/")); if (0 < p && p < profileAnnos.length) - cs.annotations.prepend(List.of(profileAnnos[p])); + cs.prependAttributes(List.of(profileAnnos[p])); writeClass(pool, cs, writer); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java index f6a4da42c32..40ec828b879 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java @@ -1131,6 +1131,14 @@ public class TreeInfo { private static class TypeAnnotationFinder extends TreeScanner { public boolean foundTypeAnno = false; + + @Override + public void scan(JCTree tree) { + if (foundTypeAnno || tree == null) + return; + super.scan(tree); + } + public void visitAnnotation(JCAnnotation tree) { foundTypeAnno = foundTypeAnno || tree.hasTag(TYPE_ANNOTATION); } diff --git a/langtools/test/tools/javac/lib/DPrinter.java b/langtools/test/tools/javac/lib/DPrinter.java index 9f3e88707f5..8df4881cba4 100644 --- a/langtools/test/tools/javac/lib/DPrinter.java +++ b/langtools/test/tools/javac/lib/DPrinter.java @@ -403,7 +403,7 @@ public class DPrinter { printType("type", sym.type, Details.SUMMARY); printType("erasure", sym.erasure_field, Details.SUMMARY); sym.accept(symVisitor, null); - printAnnotations("annotations", sym.annotations, Details.SUMMARY); + printAnnotations("annotations", sym.getAnnotations(), Details.SUMMARY); indent(-1); } } From f3fb3c4777c21c50915760a314a92a4dec151de9 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Tue, 4 Jun 2013 19:39:21 -0700 Subject: [PATCH 152/206] 8010257: remove unused thread-local variables _ScratchA and _ScratchB Remove dead code. Reviewed-by: twisti, coleenp --- hotspot/src/share/vm/runtime/thread.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index d64ca311c65..71007590bbf 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -638,9 +638,6 @@ public: jint _hashStateZ ; void * _schedctl ; - intptr_t _ScratchA, _ScratchB ; // Scratch locations for fast-path sync code - static ByteSize ScratchA_offset() { return byte_offset_of(Thread, _ScratchA ); } - static ByteSize ScratchB_offset() { return byte_offset_of(Thread, _ScratchB ); } volatile jint rng [4] ; // RNG for spin loop From 9fbd8582b46a88dd7134fdb86e63afa3ed70d418 Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Tue, 4 Jun 2013 22:16:15 -0700 Subject: [PATCH 153/206] 8015252: Enable HotSpot build with Clang Reviewed-by: twisti, dholmes, kvn --- hotspot/make/bsd/makefiles/adlc.make | 2 +- hotspot/make/bsd/makefiles/gcc.make | 214 ++++++++++++----- hotspot/make/bsd/makefiles/vm.make | 6 +- hotspot/make/linux/makefiles/adlc.make | 2 +- hotspot/make/linux/makefiles/gcc.make | 220 ++++++++++++++---- hotspot/src/os/bsd/vm/os_bsd.cpp | 43 ---- .../src/os_cpu/linux_x86/vm/linux_x86_32.s | 6 +- .../src/os_cpu/linux_x86/vm/os_linux_x86.cpp | 7 + 8 files changed, 350 insertions(+), 150 deletions(-) diff --git a/hotspot/make/bsd/makefiles/adlc.make b/hotspot/make/bsd/makefiles/adlc.make index ceaa893ec8d..826d256b9eb 100644 --- a/hotspot/make/bsd/makefiles/adlc.make +++ b/hotspot/make/bsd/makefiles/adlc.make @@ -69,7 +69,7 @@ CXXFLAGS += -DASSERT # CFLAGS_WARN holds compiler options to suppress/enable warnings. # Compiler warnings are treated as errors ifneq ($(COMPILER_WARNINGS_FATAL),false) - CFLAGS_WARN = -Werror + CFLAGS_WARN = $(WARNINGS_ARE_ERRORS) endif CFLAGS += $(CFLAGS_WARN) diff --git a/hotspot/make/bsd/makefiles/gcc.make b/hotspot/make/bsd/makefiles/gcc.make index 858173bf203..64fa53441b8 100644 --- a/hotspot/make/bsd/makefiles/gcc.make +++ b/hotspot/make/bsd/makefiles/gcc.make @@ -71,6 +71,11 @@ ifeq ($(SPEC),) CC = $(CC32) endif + ifeq ($(USE_CLANG), true) + CXX = clang++ + CC = clang + endif + HOSTCXX = $(CXX) HOSTCC = $(CC) endif @@ -79,21 +84,79 @@ ifeq ($(SPEC),) endif -# -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only -# prints the numbers (e.g. "2.95", "3.2.1") -CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) -CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) - -# check for precompiled headers support -ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0" -# Allow the user to turn off precompiled headers from the command line. -ifneq ($(USE_PRECOMPILED_HEADER),0) -PRECOMPILED_HEADER_DIR=. -PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp -PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch -endif +ifeq ($(USE_CLANG), true) + CC_VER_MAJOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f1) + CC_VER_MINOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f2) +else + # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only + # prints the numbers (e.g. "2.95", "3.2.1") + CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) + CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) endif +ifeq ($(USE_CLANG), true) + # clang has precompiled headers support by default, but the user can switch + # it off by using 'USE_PRECOMPILED_HEADER=0'. + ifdef LP64 + ifeq ($(USE_PRECOMPILED_HEADER),) + USE_PRECOMPILED_HEADER=1 + endif + else + # We don't support precompiled headers on 32-bit builds because there some files are + # compiled with -fPIC while others are compiled without (see 'NONPIC_OBJ_FILES' rules.make) + # Clang produces an error if the PCH file was compiled with other options than the actual compilation unit. + USE_PRECOMPILED_HEADER=0 + endif + + ifeq ($(USE_PRECOMPILED_HEADER),1) + + ifndef LP64 + $(error " Precompiled Headers only supported on 64-bit platforms!") + endif + + PRECOMPILED_HEADER_DIR=. + PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp + PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch + + PCH_FLAG = -include precompiled.hpp + PCH_FLAG/DEFAULT = $(PCH_FLAG) + PCH_FLAG/NO_PCH = -DNO_PCH + PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@)) + + VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE) + VM_PCH_FLAG/AOUT = + VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO)) + + # We only use precompiled headers for the JVM build + CFLAGS += $(VM_PCH_FLAG) + + # There are some files which don't like precompiled headers + # The following files are build with 'OPT_CFLAGS/NOOPT' (-O0) in the opt build. + # But Clang doesn't support a precompiled header which was compiled with -O3 + # to be used in a compilation unit which uses '-O0'. We could also prepare an + # extra '-O0' PCH file for the opt build and use it here, but it's probably + # not worth the effort as long as only two files need this special handling. + PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH) + PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH) + PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH) + + endif +else # ($(USE_CLANG), true) + # check for precompiled headers support + ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0" + # Allow the user to turn off precompiled headers from the command line. + ifneq ($(USE_PRECOMPILED_HEADER),0) + PRECOMPILED_HEADER_DIR=. + PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp + PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch + endif + endif +endif + +# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. +ifeq ($(USE_PRECOMPILED_HEADER),0) + CFLAGS += -DDONT_USE_PRECOMPILED_HEADER +endif #------------------------------------------------------------------------ # Compiler flags @@ -115,17 +178,31 @@ endif CFLAGS += $(VM_PICFLAG) CFLAGS += -fno-rtti CFLAGS += -fno-exceptions -CFLAGS += -pthread -CFLAGS += -fcheck-new -# version 4 and above support fvisibility=hidden (matches jni_x86.h file) -# except 4.1.2 gives pointless warnings that can't be disabled (afaik) -ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" -CFLAGS += -fvisibility=hidden +ifeq ($(USE_CLANG),) + CFLAGS += -pthread + CFLAGS += -fcheck-new + # version 4 and above support fvisibility=hidden (matches jni_x86.h file) + # except 4.1.2 gives pointless warnings that can't be disabled (afaik) + ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" + CFLAGS += -fvisibility=hidden + endif +else + CFLAGS += -fvisibility=hidden +endif + +ifeq ($(USE_CLANG), true) + # Before Clang 3.1, we had to pass the stack alignment specification directly to llvm with the help of '-mllvm' + # Starting with version 3.1, Clang understands the '-mstack-alignment' (and rejects '-mllvm -stack-alignment') + ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 1 \) \))" "0" + STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mstack-alignment=16 + else + STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mllvm -stack-alignment=16 + endif endif ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) ARCHFLAG/i486 = -m32 -march=i586 -ARCHFLAG/amd64 = -m64 +ARCHFLAG/amd64 = -m64 $(STACK_ALIGNMENT_OPT) ARCHFLAG/ia64 = ARCHFLAG/sparc = -m32 -mcpu=v9 ARCHFLAG/sparcv9 = -m64 -mcpu=v9 @@ -163,14 +240,25 @@ ifneq ($(COMPILER_WARNINGS_FATAL),false) WARNINGS_ARE_ERRORS = -Werror endif -# Except for a few acceptable ones -# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit -# conversions which might affect the values. To avoid that, we need to turn -# it off explicitly. -ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" +ifeq ($(USE_CLANG), true) + # However we need to clean the code up before we can unrestrictedly enable this option with Clang + WARNINGS_ARE_ERRORS += -Wno-unused-value -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses + WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-compare +# Not yet supported by clang in Xcode 4.6.2 +# WARNINGS_ARE_ERRORS += -Wno-tautological-constant-out-of-range-compare + WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess + WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body +endif + WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -else -WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef + +ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" + # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit + # conversions which might affect the values. Only enable it in earlier versions. + WARNING_FLAGS = -Wunused-function + ifeq ($(USE_CLANG),) + WARNINGS_FLAGS += -Wconversion + endif endif CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) @@ -214,14 +302,24 @@ endif OPT_CFLAGS/NOOPT=-O0 -# 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. -ifneq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) = 3 \) \))" "0" -OPT_CFLAGS/mulnode.o += -O0 +# Work around some compiler bugs. +ifeq ($(USE_CLANG), true) + ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1) + OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT) + endif +else + # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. + ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1) + OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT) + endif endif # Flags for generating make dependency flags. -ifneq ("${CC_VER_MAJOR}", "2") -DEPFLAGS = -fpch-deps -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) +DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) +ifeq ($(USE_CLANG),) + ifneq ($(CC_VER_MAJOR), 2) + DEPFLAGS += -fpch-deps + endif endif # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. @@ -249,13 +347,15 @@ endif # statically link libstdc++.so, work with gcc but ignored by g++ STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -# statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. -ifneq ("${CC_VER_MAJOR}", "2") -STATIC_LIBGCC += -static-libgcc -endif +ifeq ($(USE_CLANG),) + # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. + ifneq ("${CC_VER_MAJOR}", "2") + STATIC_LIBGCC += -static-libgcc + endif -ifeq ($(BUILDARCH), ia64) -LFLAGS += -Wl,-relax + ifeq ($(BUILDARCH), ia64) + LFLAGS += -Wl,-relax + endif endif # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. @@ -296,25 +396,31 @@ endif #------------------------------------------------------------------------ # Debug flags -# Use the stabs format for debugging information (this is the default -# on gcc-2.91). It's good enough, has all the information about line -# numbers and local variables, and libjvm.so is only about 16M. -# Change this back to "-g" if you want the most expressive format. -# (warning: that could easily inflate libjvm.so to 150M!) -# Note: The Itanium gcc compiler crashes when using -gstabs. -DEBUG_CFLAGS/ia64 = -g -DEBUG_CFLAGS/amd64 = -g -DEBUG_CFLAGS/arm = -g -DEBUG_CFLAGS/ppc = -g -DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) -ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) -DEBUG_CFLAGS += -gstabs +ifeq ($(USE_CLANG), true) + # Restrict the debug information created by Clang to avoid + # too big object files and speed the build up a little bit + # (see http://llvm.org/bugs/show_bug.cgi?id=7554) + CFLAGS += -flimit-debug-info endif -# DEBUG_BINARIES overrides everything, use full -g debug information +# DEBUG_BINARIES uses full -g debug information for all configs ifeq ($(DEBUG_BINARIES), true) - DEBUG_CFLAGS = -g - CFLAGS += $(DEBUG_CFLAGS) + CFLAGS += -g +else + # Use the stabs format for debugging information (this is the default + # on gcc-2.91). It's good enough, has all the information about line + # numbers and local variables, and libjvm.so is only about 16M. + # Change this back to "-g" if you want the most expressive format. + # (warning: that could easily inflate libjvm.so to 150M!) + # Note: The Itanium gcc compiler crashes when using -gstabs. + DEBUG_CFLAGS/ia64 = -g + DEBUG_CFLAGS/amd64 = -g + DEBUG_CFLAGS/arm = -g + DEBUG_CFLAGS/ppc = -g + DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) + ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) + DEBUG_CFLAGS += -gstabs + endif endif # If we are building HEADLESS, pass on to VM diff --git a/hotspot/make/bsd/makefiles/vm.make b/hotspot/make/bsd/makefiles/vm.make index f668b4e5334..7342ca3a1a7 100644 --- a/hotspot/make/bsd/makefiles/vm.make +++ b/hotspot/make/bsd/makefiles/vm.make @@ -126,7 +126,11 @@ ifneq ($(OS_VENDOR), Darwin) LFLAGS += -Xlinker -z -Xlinker noexecstack endif -LIBS += -lm -pthread +LIBS += -lm + +ifeq ($(USE_CLANG),) + LIBS += -pthread +endif # By default, link the *.o into the library, not the executable. LINK_INTO$(LINK_INTO) = LIBJVM diff --git a/hotspot/make/linux/makefiles/adlc.make b/hotspot/make/linux/makefiles/adlc.make index f1892d7d5cc..25ace2f5f76 100644 --- a/hotspot/make/linux/makefiles/adlc.make +++ b/hotspot/make/linux/makefiles/adlc.make @@ -68,7 +68,7 @@ CXXFLAGS += -DASSERT # CFLAGS_WARN holds compiler options to suppress/enable warnings. # Compiler warnings are treated as errors -CFLAGS_WARN = -Werror +CFLAGS_WARN = $(WARNINGS_ARE_ERRORS) CFLAGS += $(CFLAGS_WARN) OBJECTNAMES = \ diff --git a/hotspot/make/linux/makefiles/gcc.make b/hotspot/make/linux/makefiles/gcc.make index acbfc058835..6ef416dfbec 100644 --- a/hotspot/make/linux/makefiles/gcc.make +++ b/hotspot/make/linux/makefiles/gcc.make @@ -36,8 +36,14 @@ ifeq ($(SPEC),) HOSTCC = gcc STRIP = $(ALT_COMPILER_PATH)/strip else - CXX = g++ - CC = gcc + ifeq ($(USE_CLANG), true) + CXX = clang++ + CC = clang + else + CXX = g++ + CC = gcc + endif + HOSTCXX = $(CXX) HOSTCC = $(CC) STRIP = strip @@ -46,19 +52,79 @@ ifeq ($(SPEC),) endif -# -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only -# prints the numbers (e.g. "2.95", "3.2.1") -CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) -CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) - -# check for precompiled headers support -ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0" -# Allow the user to turn off precompiled headers from the command line. -ifneq ($(USE_PRECOMPILED_HEADER),0) -PRECOMPILED_HEADER_DIR=. -PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp -PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch +ifeq ($(USE_CLANG), true) + CC_VER_MAJOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f1) + CC_VER_MINOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f2) +else + # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only + # prints the numbers (e.g. "2.95", "3.2.1") + CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) + CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) endif + + +ifeq ($(USE_CLANG), true) + # Clang has precompiled headers support by default, but the user can switch + # it off by using 'USE_PRECOMPILED_HEADER=0'. + ifdef LP64 + ifeq ($(USE_PRECOMPILED_HEADER),) + USE_PRECOMPILED_HEADER=1 + endif + else + # We don't support precompiled headers on 32-bit builds because there some files are + # compiled with -fPIC while others are compiled without (see 'NONPIC_OBJ_FILES' rules.make) + # Clang produces an error if the PCH file was compiled with other options than the actual compilation unit. + USE_PRECOMPILED_HEADER=0 + endif + + ifeq ($(USE_PRECOMPILED_HEADER),1) + + ifndef LP64 + $(error " Precompiled Headers only supported on 64-bit platforms!") + endif + + PRECOMPILED_HEADER_DIR=. + PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp + PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch + + PCH_FLAG = -include precompiled.hpp + PCH_FLAG/DEFAULT = $(PCH_FLAG) + PCH_FLAG/NO_PCH = -DNO_PCH + PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@)) + + VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE) + VM_PCH_FLAG/AOUT = + VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO)) + + # We only use precompiled headers for the JVM build + CFLAGS += $(VM_PCH_FLAG) + + # There are some files which don't like precompiled headers + # The following files are build with 'OPT_CFLAGS/NOOPT' (-O0) in the opt build. + # But Clang doesn't support a precompiled header which was compiled with -O3 + # to be used in a compilation unit which uses '-O0'. We could also prepare an + # extra '-O0' PCH file for the opt build and use it here, but it's probably + # not worth the effoert as long as only two files need this special handling. + PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH) + PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH) + PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH) + + endif +else # ($(USE_CLANG), true) + # check for precompiled headers support + ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0" + # Allow the user to turn off precompiled headers from the command line. + ifneq ($(USE_PRECOMPILED_HEADER),0) + PRECOMPILED_HEADER_DIR=. + PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp + PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch + endif + endif +endif + +# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. +ifeq ($(USE_PRECOMPILED_HEADER),0) + CFLAGS += -DDONT_USE_PRECOMPILED_HEADER endif @@ -83,16 +149,30 @@ CFLAGS += $(VM_PICFLAG) CFLAGS += -fno-rtti CFLAGS += -fno-exceptions CFLAGS += -D_REENTRANT -CFLAGS += -fcheck-new -# version 4 and above support fvisibility=hidden (matches jni_x86.h file) -# except 4.1.2 gives pointless warnings that can't be disabled (afaik) -ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" -CFLAGS += -fvisibility=hidden +ifeq ($(USE_CLANG),) + CFLAGS += -fcheck-new + # version 4 and above support fvisibility=hidden (matches jni_x86.h file) + # except 4.1.2 gives pointless warnings that can't be disabled (afaik) + ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" + CFLAGS += -fvisibility=hidden + endif +else + CFLAGS += -fvisibility=hidden +endif + +ifeq ($(USE_CLANG), true) + # Before Clang 3.1, we had to pass the stack alignment specification directly to llvm with the help of '-mllvm' + # Starting with version 3.1, Clang understands the '-mstack-alignment' (and rejects '-mllvm -stack-alignment') + ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 1 \) \))" "0" + STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mstack-alignment=16 + else + STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mllvm -stack-alignment=16 + endif endif ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) ARCHFLAG/i486 = -m32 -march=i586 -ARCHFLAG/amd64 = -m64 +ARCHFLAG/amd64 = -m64 $(STACK_ALIGNMENT_OPT) ARCHFLAG/ia64 = ARCHFLAG/sparc = -m32 -mcpu=v9 ARCHFLAG/sparcv9 = -m64 -mcpu=v9 @@ -126,12 +206,22 @@ endif # Compiler warnings are treated as errors WARNINGS_ARE_ERRORS = -Werror +ifeq ($(USE_CLANG), true) + # However we need to clean the code up before we can unrestrictedly enable this option with Clang + WARNINGS_ARE_ERRORS += -Wno-unused-value -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses + WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-tautological-compare + WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess + WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body +endif + WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit -# conversions which might affect the values. Only enable it in earlier versions. -ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" -WARNING_FLAGS += -Wconversion +ifeq ($(USE_CLANG),) + # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit + # conversions which might affect the values. Only enable it in earlier versions. + ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" + WARNING_FLAGS += -Wconversion + endif endif CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) @@ -165,19 +255,24 @@ endif OPT_CFLAGS/NOOPT=-O0 -# 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. -ifneq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) = 3 \) \))" "0" -OPT_CFLAGS/mulnode.o += -O0 +# Work around some compiler bugs. +ifeq ($(USE_CLANG), true) + ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1) + OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT) + endif +else + # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. + ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1) + OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT) + endif endif # Flags for generating make dependency flags. -ifneq ("${CC_VER_MAJOR}", "2") -DEPFLAGS = -fpch-deps -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) -endif - -# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. -ifeq ($(USE_PRECOMPILED_HEADER),0) -CFLAGS += -DDONT_USE_PRECOMPILED_HEADER +DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) +ifeq ($(USE_CLANG),) + ifneq ("${CC_VER_MAJOR}", "2") + DEPFLAGS += -fpch-deps + endif endif #------------------------------------------------------------------------ @@ -186,24 +281,33 @@ endif # statically link libstdc++.so, work with gcc but ignored by g++ STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -# statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. -ifneq ("${CC_VER_MAJOR}", "2") -STATIC_LIBGCC += -static-libgcc -endif +ifeq ($(USE_CLANG),) + # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. + ifneq ("${CC_VER_MAJOR}", "2") + STATIC_LIBGCC += -static-libgcc + endif -ifeq ($(BUILDARCH), ia64) -LFLAGS += -Wl,-relax + ifeq ($(BUILDARCH), ia64) + LFLAGS += -Wl,-relax + endif endif # Enable linker optimization LFLAGS += -Xlinker -O1 -# If this is a --hash-style=gnu system, use --hash-style=both -# The gnu .hash section won't work on some Linux systems like SuSE 10. -_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu') -ifneq ($(_HAS_HASH_STYLE_GNU),) +ifeq ($(USE_CLANG),) + # If this is a --hash-style=gnu system, use --hash-style=both + # The gnu .hash section won't work on some Linux systems like SuSE 10. + _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu') + ifneq ($(_HAS_HASH_STYLE_GNU),) + LDFLAGS_HASH_STYLE = -Wl,--hash-style=both + endif +else + # Don't know how to find out the 'hash style' of a system as '-dumpspecs' + # doesn't work for Clang. So for now we'll alwys use --hash-style=both LDFLAGS_HASH_STYLE = -Wl,--hash-style=both endif + LFLAGS += $(LDFLAGS_HASH_STYLE) # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. @@ -221,6 +325,13 @@ AOUT_FLAGS += -Xlinker -export-dynamic #------------------------------------------------------------------------ # Debug flags +ifeq ($(USE_CLANG), true) + # Restrict the debug information created by Clang to avoid + # too big object files and speed the build up a little bit + # (see http://llvm.org/bugs/show_bug.cgi?id=7554) + CFLAGS += -flimit-debug-info +endif + # DEBUG_BINARIES uses full -g debug information for all configs ifeq ($(DEBUG_BINARIES), true) CFLAGS += -g @@ -237,7 +348,12 @@ else DEBUG_CFLAGS/ppc = -g DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) - DEBUG_CFLAGS += -gstabs + ifeq ($(USE_CLANG), true) + # Clang doesn't understand -gstabs + OPT_CFLAGS += -g + else + OPT_CFLAGS += -gstabs + endif endif ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) @@ -247,7 +363,12 @@ else FASTDEBUG_CFLAGS/ppc = -g FASTDEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),) - FASTDEBUG_CFLAGS += -gstabs + ifeq ($(USE_CLANG), true) + # Clang doesn't understand -gstabs + OPT_CFLAGS += -g + else + OPT_CFLAGS += -gstabs + endif endif OPT_CFLAGS/ia64 = -g @@ -256,7 +377,12 @@ else OPT_CFLAGS/ppc = -g OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH)) ifeq ($(OPT_CFLAGS/$(BUILDARCH)),) - OPT_CFLAGS += -gstabs + ifeq ($(USE_CLANG), true) + # Clang doesn't understand -gstabs + OPT_CFLAGS += -g + else + OPT_CFLAGS += -gstabs + endif endif endif endif diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index f0b32196f5d..ad3e8320e7e 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -626,8 +626,6 @@ void os::Bsd::hotspot_sigmask(Thread* thread) { ////////////////////////////////////////////////////////////////////////////// // create new thread -static address highest_vm_reserved_address(); - // check if it's safe to start a new thread static bool _thread_safety_check(Thread* thread) { return true; @@ -2112,10 +2110,6 @@ bool os::pd_release_memory(char* addr, size_t size) { return anon_munmap(addr, size); } -static address highest_vm_reserved_address() { - return _highest_vm_reserved_address; -} - static bool bsd_mprotect(char* addr, size_t size, int prot) { // Bsd wants the mprotect address argument to be page aligned. char* bottom = (char*)align_size_down((intptr_t)addr, os::Bsd::page_size()); @@ -2159,43 +2153,6 @@ bool os::Bsd::hugetlbfs_sanity_check(bool warn, size_t page_size) { return false; } -/* -* Set the coredump_filter bits to include largepages in core dump (bit 6) -* -* From the coredump_filter documentation: -* -* - (bit 0) anonymous private memory -* - (bit 1) anonymous shared memory -* - (bit 2) file-backed private memory -* - (bit 3) file-backed shared memory -* - (bit 4) ELF header pages in file-backed private memory areas (it is -* effective only if the bit 2 is cleared) -* - (bit 5) hugetlb private memory -* - (bit 6) hugetlb shared memory -*/ -static void set_coredump_filter(void) { - FILE *f; - long cdm; - - if ((f = fopen("/proc/self/coredump_filter", "r+")) == NULL) { - return; - } - - if (fscanf(f, "%lx", &cdm) != 1) { - fclose(f); - return; - } - - rewind(f); - - if ((cdm & LARGEPAGES_BIT) == 0) { - cdm |= LARGEPAGES_BIT; - fprintf(f, "%#lx", cdm); - } - - fclose(f); -} - // Large page support static size_t _large_page_size = 0; diff --git a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.s b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.s index 08c6391c4cb..d29d31df464 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.s +++ b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.s @@ -241,7 +241,7 @@ acb_CopyLeft: jbe 2f # <= 32 dwords rep; smovl jmp 4f - .=.+8 + .space 8 2: subl %esi,%edi .p2align 4,,15 3: movl (%esi),%edx @@ -378,7 +378,7 @@ acs_CopyRight: rep; smovl jmp 4f # copy aligned dwords - .=.+5 + .space 5 2: subl %esi,%edi .p2align 4,,15 3: movl (%esi),%edx @@ -454,7 +454,7 @@ ci_CopyRight: popl %edi popl %esi ret - .=.+10 + .space 10 2: subl %esi,%edi jmp 4f .p2align 4,,15 diff --git a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp index 4fbea466ced..fa0f1b2aa1c 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp +++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp @@ -93,6 +93,10 @@ address os::current_stack_pointer() { register void *esp; __asm__("mov %%"SPELL_REG_SP", %0":"=r"(esp)); return (address) ((char*)esp + sizeof(long)*2); +#elif defined(__clang__) + intptr_t* esp; + __asm__ __volatile__ ("mov %%"SPELL_REG_SP", %0":"=r"(esp):); + return (address) esp; #else register void *esp __asm__ (SPELL_REG_SP); return (address) esp; @@ -175,6 +179,9 @@ intptr_t* _get_previous_fp() { #ifdef SPARC_WORKS register intptr_t **ebp; __asm__("mov %%"SPELL_REG_FP", %0":"=r"(ebp)); +#elif defined(__clang__) + intptr_t **ebp; + __asm__ __volatile__ ("mov %%"SPELL_REG_FP", %0":"=r"(ebp):); #else register intptr_t **ebp __asm__ (SPELL_REG_FP); #endif From 1e63ac571c9ab26bfacff36e12f35f1fce3f3ad7 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 5 Jun 2013 12:08:49 +0530 Subject: [PATCH 154/206] 8015945: loadWithNewGlobal return value has to be properly wrapped Reviewed-by: lagergren, hannesw --- .../api/scripting/ScriptObjectMirror.java | 53 ++++++++++++++---- .../jdk/nashorn/internal/runtime/Context.java | 3 +- nashorn/test/script/basic/JDK-8015945.js | 55 +++++++++++++++++++ .../test/script/basic/JDK-8015945.js.EXPECTED | 7 +++ 4 files changed, 106 insertions(+), 12 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8015945.js create mode 100644 nashorn/test/script/basic/JDK-8015945.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java index 59ac5fec042..7428a8f67f0 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java +++ b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java @@ -342,20 +342,28 @@ public final class ScriptObjectMirror extends JSObject implements Bindings { }); } - // package-privates below this. - ScriptObject getScriptObject() { - return sobj; - } - static Object translateUndefined(Object obj) { - return (obj == ScriptRuntime.UNDEFINED)? null : obj; - } + // These are public only so that Context can access these. - static Object wrap(final Object obj, final ScriptObject homeGlobal) { + /** + * Make a script object mirror on given object if needed. + * + * @param obj object to be wrapped + * @param homeGlobal global to which this object belongs + * @return wrapped object + */ + public static Object wrap(final Object obj, final ScriptObject homeGlobal) { return (obj instanceof ScriptObject) ? new ScriptObjectMirror((ScriptObject)obj, homeGlobal) : obj; } - static Object unwrap(final Object obj, final ScriptObject homeGlobal) { + /** + * Unwrap a script object mirror if needed. + * + * @param obj object to be unwrapped + * @param homeGlobal global to which this object belongs + * @return unwrapped object + */ + public static Object unwrap(final Object obj, final ScriptObject homeGlobal) { if (obj instanceof ScriptObjectMirror) { final ScriptObjectMirror mirror = (ScriptObjectMirror)obj; return (mirror.global == homeGlobal)? mirror.sobj : obj; @@ -364,7 +372,14 @@ public final class ScriptObjectMirror extends JSObject implements Bindings { return obj; } - static Object[] wrapArray(final Object[] args, final ScriptObject homeGlobal) { + /** + * Wrap an array of object to script object mirrors if needed. + * + * @param args array to be unwrapped + * @param homeGlobal global to which this object belongs + * @return wrapped array + */ + public static Object[] wrapArray(final Object[] args, final ScriptObject homeGlobal) { if (args == null || args.length == 0) { return args; } @@ -378,7 +393,14 @@ public final class ScriptObjectMirror extends JSObject implements Bindings { return newArgs; } - static Object[] unwrapArray(final Object[] args, final ScriptObject homeGlobal) { + /** + * Unwrap an array of script object mirrors if needed. + * + * @param args array to be unwrapped + * @param homeGlobal global to which this object belongs + * @return unwrapped array + */ + public static Object[] unwrapArray(final Object[] args, final ScriptObject homeGlobal) { if (args == null || args.length == 0) { return args; } @@ -391,4 +413,13 @@ public final class ScriptObjectMirror extends JSObject implements Bindings { } return newArgs; } + + // package-privates below this. + ScriptObject getScriptObject() { + return sobj; + } + + static Object translateUndefined(Object obj) { + return (obj == ScriptRuntime.UNDEFINED)? null : obj; + } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index e75bb1b51e2..6126e1a3635 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -48,6 +48,7 @@ import java.security.PrivilegedAction; import java.security.ProtectionDomain; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.util.CheckClassAdapter; +import jdk.nashorn.api.scripting.ScriptObjectMirror; import jdk.nashorn.internal.codegen.Compiler; import jdk.nashorn.internal.codegen.ObjectClassGenerator; import jdk.nashorn.internal.ir.FunctionNode; @@ -518,7 +519,7 @@ public final class Context { setGlobalTrusted(newGlobal); try { - return load(newGlobal, from); + return ScriptObjectMirror.wrap(load(newGlobal, from), newGlobal); } finally { setGlobalTrusted(oldGlobal); } diff --git a/nashorn/test/script/basic/JDK-8015945.js b/nashorn/test/script/basic/JDK-8015945.js new file mode 100644 index 00000000000..5b9962e5d9d --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015945.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8015945: loadWithNewGlobal return value has to be properly wrapped + * + * @test + * @option -scripting + * @run + */ + +var global = loadWithNewGlobal({ name: "", + script: < T pop(final T node) { T expected = node; diff --git a/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java b/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java index 8529a1fe67d..31c07812360 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java @@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir; import java.util.Collections; import java.util.List; - import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; @@ -38,7 +37,7 @@ import jdk.nashorn.internal.ir.visitor.NodeVisitor; public final class ObjectNode extends Node { /** Literal elements. */ - private final List elements; + private final List elements; /** * Constructor @@ -47,12 +46,12 @@ public final class ObjectNode extends Node { * @param finish finish * @param elements the elements used to initialize this ObjectNode */ - public ObjectNode(final long token, final int finish, final List elements) { + public ObjectNode(final long token, final int finish, final List elements) { super(token, finish); this.elements = elements; } - private ObjectNode(final ObjectNode objectNode, final List elements) { + private ObjectNode(final ObjectNode objectNode, final List elements) { super(objectNode); this.elements = elements; } @@ -60,7 +59,7 @@ public final class ObjectNode extends Node { @Override public Node accept(final NodeVisitor visitor) { if (visitor.enterObjectNode(this)) { - return visitor.leaveObjectNode(setElements(Node.accept(visitor, Node.class, elements))); + return visitor.leaveObjectNode(setElements(Node.accept(visitor, PropertyNode.class, elements))); } return this; @@ -92,11 +91,11 @@ public final class ObjectNode extends Node { * Get the elements of this literal node * @return a list of elements */ - public List getElements() { + public List getElements() { return Collections.unmodifiableList(elements); } - private ObjectNode setElements(final List elements) { + private ObjectNode setElements(final List elements) { if (this.elements == elements) { return this; } diff --git a/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java b/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java index d4985ea337e..aa9234efaed 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java +++ b/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java @@ -282,7 +282,7 @@ loop: next(); // Prepare to accumulate elements. - final List elements = new ArrayList<>(); + final List elements = new ArrayList<>(); // Create a block for the object literal. loop: @@ -298,7 +298,7 @@ loop: default: // Get and add the next property. - final Node property = propertyAssignment(); + final PropertyNode property = propertyAssignment(); elements.add(property); // Comma between property assigments is mandatory in JSON. @@ -317,7 +317,7 @@ loop: * Parse a property assignment from the token stream * @return the property assignment as a Node */ - private Node propertyAssignment() { + private PropertyNode propertyAssignment() { // Capture firstToken. final long propertyToken = token; LiteralNode name = null; diff --git a/nashorn/src/jdk/nashorn/internal/parser/Parser.java b/nashorn/src/jdk/nashorn/internal/parser/Parser.java index e4dcf1b7424..ee90b8d9111 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/Parser.java +++ b/nashorn/src/jdk/nashorn/internal/parser/Parser.java @@ -59,7 +59,6 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; - import jdk.nashorn.internal.codegen.CompilerConstants; import jdk.nashorn.internal.codegen.Namespace; import jdk.nashorn.internal.ir.AccessNode; @@ -2028,7 +2027,7 @@ loop: } } - return new ObjectNode(objectToken, finish, new ArrayList(map.values())); + return new ObjectNode(objectToken, finish, new ArrayList<>(map.values())); } /** diff --git a/nashorn/src/jdk/nashorn/internal/runtime/JSONFunctions.java b/nashorn/src/jdk/nashorn/internal/runtime/JSONFunctions.java index ed4d8653425..c296a87accc 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/JSONFunctions.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/JSONFunctions.java @@ -25,9 +25,11 @@ package jdk.nashorn.internal.runtime; +import static jdk.nashorn.internal.runtime.arrays.ArrayIndex.getArrayIndexNoThrow; +import static jdk.nashorn.internal.runtime.arrays.ArrayIndex.isValidArrayIndex; + import java.lang.invoke.MethodHandle; import java.util.Iterator; -import java.util.List; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.ObjectNode; @@ -36,8 +38,6 @@ import jdk.nashorn.internal.ir.UnaryNode; import jdk.nashorn.internal.parser.JSONParser; import jdk.nashorn.internal.parser.TokenType; import jdk.nashorn.internal.runtime.linker.Bootstrap; -import static jdk.nashorn.internal.runtime.arrays.ArrayIndex.getArrayIndexNoThrow; -import static jdk.nashorn.internal.runtime.arrays.ArrayIndex.isValidArrayIndex; /** * Utilities used by "JSON" object implementation. @@ -171,10 +171,8 @@ public final class JSONFunctions { final ObjectNode objNode = (ObjectNode) node; final ScriptObject object = ((GlobalObject)global).newObject(); final boolean strict = global.isStrictContext(); - final List elements = objNode.getElements(); - for (final Node elem : elements) { - final PropertyNode pNode = (PropertyNode) elem; + for (final PropertyNode pNode: objNode.getElements()) { final Node valueNode = pNode.getValue(); final String name = pNode.getKeyName(); From 03ee3a979c1738eb14c11a1bda5f85b5b2d3c3fc Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Wed, 5 Jun 2013 12:17:10 +0200 Subject: [PATCH 156/206] 8015961: Several small code-gardening fixes Reviewed-by: lagergren, sundar --- .../src/jdk/nashorn/internal/codegen/Lower.java | 15 +++++++-------- .../nashorn/internal/codegen/RuntimeCallSite.java | 5 +++-- .../src/jdk/nashorn/internal/ir/FunctionNode.java | 3 +-- .../objects/GenericPropertyDescriptor.java | 4 ++-- .../jdk/nashorn/internal/objects/NativeMath.java | 1 - .../src/jdk/nashorn/internal/runtime/Context.java | 2 +- .../jdk/nashorn/internal/runtime/ListAdapter.java | 9 +++++---- .../internal/runtime/regexp/joni/Parser.java | 4 ++-- 8 files changed, 21 insertions(+), 22 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java index 2747560a6e7..013564c2760 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java @@ -32,7 +32,6 @@ import static jdk.nashorn.internal.codegen.CompilerConstants.THIS; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import jdk.nashorn.internal.ir.BaseNode; import jdk.nashorn.internal.ir.BinaryNode; import jdk.nashorn.internal.ir.Block; @@ -258,7 +257,7 @@ final class Lower extends NodeOperatorVisitor { return throwNode; } - private static Node ensureUniqueNamesIn(final LexicalContext lc, final Node node) { + private static Node ensureUniqueNamesIn(final Node node) { return node.accept(new NodeVisitor(new LexicalContext()) { @Override public Node leaveFunctionNode(final FunctionNode functionNode) { @@ -273,10 +272,10 @@ final class Lower extends NodeOperatorVisitor { }); } - private static List copyFinally(final LexicalContext lc, final Block finallyBody) { + private static List copyFinally(final Block finallyBody) { final List newStatements = new ArrayList<>(); for (final Statement statement : finallyBody.getStatements()) { - newStatements.add((Statement)ensureUniqueNamesIn(lc, statement)); + newStatements.add((Statement)ensureUniqueNamesIn(statement)); if (statement.hasTerminalFlags()) { return newStatements; } @@ -340,7 +339,7 @@ final class Lower extends NodeOperatorVisitor { @Override public Node leaveThrowNode(final ThrowNode throwNode) { if (rethrows.contains(throwNode)) { - final List newStatements = copyFinally(lc, finallyBody); + final List newStatements = copyFinally(finallyBody); if (!isTerminal(newStatements)) { newStatements.add(throwNode); } @@ -374,7 +373,7 @@ final class Lower extends NodeOperatorVisitor { resultNode = null; } - newStatements.addAll(copyFinally(lc, finallyBody)); + newStatements.addAll(copyFinally(finallyBody)); if (!isTerminal(newStatements)) { newStatements.add(expr == null ? returnNode : returnNode.setExpression(resultNode)); } @@ -384,7 +383,7 @@ final class Lower extends NodeOperatorVisitor { private Node copy(final Statement endpoint, final Node targetNode) { if (!insideTry.contains(targetNode)) { - final List newStatements = copyFinally(lc, finallyBody); + final List newStatements = copyFinally(finallyBody); if (!isTerminal(newStatements)) { newStatements.add(endpoint); } @@ -550,7 +549,7 @@ final class Lower extends NodeOperatorVisitor { final FunctionNode currentFunction = lc.getCurrentFunction(); return callNode.setEvalArgs( new CallNode.EvalArgs( - ensureUniqueNamesIn(lc, args.get(0)).accept(this), + ensureUniqueNamesIn(args.get(0)).accept(this), compilerConstant(THIS), evalLocation(callee), currentFunction.isStrict())); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java b/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java index 5bbec96266a..c9f3836ba56 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java @@ -41,10 +41,10 @@ import jdk.nashorn.internal.codegen.CompilerConstants.Call; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.RuntimeNode; import jdk.nashorn.internal.ir.RuntimeNode.Request; -import jdk.nashorn.internal.runtime.ScriptRuntime; -import jdk.nashorn.internal.runtime.linker.Bootstrap; import jdk.nashorn.internal.lookup.Lookup; import jdk.nashorn.internal.lookup.MethodHandleFactory; +import jdk.nashorn.internal.runtime.ScriptRuntime; +import jdk.nashorn.internal.runtime.linker.Bootstrap; /** * Optimistic call site that assumes its Object arguments to be of a boxed type. @@ -333,6 +333,7 @@ public final class RuntimeCallSite extends MutableCallSite { * * Do not call directly * + * @param name current name (with type) of runtime call at the call site * @return next wider specialization method for this RuntimeCallSite */ public MethodHandle next(final String name) { diff --git a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java index 4c5eebb01d7..3640db30e87 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java @@ -30,7 +30,6 @@ import java.util.EnumSet; import java.util.HashSet; import java.util.List; import java.util.Set; - import jdk.nashorn.internal.codegen.CompileUnit; import jdk.nashorn.internal.codegen.Compiler; import jdk.nashorn.internal.codegen.CompilerConstants; @@ -385,7 +384,7 @@ public final class FunctionNode extends LexicalContextNode implements Flags newState = EnumSet.copyOf(this.compilationState); diff --git a/nashorn/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java b/nashorn/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java index f76f7f19878..31afc307fc2 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java +++ b/nashorn/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java @@ -150,11 +150,11 @@ public final class GenericPropertyDescriptor extends ScriptObject implements Pro if (this == obj) { return true; } - if (!(obj instanceof AccessorPropertyDescriptor)) { + if (!(obj instanceof GenericPropertyDescriptor)) { return false; } - final AccessorPropertyDescriptor other = (AccessorPropertyDescriptor)obj; + final GenericPropertyDescriptor other = (GenericPropertyDescriptor)obj; return ScriptRuntime.sameValue(configurable, other.configurable) && ScriptRuntime.sameValue(enumerable, other.enumerable); } diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java b/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java index 50a2d864f29..9b1f226ed2c 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java @@ -31,7 +31,6 @@ import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.SpecializedFunction; import jdk.nashorn.internal.objects.annotations.Where; -import jdk.nashorn.internal.runtime.GlobalFunctions; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptObject; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index 6126e1a3635..d0e3b0200da 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -501,7 +501,7 @@ public final class Context { * * @throws IOException if source cannot be found or loaded */ - public Object loadWithNewGlobal(final Object from) throws IOException, RuntimeException { + public Object loadWithNewGlobal(final Object from) throws IOException { final ScriptObject oldGlobal = getGlobalTrusted(); final ScriptObject newGlobal = AccessController.doPrivileged(new PrivilegedAction() { @Override diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java b/nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java index cc99cd126bf..428cb555fb0 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java @@ -15,10 +15,11 @@ import jdk.nashorn.internal.runtime.linker.InvokeByName; * as dequeues, it's still slightly more efficient to be able to translate dequeue operations into pushes, pops, shifts, * and unshifts, than to blindly translate all list's add/remove operations into splices. Also, it is conceivable that a * custom script object that implements an Array-like API can have a background data representation that is optimized - * for dequeue-like access. Note that with ECMAScript arrays, {@code push} and {@pop} operate at the end of the array, - * while in Java {@code Deque} they operate on the front of the queue and as such the Java dequeue {@link #push(Object)} - * and {@link #pop()} operations will translate to {@code unshift} and {@code shift} script operations respectively, - * while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and {@code pop}. + * for dequeue-like access. Note that with ECMAScript arrays, {@code push} and {@code pop} operate at the end of the + * array, while in Java {@code Deque} they operate on the front of the queue and as such the Java dequeue + * {@link #push(Object)} and {@link #pop()} operations will translate to {@code unshift} and {@code shift} script + * operations respectively, while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and + * {@code pop}. */ public class ListAdapter extends AbstractList implements RandomAccess, Deque { // These add to the back and front of the list diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java index 749b1d4196d..03c99a3c03c 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java @@ -23,23 +23,23 @@ import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsOnOff; import static jdk.nashorn.internal.runtime.regexp.joni.Option.isDontCaptureGroup; import static jdk.nashorn.internal.runtime.regexp.joni.Option.isIgnoreCase; -import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.AnyCharNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; +import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode.CCStateArg; import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; import jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode; import jdk.nashorn.internal.runtime.regexp.joni.ast.StringNode; -import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode.CCStateArg; import jdk.nashorn.internal.runtime.regexp.joni.constants.AnchorType; import jdk.nashorn.internal.runtime.regexp.joni.constants.CCSTATE; import jdk.nashorn.internal.runtime.regexp.joni.constants.CCVALTYPE; import jdk.nashorn.internal.runtime.regexp.joni.constants.EncloseType; import jdk.nashorn.internal.runtime.regexp.joni.constants.NodeType; import jdk.nashorn.internal.runtime.regexp.joni.constants.TokenType; +import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; class Parser extends Lexer { From d7c42983fb719d9829801ccf16f8d8bf6f5cbbba Mon Sep 17 00:00:00 2001 From: Dmitry Markov Date: Wed, 5 Jun 2013 14:21:31 +0400 Subject: [PATCH 157/206] 8015375: Edits to text components hang for clipboard access Reviewed-by: art, anthony --- jdk/src/solaris/native/sun/xawt/XlibWrapper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jdk/src/solaris/native/sun/xawt/XlibWrapper.c b/jdk/src/solaris/native/sun/xawt/XlibWrapper.c index ac6506c5a3c..04dd24b17f1 100644 --- a/jdk/src/solaris/native/sun/xawt/XlibWrapper.c +++ b/jdk/src/solaris/native/sun/xawt/XlibWrapper.c @@ -1946,13 +1946,16 @@ secondary_loop_event(Display* dpy, XEvent* event, char* arg) { JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XNextSecondaryLoopEvent(JNIEnv *env, jclass clazz, jlong display, jlong ptr) { + uint32_t timeout = 1; + AWT_CHECK_HAVE_LOCK(); exitSecondaryLoop = False; while (!exitSecondaryLoop) { if (XCheckIfEvent((Display*) jlong_to_ptr(display), (XEvent*) jlong_to_ptr(ptr), secondary_loop_event, NULL)) { return JNI_TRUE; } - AWT_WAIT(AWT_SECONDARY_LOOP_TIMEOUT); + timeout = (timeout < AWT_SECONDARY_LOOP_TIMEOUT) ? (timeout << 1) : AWT_SECONDARY_LOOP_TIMEOUT; + AWT_WAIT(timeout); } return JNI_FALSE; } From 008916124b415736cb8b170cc3857a6a5b3f00e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Wed, 5 Jun 2013 12:44:24 +0200 Subject: [PATCH 158/206] 8015350: Array.prototype.reduceRight issue with large length and index Reviewed-by: attila, sundar, lagergren --- .../nashorn/internal/objects/NativeArray.java | 22 ++++---- .../runtime/arrays/ArrayIterator.java | 6 +-- .../runtime/arrays/ArrayLikeIterator.java | 8 +-- .../arrays/EmptyArrayLikeIterator.java | 2 +- .../runtime/arrays/IteratorAction.java | 4 +- .../internal/runtime/arrays/MapIterator.java | 4 +- .../runtime/arrays/ReverseArrayIterator.java | 4 +- .../runtime/arrays/ReverseMapIterator.java | 4 +- nashorn/test/script/basic/JDK-8015350.js | 51 +++++++++++++++++++ .../test/script/basic/JDK-8015350.js.EXPECTED | 4 ++ 10 files changed, 82 insertions(+), 27 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8015350.js create mode 100644 nashorn/test/script/basic/JDK-8015350.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java b/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java index 6f9fbcec889..9736376bc9b 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java @@ -75,7 +75,7 @@ public final class NativeArray extends ScriptObject { private static final MethodHandle FILTER_CALLBACK_INVOKER = createIteratorCallbackInvoker(boolean.class); private static final MethodHandle REDUCE_CALLBACK_INVOKER = Bootstrap.createDynamicInvoker("dyn:call", Object.class, - Object.class, Undefined.class, Object.class, Object.class, int.class, Object.class); + Object.class, Undefined.class, Object.class, Object.class, long.class, Object.class); private static final MethodHandle CALL_CMP = Bootstrap.createDynamicInvoker("dyn:call", double.class, ScriptFunction.class, Object.class, Object.class, Object.class); @@ -1086,7 +1086,7 @@ public final class NativeArray extends ScriptObject { private static boolean applyEvery(final Object self, final Object callbackfn, final Object thisArg) { return new IteratorAction(Global.toObject(self), callbackfn, thisArg, true) { @Override - protected boolean forEach(final Object val, final int i) throws Throwable { + protected boolean forEach(final Object val, final long i) throws Throwable { return (result = (boolean)EVERY_CALLBACK_INVOKER.invokeExact(callbackfn, thisArg, val, i, self)); } }.apply(); @@ -1104,7 +1104,7 @@ public final class NativeArray extends ScriptObject { public static Object some(final Object self, final Object callbackfn, final Object thisArg) { return new IteratorAction(Global.toObject(self), callbackfn, thisArg, false) { @Override - protected boolean forEach(final Object val, final int i) throws Throwable { + protected boolean forEach(final Object val, final long i) throws Throwable { return !(result = (boolean)SOME_CALLBACK_INVOKER.invokeExact(callbackfn, thisArg, val, i, self)); } }.apply(); @@ -1122,7 +1122,7 @@ public final class NativeArray extends ScriptObject { public static Object forEach(final Object self, final Object callbackfn, final Object thisArg) { return new IteratorAction(Global.toObject(self), callbackfn, thisArg, ScriptRuntime.UNDEFINED) { @Override - protected boolean forEach(final Object val, final int i) throws Throwable { + protected boolean forEach(final Object val, final long i) throws Throwable { FOREACH_CALLBACK_INVOKER.invokeExact(callbackfn, thisArg, val, i, self); return true; } @@ -1141,9 +1141,9 @@ public final class NativeArray extends ScriptObject { public static Object map(final Object self, final Object callbackfn, final Object thisArg) { return new IteratorAction(Global.toObject(self), callbackfn, thisArg, null) { @Override - protected boolean forEach(final Object val, final int i) throws Throwable { + protected boolean forEach(final Object val, final long i) throws Throwable { final Object r = MAP_CALLBACK_INVOKER.invokeExact(callbackfn, thisArg, val, i, self); - result.defineOwnProperty(index, r); + result.defineOwnProperty((int)index, r); return true; } @@ -1167,12 +1167,12 @@ public final class NativeArray extends ScriptObject { @Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1) public static Object filter(final Object self, final Object callbackfn, final Object thisArg) { return new IteratorAction(Global.toObject(self), callbackfn, thisArg, new NativeArray()) { - private int to = 0; + private long to = 0; @Override - protected boolean forEach(final Object val, final int i) throws Throwable { + protected boolean forEach(final Object val, final long i) throws Throwable { if ((boolean)FILTER_CALLBACK_INVOKER.invokeExact(callbackfn, thisArg, val, i, self)) { - result.defineOwnProperty(to++, val); + result.defineOwnProperty((int)(to++), val); } return true; } @@ -1200,7 +1200,7 @@ public final class NativeArray extends ScriptObject { //if initial value is ScriptRuntime.UNDEFINED - step forward once. return new IteratorAction(Global.toObject(self), callbackfn, ScriptRuntime.UNDEFINED, initialValue, iter) { @Override - protected boolean forEach(final Object val, final int i) throws Throwable { + protected boolean forEach(final Object val, final long i) throws Throwable { // TODO: why can't I declare the second arg as Undefined.class? result = REDUCE_CALLBACK_INVOKER.invokeExact(callbackfn, ScriptRuntime.UNDEFINED, result, val, i, self); return true; @@ -1258,7 +1258,7 @@ public final class NativeArray extends ScriptObject { private static MethodHandle createIteratorCallbackInvoker(final Class rtype) { return Bootstrap.createDynamicInvoker("dyn:call", rtype, Object.class, Object.class, Object.class, - int.class, Object.class); + long.class, Object.class); } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayIterator.java b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayIterator.java index 3b9905a2577..e250c748a62 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayIterator.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayIterator.java @@ -36,7 +36,7 @@ public class ArrayIterator extends ArrayLikeIterator { protected final ScriptObject array; /** length of array */ - protected final int length; + protected final long length; /** * Constructor @@ -46,7 +46,7 @@ public class ArrayIterator extends ArrayLikeIterator { protected ArrayIterator(final ScriptObject array, final boolean includeUndefined) { super(includeUndefined); this.array = array; - this.length = (int) array.getArray().length(); + this.length = array.getArray().length(); } /** @@ -63,7 +63,7 @@ public class ArrayIterator extends ArrayLikeIterator { } @Override - public int getLength() { + public long getLength() { return length; } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java index 5061683a355..48505f4471e 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java @@ -38,7 +38,7 @@ import jdk.nashorn.internal.runtime.ScriptObject; abstract public class ArrayLikeIterator implements Iterator { /** current element index in iteration */ - protected int index; + protected long index; /** should undefined elements be included in the iteration? */ protected final boolean includeUndefined; @@ -65,7 +65,7 @@ abstract public class ArrayLikeIterator implements Iterator { * Go the the next valid element index of the iterator * @return next index */ - protected int bumpIndex() { + protected long bumpIndex() { return index++; } @@ -73,7 +73,7 @@ abstract public class ArrayLikeIterator implements Iterator { * Return the next valid element index of the iterator * @return next index */ - public int nextIndex() { + public long nextIndex() { return index; } @@ -86,7 +86,7 @@ abstract public class ArrayLikeIterator implements Iterator { * Get the length of the iteration * @return length */ - public abstract int getLength(); + public abstract long getLength(); /** * ArrayLikeIterator factory diff --git a/nashorn/src/jdk/nashorn/internal/runtime/arrays/EmptyArrayLikeIterator.java b/nashorn/src/jdk/nashorn/internal/runtime/arrays/EmptyArrayLikeIterator.java index 5264283a3a9..e94f8cf3682 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/EmptyArrayLikeIterator.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/EmptyArrayLikeIterator.java @@ -47,7 +47,7 @@ final class EmptyArrayLikeIterator extends ArrayLikeIterator { } @Override - public int getLength() { + public long getLength() { return 0; } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java b/nashorn/src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java index 9fb4eed895e..7568f41b766 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java @@ -49,7 +49,7 @@ public abstract class IteratorAction { protected T result; /** Current array index of iterator */ - protected int index; + protected long index; /** Iterator object */ private final ArrayLikeIterator iter; @@ -134,6 +134,6 @@ public abstract class IteratorAction { * * @throws Throwable if invocation throws an exception/error */ - protected abstract boolean forEach(final Object val, final int i) throws Throwable; + protected abstract boolean forEach(final Object val, final long i) throws Throwable; } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/arrays/MapIterator.java b/nashorn/src/jdk/nashorn/internal/runtime/arrays/MapIterator.java index fdf9d3a4047..f8b40cfea8a 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/MapIterator.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/MapIterator.java @@ -49,8 +49,8 @@ class MapIterator extends ArrayLikeIterator { } @Override - public int getLength() { - return (int) length; + public long getLength() { + return length; } @Override diff --git a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ReverseArrayIterator.java b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ReverseArrayIterator.java index 72a47a93c0d..f9ba0ff0057 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ReverseArrayIterator.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ReverseArrayIterator.java @@ -39,7 +39,7 @@ public final class ReverseArrayIterator extends ArrayIterator { */ public ReverseArrayIterator(final ScriptObject array, final boolean includeUndefined) { super(array, includeUndefined); - this.index = (int) (array.getArray().length() - 1); + this.index = array.getArray().length() - 1; } @Override @@ -53,7 +53,7 @@ public final class ReverseArrayIterator extends ArrayIterator { } @Override - protected int bumpIndex() { + protected long bumpIndex() { return index--; } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ReverseMapIterator.java b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ReverseMapIterator.java index 760ac7207d0..0822b5a4c02 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ReverseMapIterator.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ReverseMapIterator.java @@ -35,7 +35,7 @@ final class ReverseMapIterator extends MapIterator { ReverseMapIterator(final ScriptObject obj, final boolean includeUndefined) { super(obj, includeUndefined); - this.index = JSType.toInt32(obj.getLength()) - 1; + this.index = JSType.toUint32(obj.getLength()) - 1; } @Override @@ -49,7 +49,7 @@ final class ReverseMapIterator extends MapIterator { } @Override - protected int bumpIndex() { + protected long bumpIndex() { return index--; } } diff --git a/nashorn/test/script/basic/JDK-8015350.js b/nashorn/test/script/basic/JDK-8015350.js new file mode 100644 index 00000000000..c8202969b4c --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015350.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8015350: Array.prototype.reduceRight issue with large length and index + * + * @test + * @run + */ + +function reduce(obj) { + try { + Array.prototype.reduceRight.call(obj, function(acc, v, i, o){ + print(v + i); + throw "stop"; + }, 0); + } catch (error) { + print(error); + } +} + +// array-like object +reduce({ + length:0xffffffff, + 0xfffffffe: "index: " +}); + +// actual sparse array +var array = []; +array[0xfffffffe] = "index: "; +reduce(array); diff --git a/nashorn/test/script/basic/JDK-8015350.js.EXPECTED b/nashorn/test/script/basic/JDK-8015350.js.EXPECTED new file mode 100644 index 00000000000..e8bda2c4e41 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8015350.js.EXPECTED @@ -0,0 +1,4 @@ +index: 4294967294 +stop +index: 4294967294 +stop From 69dcf8a54e427ee1c7ee05086cfa70be6697099b Mon Sep 17 00:00:00 2001 From: Vladislav Karnaukhov Date: Wed, 5 Jun 2013 16:57:33 +0400 Subject: [PATCH 159/206] 8015425: [macosx] A follow-up for the fix 8010721 Reviewed-by: serb, anthony --- jdk/src/macosx/native/sun/awt/AWTWindow.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/macosx/native/sun/awt/AWTWindow.m b/jdk/src/macosx/native/sun/awt/AWTWindow.m index 4a3a4720d02..2997ff4de75 100644 --- a/jdk/src/macosx/native/sun/awt/AWTWindow.m +++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m @@ -539,7 +539,7 @@ AWT_ASSERT_APPKIT_THREAD; AWTWindow *opposite = [AWTWindow lastKeyWindow]; if (!IS(self.styleBits, IS_DIALOG)) { [CMenuBar activate:self.javaMenuBar modallyDisabled:NO]; - } else if (IS(self.styleBits, IS_MODAL)) { + } else if ((opposite != NULL) && IS(self.styleBits, IS_MODAL)) { [CMenuBar activate:opposite->javaMenuBar modallyDisabled:YES]; } [AWTWindow setLastKeyWindow:nil]; From 63c141c5125759fd56f86d21cdf035ce2ff5d217 Mon Sep 17 00:00:00 2001 From: Alexander Zuev Date: Wed, 5 Jun 2013 16:58:10 +0400 Subject: [PATCH 160/206] 7186887: Test T6567415.java can fail on a slow machine Reviewed-by: jjg, ksrini --- langtools/test/tools/javac/6567415/T6567415.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langtools/test/tools/javac/6567415/T6567415.java b/langtools/test/tools/javac/6567415/T6567415.java index 683197e6e84..a308d286b35 100644 --- a/langtools/test/tools/javac/6567415/T6567415.java +++ b/langtools/test/tools/javac/6567415/T6567415.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -137,7 +137,7 @@ public class T6567415 { } }; t.start(); - t.join(1000*10); + t.join(1000*60); System.out.println(t.getState()); if (t.isAlive()) { throw new RuntimeException("Error: compilation is looping"); From a0707f358d6246f05b6d4c0ce88adcae05144ad4 Mon Sep 17 00:00:00 2001 From: James Laskey Date: Wed, 5 Jun 2013 10:32:50 -0300 Subject: [PATCH 161/206] 8015911: $EXEC does not handle large outputs Reviewed-by: sundar, attila --- .../internal/runtime/ScriptingFunctions.java | 77 +++++++++++++------ 1 file changed, 54 insertions(+), 23 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java index 1d046ca96c8..ee1639d01a5 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java @@ -32,9 +32,8 @@ import static jdk.nashorn.internal.lookup.Lookup.MH; import java.io.BufferedReader; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; -import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.util.Map; @@ -165,36 +164,61 @@ public final class ScriptingFunctions { // Start the process. final Process process = processBuilder.start(); + final IOException exception[] = new IOException[2]; + + // Collect output. + final StringBuilder outBuffer = new StringBuilder(); + Thread outThread = new Thread(new Runnable() { + @Override + public void run() { + char buffer[] = new char[1024]; + try (final InputStreamReader inputStream = new InputStreamReader(process.getInputStream())) { + for (int length; (length = inputStream.read(buffer, 0, buffer.length)) != -1; ) { + outBuffer.append(buffer, 0, length); + } + } catch (IOException ex) { + exception[0] = ex; + } + } + }, "$EXEC output"); + + // Collect errors. + final StringBuilder errBuffer = new StringBuilder(); + Thread errThread = new Thread(new Runnable() { + @Override + public void run() { + char buffer[] = new char[1024]; + try (final InputStreamReader inputStream = new InputStreamReader(process.getErrorStream())) { + for (int length; (length = inputStream.read(buffer, 0, buffer.length)) != -1; ) { + outBuffer.append(buffer, 0, length); + } + } catch (IOException ex) { + exception[1] = ex; + } + } + }, "$EXEC error"); + + // Start gathering output. + outThread.start(); + errThread.start(); // If input is present, pass on to process. - try (OutputStream outputStream = process.getOutputStream()) { + try (OutputStreamWriter outputStream = new OutputStreamWriter(process.getOutputStream())) { if (input != UNDEFINED) { - outputStream.write(JSType.toString(input).getBytes()); + String in = JSType.toString(input); + outputStream.write(in, 0, in.length()); } + } catch (IOException ex) { + // Process was not expecting input. May be normal state of affairs. } // Wait for the process to complete. final int exit = process.waitFor(); + outThread.join(); + errThread.join(); - // Collect output. - String out; - try (InputStream inputStream = process.getInputStream()) { - final StringBuilder outBuffer = new StringBuilder(); - for (int ch; (ch = inputStream.read()) != -1; ) { - outBuffer.append((char)ch); - } - out = outBuffer.toString(); - } - - // Collect errors. - String err; - try (InputStream errorStream = process.getErrorStream()) { - final StringBuilder errBuffer = new StringBuilder(); - for (int ch; (ch = errorStream.read()) != -1; ) { - errBuffer.append((char)ch); - } - err = errBuffer.toString(); - } + final String out = outBuffer.toString(); + final String err = errBuffer.toString(); // Set globals for secondary results. final boolean isStrict = global.isStrictContext(); @@ -202,6 +226,13 @@ public final class ScriptingFunctions { global.set(ERR_NAME, err, isStrict); global.set(EXIT_NAME, exit, isStrict); + // Propagate exception if present. + for (int i = 0; i < exception.length; i++) { + if (exception[i] != null) { + throw exception[i]; + } + } + // Return the result from stdout. return out; } From ff6cb043ba2802db79aaae780381569a881e47b5 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Wed, 5 Jun 2013 17:44:50 +0400 Subject: [PATCH 162/206] 8015339: Correct a wording in javadoc of java.awt.ContainerOrderFocusTraversalPolicy Reviewed-by: art, anthony --- .../classes/java/awt/ContainerOrderFocusTraversalPolicy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java b/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java index e2b846285eb..4991b470fd9 100644 --- a/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java +++ b/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java @@ -42,7 +42,7 @@ import sun.util.logging.PlatformLogger; * Component to focus. This behavior can be disabled using the * setImplicitDownCycleTraversal method. *

    - * By default, methods of this class with return a Component only if it is + * By default, methods of this class will return a Component only if it is * visible, displayable, enabled, and focusable. Subclasses can modify this * behavior by overriding the accept method. *

    From 332b758ab0d4566b286f69d6b5ca76e4726fc753 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Wed, 5 Jun 2013 18:15:58 +0400 Subject: [PATCH 163/206] 8013370: Null pointer exception when adding more than 9 accelators to a JMenuBar Reviewed-by: serb --- .../classes/javax/swing/KeyboardManager.java | 5 +- .../KeyboardManager/8013370/Test8013370.java | 110 ++++++++++++++++++ 2 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 jdk/test/javax/swing/KeyboardManager/8013370/Test8013370.java diff --git a/jdk/src/share/classes/javax/swing/KeyboardManager.java b/jdk/src/share/classes/javax/swing/KeyboardManager.java index cb5134bb7fc..3ce79226a5f 100644 --- a/jdk/src/share/classes/javax/swing/KeyboardManager.java +++ b/jdk/src/share/classes/javax/swing/KeyboardManager.java @@ -285,10 +285,11 @@ class KeyboardManager { while (iter.hasMoreElements()) { JMenuBar mb = (JMenuBar)iter.nextElement(); if ( mb.isShowing() && mb.isEnabled() ) { // don't want to give these out - if( !(ks.equals(ksE)) ) { + boolean extended = (ksE != null) && !ksE.equals(ks); + if (extended) { fireBinding(mb, ksE, e, pressed); } - if(ks.equals(ksE) || !e.isConsumed()) { + if (!extended || !e.isConsumed()) { fireBinding(mb, ks, e, pressed); } if (e.isConsumed()) { diff --git a/jdk/test/javax/swing/KeyboardManager/8013370/Test8013370.java b/jdk/test/javax/swing/KeyboardManager/8013370/Test8013370.java new file mode 100644 index 00000000000..2b9856f7272 --- /dev/null +++ b/jdk/test/javax/swing/KeyboardManager/8013370/Test8013370.java @@ -0,0 +1,110 @@ +/* + * 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.Robot; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; + +import javax.swing.AbstractAction; +import javax.swing.InputMap; +import javax.swing.JFrame; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.KeyStroke; +import sun.awt.SunToolkit; + +import static java.awt.event.InputEvent.CTRL_DOWN_MASK; +import static javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW; +import static javax.swing.JOptionPane.showMessageDialog; +import static javax.swing.SwingUtilities.invokeAndWait; + +/* + * @test + * @bug 8013370 + * @summary Ensure that key stroke is not null + * @author Sergey Malenkov + */ + +public class Test8013370 implements Runnable { + public static void main(String[] args) throws Exception { + Test8013370 task = new Test8013370(); + invokeAndWait(task); + + Robot robot = new Robot(); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.keyRelease(KeyEvent.VK_CONTROL); + robot.waitForIdle(); + + invokeAndWait(task); + task.validate(); + } + + private JFrame frame; + private boolean error; + + @Override + public void run() { + if (this.frame == null) { + JMenuBar menu = new JMenuBar() { + @Override + protected boolean processKeyBinding(KeyStroke stroke, KeyEvent event, int condition, boolean pressed) { + if (stroke == null) { + Test8013370.this.error = true; + return false; + } + return super.processKeyBinding(stroke, event, condition, pressed); + } + }; + menu.add(new JMenuItem("Menu")); + + InputMap map = menu.getInputMap(WHEN_IN_FOCUSED_WINDOW); + // We add exactly 10 actions because the ArrayTable is converted + // from a array to a hashtable when more than 8 values are added. + for (int i = 0; i < 9; i++) { + String name = " Action #" + i; + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_A + i, CTRL_DOWN_MASK), name); + + menu.getActionMap().put(name, new AbstractAction(name) { + @Override + public void actionPerformed(ActionEvent event) { + showMessageDialog(null, getValue(NAME)); + } + }); + } + this.frame = new JFrame("8013370"); + this.frame.setJMenuBar(menu); + this.frame.setVisible(true); + } + else { + this.frame.dispose(); + } + } + + private void validate() { + if (this.error) { + throw new Error("KeyStroke is null"); + } + } +} From 6b7b9e67e2086c5260a913ba5ca330cdad384205 Mon Sep 17 00:00:00 2001 From: James Laskey Date: Wed, 5 Jun 2013 12:41:09 -0300 Subject: [PATCH 164/206] 8015910: Nashorn JavaFX includes are out of sync with JavaFX repo Reviewed-by: sundar --- .../internal/runtime/resources/fx/controls.js | 26 ++++----- .../internal/runtime/resources/fx/graphics.js | 54 +++++++++---------- .../internal/runtime/resources/fx/swt.js | 2 +- .../internal/runtime/resources/fx/web.js | 4 +- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/controls.js b/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/controls.js index f550107defa..6a2a89c400c 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/controls.js +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/controls.js @@ -70,7 +70,7 @@ CheckBoxTableCellBuilder = Java.type("javafx.scene.control.cel CheckBoxTreeCell = Java.type("javafx.scene.control.cell.CheckBoxTreeCell"); CheckBoxTreeCellBuilder = Java.type("javafx.scene.control.cell.CheckBoxTreeCellBuilder"); CheckBoxTreeTableCell = Java.type("javafx.scene.control.cell.CheckBoxTreeTableCell"); -CheckBoxTreeTableCellBuilder = Java.type("javafx.scene.control.cell.CheckBoxTreeTableCellBuilder"); +//CheckBoxTreeTableCellBuilder = Java.type("javafx.scene.control.cell.CheckBoxTreeTableCellBuilder"); ChoiceBoxListCell = Java.type("javafx.scene.control.cell.ChoiceBoxListCell"); ChoiceBoxListCellBuilder = Java.type("javafx.scene.control.cell.ChoiceBoxListCellBuilder"); ChoiceBoxTableCell = Java.type("javafx.scene.control.cell.ChoiceBoxTableCell"); @@ -78,7 +78,7 @@ ChoiceBoxTableCellBuilder = Java.type("javafx.scene.control.cel ChoiceBoxTreeCell = Java.type("javafx.scene.control.cell.ChoiceBoxTreeCell"); ChoiceBoxTreeCellBuilder = Java.type("javafx.scene.control.cell.ChoiceBoxTreeCellBuilder"); ChoiceBoxTreeTableCell = Java.type("javafx.scene.control.cell.ChoiceBoxTreeTableCell"); -ChoiceBoxTreeTableCellBuilder = Java.type("javafx.scene.control.cell.ChoiceBoxTreeTableCellBuilder"); +//ChoiceBoxTreeTableCellBuilder = Java.type("javafx.scene.control.cell.ChoiceBoxTreeTableCellBuilder"); ComboBoxListCell = Java.type("javafx.scene.control.cell.ComboBoxListCell"); ComboBoxListCellBuilder = Java.type("javafx.scene.control.cell.ComboBoxListCellBuilder"); ComboBoxTableCell = Java.type("javafx.scene.control.cell.ComboBoxTableCell"); @@ -86,7 +86,7 @@ ComboBoxTableCellBuilder = Java.type("javafx.scene.control.cel ComboBoxTreeCell = Java.type("javafx.scene.control.cell.ComboBoxTreeCell"); ComboBoxTreeCellBuilder = Java.type("javafx.scene.control.cell.ComboBoxTreeCellBuilder"); ComboBoxTreeTableCell = Java.type("javafx.scene.control.cell.ComboBoxTreeTableCell"); -ComboBoxTreeTableCellBuilder = Java.type("javafx.scene.control.cell.ComboBoxTreeTableCellBuilder"); +//ComboBoxTreeTableCellBuilder = Java.type("javafx.scene.control.cell.ComboBoxTreeTableCellBuilder"); MapValueFactory = Java.type("javafx.scene.control.cell.MapValueFactory"); ProgressBarTableCell = Java.type("javafx.scene.control.cell.ProgressBarTableCell"); ProgressBarTreeTableCell = Java.type("javafx.scene.control.cell.ProgressBarTreeTableCell"); @@ -99,9 +99,9 @@ TextFieldTableCellBuilder = Java.type("javafx.scene.control.cel TextFieldTreeCell = Java.type("javafx.scene.control.cell.TextFieldTreeCell"); TextFieldTreeCellBuilder = Java.type("javafx.scene.control.cell.TextFieldTreeCellBuilder"); TextFieldTreeTableCell = Java.type("javafx.scene.control.cell.TextFieldTreeTableCell"); -TextFieldTreeTableCellBuilder = Java.type("javafx.scene.control.cell.TextFieldTreeTableCellBuilder"); +//TextFieldTreeTableCellBuilder = Java.type("javafx.scene.control.cell.TextFieldTreeTableCellBuilder"); TreeItemPropertyValueFactory = Java.type("javafx.scene.control.cell.TreeItemPropertyValueFactory"); -TreeItemPropertyValueFactoryBuilder = Java.type("javafx.scene.control.cell.TreeItemPropertyValueFactoryBuilder"); +//TreeItemPropertyValueFactoryBuilder = Java.type("javafx.scene.control.cell.TreeItemPropertyValueFactoryBuilder"); CellBuilder = Java.type("javafx.scene.control.CellBuilder"); CheckBox = Java.type("javafx.scene.control.CheckBox"); CheckBoxBuilder = Java.type("javafx.scene.control.CheckBoxBuilder"); @@ -167,7 +167,7 @@ RadioButtonBuilder = Java.type("javafx.scene.control.Rad RadioMenuItem = Java.type("javafx.scene.control.RadioMenuItem"); RadioMenuItemBuilder = Java.type("javafx.scene.control.RadioMenuItemBuilder"); ResizeFeaturesBase = Java.type("javafx.scene.control.ResizeFeaturesBase"); -ResizeFeaturesBaseBuilder = Java.type("javafx.scene.control.ResizeFeaturesBaseBuilder"); +//ResizeFeaturesBaseBuilder = Java.type("javafx.scene.control.ResizeFeaturesBaseBuilder"); ScrollBar = Java.type("javafx.scene.control.ScrollBar"); ScrollBarBuilder = Java.type("javafx.scene.control.ScrollBarBuilder"); ScrollPane = Java.type("javafx.scene.control.ScrollPane"); @@ -183,7 +183,7 @@ SeparatorMenuItemBuilder = Java.type("javafx.scene.control.Sep SingleSelectionModel = Java.type("javafx.scene.control.SingleSelectionModel"); Skin = Java.type("javafx.scene.control.Skin"); SkinBase = Java.type("javafx.scene.control.SkinBase"); -SkinBaseBuilder = Java.type("javafx.scene.control.SkinBaseBuilder"); +//SkinBaseBuilder = Java.type("javafx.scene.control.SkinBaseBuilder"); Skinnable = Java.type("javafx.scene.control.Skinnable"); Slider = Java.type("javafx.scene.control.Slider"); SliderBuilder = Java.type("javafx.scene.control.SliderBuilder"); @@ -202,7 +202,7 @@ TableColumn$CellDataFeatures = Java.type("javafx.scene.control.Tab TableColumn$CellEditEvent = Java.type("javafx.scene.control.TableColumn$CellEditEvent"); TableColumn$SortType = Java.type("javafx.scene.control.TableColumn$SortType"); TableColumnBase = Java.type("javafx.scene.control.TableColumnBase"); -TableColumnBaseBuilder = Java.type("javafx.scene.control.TableColumnBaseBuilder"); +//TableColumnBaseBuilder = Java.type("javafx.scene.control.TableColumnBaseBuilder"); TableColumnBuilder = Java.type("javafx.scene.control.TableColumnBuilder"); TableFocusModel = Java.type("javafx.scene.control.TableFocusModel"); TablePosition = Java.type("javafx.scene.control.TablePosition"); @@ -210,7 +210,7 @@ TablePositionBase = Java.type("javafx.scene.control.Tab TableRow = Java.type("javafx.scene.control.TableRow"); TableRowBuilder = Java.type("javafx.scene.control.TableRowBuilder"); TableSelectionModel = Java.type("javafx.scene.control.TableSelectionModel"); -TableSelectionModelBuilder = Java.type("javafx.scene.control.TableSelectionModelBuilder"); +//TableSelectionModelBuilder = Java.type("javafx.scene.control.TableSelectionModelBuilder"); TableView = Java.type("javafx.scene.control.TableView"); TableView$ResizeFeatures = Java.type("javafx.scene.control.TableView$ResizeFeatures"); TableView$TableViewFocusModel = Java.type("javafx.scene.control.TableView$TableViewFocusModel"); @@ -244,21 +244,21 @@ TreeItem$TreeModificationEvent = Java.type("javafx.scene.control.Tre TreeItemBuilder = Java.type("javafx.scene.control.TreeItemBuilder"); TreeSortMode = Java.type("javafx.scene.control.TreeSortMode"); TreeTableCell = Java.type("javafx.scene.control.TreeTableCell"); -TreeTableCellBuilder = Java.type("javafx.scene.control.TreeTableCellBuilder"); +//TreeTableCellBuilder = Java.type("javafx.scene.control.TreeTableCellBuilder"); TreeTableColumn = Java.type("javafx.scene.control.TreeTableColumn"); TreeTableColumn$CellDataFeatures = Java.type("javafx.scene.control.TreeTableColumn$CellDataFeatures"); TreeTableColumn$CellEditEvent = Java.type("javafx.scene.control.TreeTableColumn$CellEditEvent"); TreeTableColumn$SortType = Java.type("javafx.scene.control.TreeTableColumn$SortType"); -TreeTableColumnBuilder = Java.type("javafx.scene.control.TreeTableColumnBuilder"); +//TreeTableColumnBuilder = Java.type("javafx.scene.control.TreeTableColumnBuilder"); TreeTablePosition = Java.type("javafx.scene.control.TreeTablePosition"); TreeTableRow = Java.type("javafx.scene.control.TreeTableRow"); -TreeTableRowBuilder = Java.type("javafx.scene.control.TreeTableRowBuilder"); +//TreeTableRowBuilder = Java.type("javafx.scene.control.TreeTableRowBuilder"); TreeTableView = Java.type("javafx.scene.control.TreeTableView"); TreeTableView$EditEvent = Java.type("javafx.scene.control.TreeTableView$EditEvent"); TreeTableView$ResizeFeatures = Java.type("javafx.scene.control.TreeTableView$ResizeFeatures"); TreeTableView$TreeTableViewFocusModel = Java.type("javafx.scene.control.TreeTableView$TreeTableViewFocusModel"); TreeTableView$TreeTableViewSelectionModel = Java.type("javafx.scene.control.TreeTableView$TreeTableViewSelectionModel"); -TreeTableViewBuilder = Java.type("javafx.scene.control.TreeTableViewBuilder"); +//TreeTableViewBuilder = Java.type("javafx.scene.control.TreeTableViewBuilder"); TreeView = Java.type("javafx.scene.control.TreeView"); TreeView$EditEvent = Java.type("javafx.scene.control.TreeView$EditEvent"); TreeViewBuilder = Java.type("javafx.scene.control.TreeViewBuilder"); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/graphics.js b/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/graphics.js index 9da00bd2948..72f55cd1926 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/graphics.js +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/graphics.js @@ -134,10 +134,10 @@ PrintQuality = Java.type("javafx.print.PrintQuality"); PrintResolution = Java.type("javafx.print.PrintResolution"); PrintSides = Java.type("javafx.print.PrintSides"); AmbientLight = Java.type("javafx.scene.AmbientLight"); -AmbientLightBuilder = Java.type("javafx.scene.AmbientLightBuilder"); +//AmbientLightBuilder = Java.type("javafx.scene.AmbientLightBuilder"); CacheHint = Java.type("javafx.scene.CacheHint"); Camera = Java.type("javafx.scene.Camera"); -CameraBuilder = Java.type("javafx.scene.CameraBuilder"); +//CameraBuilder = Java.type("javafx.scene.CameraBuilder"); Canvas = Java.type("javafx.scene.canvas.Canvas"); CanvasBuilder = Java.type("javafx.scene.canvas.CanvasBuilder"); GraphicsContext = Java.type("javafx.scene.canvas.GraphicsContext"); @@ -209,12 +209,12 @@ Dragboard = Java.type("javafx.scene.input.Dragboard DragEvent = Java.type("javafx.scene.input.DragEvent"); GestureEvent = Java.type("javafx.scene.input.GestureEvent"); InputEvent = Java.type("javafx.scene.input.InputEvent"); -InputEventBuilder = Java.type("javafx.scene.input.InputEventBuilder"); +//InputEventBuilder = Java.type("javafx.scene.input.InputEventBuilder"); InputMethodEvent = Java.type("javafx.scene.input.InputMethodEvent"); InputMethodHighlight = Java.type("javafx.scene.input.InputMethodHighlight"); InputMethodRequests = Java.type("javafx.scene.input.InputMethodRequests"); InputMethodTextRun = Java.type("javafx.scene.input.InputMethodTextRun"); -InputMethodTextRunBuilder = Java.type("javafx.scene.input.InputMethodTextRunBuilder"); +//InputMethodTextRunBuilder = Java.type("javafx.scene.input.InputMethodTextRunBuilder"); KeyCharacterCombination = Java.type("javafx.scene.input.KeyCharacterCombination"); KeyCharacterCombinationBuilder = Java.type("javafx.scene.input.KeyCharacterCombinationBuilder"); KeyCode = Java.type("javafx.scene.input.KeyCode"); @@ -238,35 +238,35 @@ SwipeEvent = Java.type("javafx.scene.input.SwipeEven TouchEvent = Java.type("javafx.scene.input.TouchEvent"); TouchPoint = Java.type("javafx.scene.input.TouchPoint"); TouchPoint$State = Java.type("javafx.scene.input.TouchPoint$State"); -TouchPointBuilder = Java.type("javafx.scene.input.TouchPointBuilder"); +//TouchPointBuilder = Java.type("javafx.scene.input.TouchPointBuilder"); TransferMode = Java.type("javafx.scene.input.TransferMode"); ZoomEvent = Java.type("javafx.scene.input.ZoomEvent"); AnchorPane = Java.type("javafx.scene.layout.AnchorPane"); AnchorPaneBuilder = Java.type("javafx.scene.layout.AnchorPaneBuilder"); Background = Java.type("javafx.scene.layout.Background"); -BackgroundBuilder = Java.type("javafx.scene.layout.BackgroundBuilder"); +//BackgroundBuilder = Java.type("javafx.scene.layout.BackgroundBuilder"); BackgroundFill = Java.type("javafx.scene.layout.BackgroundFill"); -BackgroundFillBuilder = Java.type("javafx.scene.layout.BackgroundFillBuilder"); +//BackgroundFillBuilder = Java.type("javafx.scene.layout.BackgroundFillBuilder"); BackgroundImage = Java.type("javafx.scene.layout.BackgroundImage"); -BackgroundImageBuilder = Java.type("javafx.scene.layout.BackgroundImageBuilder"); +//BackgroundImageBuilder = Java.type("javafx.scene.layout.BackgroundImageBuilder"); BackgroundPosition = Java.type("javafx.scene.layout.BackgroundPosition"); -BackgroundPositionBuilder = Java.type("javafx.scene.layout.BackgroundPositionBuilder"); +//BackgroundPositionBuilder = Java.type("javafx.scene.layout.BackgroundPositionBuilder"); BackgroundRepeat = Java.type("javafx.scene.layout.BackgroundRepeat"); BackgroundSize = Java.type("javafx.scene.layout.BackgroundSize"); -BackgroundSizeBuilder = Java.type("javafx.scene.layout.BackgroundSizeBuilder"); +//BackgroundSizeBuilder = Java.type("javafx.scene.layout.BackgroundSizeBuilder"); Border = Java.type("javafx.scene.layout.Border"); -BorderBuilder = Java.type("javafx.scene.layout.BorderBuilder"); +//BorderBuilder = Java.type("javafx.scene.layout.BorderBuilder"); BorderImage = Java.type("javafx.scene.layout.BorderImage"); -BorderImageBuilder = Java.type("javafx.scene.layout.BorderImageBuilder"); +//BorderImageBuilder = Java.type("javafx.scene.layout.BorderImageBuilder"); BorderPane = Java.type("javafx.scene.layout.BorderPane"); BorderPaneBuilder = Java.type("javafx.scene.layout.BorderPaneBuilder"); BorderRepeat = Java.type("javafx.scene.layout.BorderRepeat"); BorderStroke = Java.type("javafx.scene.layout.BorderStroke"); -BorderStrokeBuilder = Java.type("javafx.scene.layout.BorderStrokeBuilder"); +//BorderStrokeBuilder = Java.type("javafx.scene.layout.BorderStrokeBuilder"); BorderStrokeStyle = Java.type("javafx.scene.layout.BorderStrokeStyle"); -BorderStrokeStyleBuilder = Java.type("javafx.scene.layout.BorderStrokeStyleBuilder"); +//BorderStrokeStyleBuilder = Java.type("javafx.scene.layout.BorderStrokeStyleBuilder"); BorderWidths = Java.type("javafx.scene.layout.BorderWidths"); -BorderWidthsBuilder = Java.type("javafx.scene.layout.BorderWidthsBuilder"); +//BorderWidthsBuilder = Java.type("javafx.scene.layout.BorderWidthsBuilder"); ColumnConstraints = Java.type("javafx.scene.layout.ColumnConstraints"); ColumnConstraintsBuilder = Java.type("javafx.scene.layout.ColumnConstraintsBuilder"); ConstraintsBase = Java.type("javafx.scene.layout.ConstraintsBase"); @@ -291,7 +291,7 @@ TilePaneBuilder = Java.type("javafx.scene.layout.TilePane VBox = Java.type("javafx.scene.layout.VBox"); VBoxBuilder = Java.type("javafx.scene.layout.VBoxBuilder"); LightBase = Java.type("javafx.scene.LightBase"); -LightBaseBuilder = Java.type("javafx.scene.LightBaseBuilder"); +//LightBaseBuilder = Java.type("javafx.scene.LightBaseBuilder"); Node = Java.type("javafx.scene.Node"); NodeBuilder = Java.type("javafx.scene.NodeBuilder"); Color = Java.type("javafx.scene.paint.Color"); @@ -304,19 +304,19 @@ LinearGradientBuilder = Java.type("javafx.scene.paint.LinearGra Material = Java.type("javafx.scene.paint.Material"); Paint = Java.type("javafx.scene.paint.Paint"); PhongMaterial = Java.type("javafx.scene.paint.PhongMaterial"); -PhongMaterialBuilder = Java.type("javafx.scene.paint.PhongMaterialBuilder"); +//PhongMaterialBuilder = Java.type("javafx.scene.paint.PhongMaterialBuilder"); RadialGradient = Java.type("javafx.scene.paint.RadialGradient"); RadialGradientBuilder = Java.type("javafx.scene.paint.RadialGradientBuilder"); Stop = Java.type("javafx.scene.paint.Stop"); StopBuilder = Java.type("javafx.scene.paint.StopBuilder"); ParallelCamera = Java.type("javafx.scene.ParallelCamera"); -ParallelCameraBuilder = Java.type("javafx.scene.ParallelCameraBuilder"); +//ParallelCameraBuilder = Java.type("javafx.scene.ParallelCameraBuilder"); Parent = Java.type("javafx.scene.Parent"); ParentBuilder = Java.type("javafx.scene.ParentBuilder"); PerspectiveCamera = Java.type("javafx.scene.PerspectiveCamera"); PerspectiveCameraBuilder = Java.type("javafx.scene.PerspectiveCameraBuilder"); PointLight = Java.type("javafx.scene.PointLight"); -PointLightBuilder = Java.type("javafx.scene.PointLightBuilder"); +//PointLightBuilder = Java.type("javafx.scene.PointLightBuilder"); //Scene = Java.type("javafx.scene.Scene"); SceneBuilder = Java.type("javafx.scene.SceneBuilder"); Arc = Java.type("javafx.scene.shape.Arc"); @@ -325,7 +325,7 @@ ArcTo = Java.type("javafx.scene.shape.ArcTo"); ArcToBuilder = Java.type("javafx.scene.shape.ArcToBuilder"); ArcType = Java.type("javafx.scene.shape.ArcType"); Box = Java.type("javafx.scene.shape.Box"); -BoxBuilder = Java.type("javafx.scene.shape.BoxBuilder"); +//BoxBuilder = Java.type("javafx.scene.shape.BoxBuilder"); Circle = Java.type("javafx.scene.shape.Circle"); CircleBuilder = Java.type("javafx.scene.shape.CircleBuilder"); ClosePath = Java.type("javafx.scene.shape.ClosePath"); @@ -336,7 +336,7 @@ CubicCurveTo = Java.type("javafx.scene.shape.CubicCurv CubicCurveToBuilder = Java.type("javafx.scene.shape.CubicCurveToBuilder"); CullFace = Java.type("javafx.scene.shape.CullFace"); Cylinder = Java.type("javafx.scene.shape.Cylinder"); -CylinderBuilder = Java.type("javafx.scene.shape.CylinderBuilder"); +//CylinderBuilder = Java.type("javafx.scene.shape.CylinderBuilder"); DrawMode = Java.type("javafx.scene.shape.DrawMode"); Ellipse = Java.type("javafx.scene.shape.Ellipse"); EllipseBuilder = Java.type("javafx.scene.shape.EllipseBuilder"); @@ -349,7 +349,7 @@ LineTo = Java.type("javafx.scene.shape.LineTo"); LineToBuilder = Java.type("javafx.scene.shape.LineToBuilder"); Mesh = Java.type("javafx.scene.shape.Mesh"); MeshView = Java.type("javafx.scene.shape.MeshView"); -MeshViewBuilder = Java.type("javafx.scene.shape.MeshViewBuilder"); +//MeshViewBuilder = Java.type("javafx.scene.shape.MeshViewBuilder"); MoveTo = Java.type("javafx.scene.shape.MoveTo"); MoveToBuilder = Java.type("javafx.scene.shape.MoveToBuilder"); Path = Java.type("javafx.scene.shape.Path"); @@ -368,10 +368,10 @@ Rectangle = Java.type("javafx.scene.shape.Rectangle RectangleBuilder = Java.type("javafx.scene.shape.RectangleBuilder"); Shape = Java.type("javafx.scene.shape.Shape"); Shape3D = Java.type("javafx.scene.shape.Shape3D"); -Shape3DBuilder = Java.type("javafx.scene.shape.Shape3DBuilder"); +//Shape3DBuilder = Java.type("javafx.scene.shape.Shape3DBuilder"); ShapeBuilder = Java.type("javafx.scene.shape.ShapeBuilder"); Sphere = Java.type("javafx.scene.shape.Sphere"); -SphereBuilder = Java.type("javafx.scene.shape.SphereBuilder"); +//SphereBuilder = Java.type("javafx.scene.shape.SphereBuilder"); StrokeLineCap = Java.type("javafx.scene.shape.StrokeLineCap"); StrokeLineJoin = Java.type("javafx.scene.shape.StrokeLineJoin"); StrokeType = Java.type("javafx.scene.shape.StrokeType"); @@ -384,7 +384,7 @@ SnapshotParameters = Java.type("javafx.scene.SnapshotParamet SnapshotParametersBuilder = Java.type("javafx.scene.SnapshotParametersBuilder"); SnapshotResult = Java.type("javafx.scene.SnapshotResult"); SubScene = Java.type("javafx.scene.SubScene"); -SubSceneBuilder = Java.type("javafx.scene.SubSceneBuilder"); +//SubSceneBuilder = Java.type("javafx.scene.SubSceneBuilder"); Font = Java.type("javafx.scene.text.Font"); FontBuilder = Java.type("javafx.scene.text.FontBuilder"); FontPosture = Java.type("javafx.scene.text.FontPosture"); @@ -395,7 +395,7 @@ TextAlignment = Java.type("javafx.scene.text.TextAlignm TextBoundsType = Java.type("javafx.scene.text.TextBoundsType"); TextBuilder = Java.type("javafx.scene.text.TextBuilder"); TextFlow = Java.type("javafx.scene.text.TextFlow"); -TextFlowBuilder = Java.type("javafx.scene.text.TextFlowBuilder"); +//TextFlowBuilder = Java.type("javafx.scene.text.TextFlowBuilder"); Affine = Java.type("javafx.scene.transform.Affine"); AffineBuilder = Java.type("javafx.scene.transform.AffineBuilder"); MatrixType = Java.type("javafx.scene.transform.MatrixType"); @@ -407,7 +407,7 @@ ScaleBuilder = Java.type("javafx.scene.transform.Scale Shear = Java.type("javafx.scene.transform.Shear"); ShearBuilder = Java.type("javafx.scene.transform.ShearBuilder"); Transform = Java.type("javafx.scene.transform.Transform"); -TransformBuilder = Java.type("javafx.scene.transform.TransformBuilder"); +//TransformBuilder = Java.type("javafx.scene.transform.TransformBuilder"); TransformChangedEvent = Java.type("javafx.scene.transform.TransformChangedEvent"); Translate = Java.type("javafx.scene.transform.Translate"); TranslateBuilder = Java.type("javafx.scene.transform.TranslateBuilder"); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/swt.js b/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/swt.js index 526be750f49..82197c71198 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/swt.js +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/swt.js @@ -24,6 +24,6 @@ */ CustomTransfer = Java.type("javafx.embed.swt.CustomTransfer"); -CustomTransferBuilder = Java.type("javafx.embed.swt.CustomTransferBuilder"); +//CustomTransferBuilder = Java.type("javafx.embed.swt.CustomTransferBuilder"); FXCanvas = Java.type("javafx.embed.swt.FXCanvas"); SWTFXUtils = Java.type("javafx.embed.swt.SWTFXUtils"); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/web.js b/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/web.js index d9099345320..606c3c315a9 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/web.js +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/fx/web.js @@ -24,10 +24,10 @@ */ HTMLEditor = Java.type("javafx.scene.web.HTMLEditor"); -HTMLEditorBuilder = Java.type("javafx.scene.web.HTMLEditorBuilder"); +//HTMLEditorBuilder = Java.type("javafx.scene.web.HTMLEditorBuilder"); PopupFeatures = Java.type("javafx.scene.web.PopupFeatures"); PromptData = Java.type("javafx.scene.web.PromptData"); -PromptDataBuilder = Java.type("javafx.scene.web.PromptDataBuilder"); +//PromptDataBuilder = Java.type("javafx.scene.web.PromptDataBuilder"); WebEngine = Java.type("javafx.scene.web.WebEngine"); WebEngineBuilder = Java.type("javafx.scene.web.WebEngineBuilder"); WebEvent = Java.type("javafx.scene.web.WebEvent"); From 2fad2249a2f769677c3c94a1ed23f1fc089701af Mon Sep 17 00:00:00 2001 From: Gerard Ziemski Date: Wed, 5 Jun 2013 14:12:49 -0400 Subject: [PATCH 165/206] 8009302: Mac OS X: JVM crash on infinite recursion on Appkit Thread Use SA_ONSTACK flag to ensure signal gets delivered properly. Reviewed-by: dholmes, coleenp --- hotspot/src/os/bsd/vm/os_bsd.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index f0b32196f5d..5dd7ce7e495 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -3030,6 +3030,19 @@ void os::Bsd::set_signal_handler(int sig, bool set_installed) { sigAct.sa_sigaction = signalHandler; sigAct.sa_flags = SA_SIGINFO|SA_RESTART; } +#if __APPLE__ + // Needed for main thread as XNU (Mac OS X kernel) will only deliver SIGSEGV + // (which starts as SIGBUS) on main thread with faulting address inside "stack+guard pages" + // if the signal handler declares it will handle it on alternate stack. + // Notice we only declare we will handle it on alt stack, but we are not + // actually going to use real alt stack - this is just a workaround. + // Please see ux_exception.c, method catch_mach_exception_raise for details + // link http://www.opensource.apple.com/source/xnu/xnu-2050.18.24/bsd/uxkern/ux_exception.c + if (sig == SIGSEGV) { + sigAct.sa_flags |= SA_ONSTACK; + } +#endif + // Save flags, which are set by ours assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range"); sigflags[sig] = sigAct.sa_flags; From 91f5800bbb388aada32c96acf2b7e243a9396a30 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Wed, 5 Jun 2013 15:20:35 -0700 Subject: [PATCH 166/206] 6983966: remove lzma and upx from repository JDK8 Reviewed-by: tbell, paulk, ngthomas --- common/autoconf/generated-configure.sh | 453 +++++++++++++------------ common/makefiles/Jprt.gmk | 9 + make/deploy-rules.gmk | 32 +- 3 files changed, 248 insertions(+), 246 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index fef9839894a..b5e26db434a 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67 for OpenJDK jdk8. +# Generated by GNU Autoconf 2.68 for OpenJDK jdk8. # # Report bugs to . # @@ -91,6 +91,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -216,11 +217,18 @@ IFS=$as_save_IFS # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. + # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} + case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; + esac + exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -1460,7 +1468,7 @@ Try \`$0 --help' for more information" $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac @@ -1896,7 +1904,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF OpenJDK configure jdk8 -generated by GNU Autoconf 2.67 +generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation @@ -1942,7 +1950,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1980,7 +1988,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile @@ -2018,7 +2026,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_objc_try_compile @@ -2055,7 +2063,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -2092,7 +2100,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp @@ -2105,10 +2113,10 @@ fi ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval "test \"\${$3+set}\"" = set; then : + if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 @@ -2175,7 +2183,7 @@ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" @@ -2184,7 +2192,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_mongrel @@ -2225,7 +2233,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_run @@ -2239,7 +2247,7 @@ ac_fn_cxx_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2257,7 +2265,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_compile @@ -2434,7 +2442,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ rm -f conftest.val fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_compute_int @@ -2480,7 +2488,7 @@ fi # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link @@ -2493,7 +2501,7 @@ ac_fn_cxx_check_func () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2548,7 +2556,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_func @@ -2561,7 +2569,7 @@ ac_fn_c_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2579,7 +2587,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile cat >config.log <<_ACEOF @@ -2587,7 +2595,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.67. Invocation command line was +generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -3782,7 +3790,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1370334570 +DATE_WHEN_GENERATED=1370470729 ############################################################################### # @@ -3820,7 +3828,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BASENAME+set}" = set; then : +if ${ac_cv_path_BASENAME+:} false; then : $as_echo_n "(cached) " >&6 else case $BASENAME in @@ -3879,7 +3887,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BASH+set}" = set; then : +if ${ac_cv_path_BASH+:} false; then : $as_echo_n "(cached) " >&6 else case $BASH in @@ -3938,7 +3946,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CAT+set}" = set; then : +if ${ac_cv_path_CAT+:} false; then : $as_echo_n "(cached) " >&6 else case $CAT in @@ -3997,7 +4005,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHMOD+set}" = set; then : +if ${ac_cv_path_CHMOD+:} false; then : $as_echo_n "(cached) " >&6 else case $CHMOD in @@ -4056,7 +4064,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CMP+set}" = set; then : +if ${ac_cv_path_CMP+:} false; then : $as_echo_n "(cached) " >&6 else case $CMP in @@ -4115,7 +4123,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_COMM+set}" = set; then : +if ${ac_cv_path_COMM+:} false; then : $as_echo_n "(cached) " >&6 else case $COMM in @@ -4174,7 +4182,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CP+set}" = set; then : +if ${ac_cv_path_CP+:} false; then : $as_echo_n "(cached) " >&6 else case $CP in @@ -4233,7 +4241,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CPIO+set}" = set; then : +if ${ac_cv_path_CPIO+:} false; then : $as_echo_n "(cached) " >&6 else case $CPIO in @@ -4292,7 +4300,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CUT+set}" = set; then : +if ${ac_cv_path_CUT+:} false; then : $as_echo_n "(cached) " >&6 else case $CUT in @@ -4351,7 +4359,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_DATE+set}" = set; then : +if ${ac_cv_path_DATE+:} false; then : $as_echo_n "(cached) " >&6 else case $DATE in @@ -4410,7 +4418,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_DIFF+set}" = set; then : +if ${ac_cv_path_DIFF+:} false; then : $as_echo_n "(cached) " >&6 else case $DIFF in @@ -4469,7 +4477,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_DIRNAME+set}" = set; then : +if ${ac_cv_path_DIRNAME+:} false; then : $as_echo_n "(cached) " >&6 else case $DIRNAME in @@ -4528,7 +4536,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ECHO+set}" = set; then : +if ${ac_cv_path_ECHO+:} false; then : $as_echo_n "(cached) " >&6 else case $ECHO in @@ -4587,7 +4595,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_EXPR+set}" = set; then : +if ${ac_cv_path_EXPR+:} false; then : $as_echo_n "(cached) " >&6 else case $EXPR in @@ -4646,7 +4654,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_FILE+set}" = set; then : +if ${ac_cv_path_FILE+:} false; then : $as_echo_n "(cached) " >&6 else case $FILE in @@ -4705,7 +4713,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_FIND+set}" = set; then : +if ${ac_cv_path_FIND+:} false; then : $as_echo_n "(cached) " >&6 else case $FIND in @@ -4764,7 +4772,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_HEAD+set}" = set; then : +if ${ac_cv_path_HEAD+:} false; then : $as_echo_n "(cached) " >&6 else case $HEAD in @@ -4823,7 +4831,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_LN+set}" = set; then : +if ${ac_cv_path_LN+:} false; then : $as_echo_n "(cached) " >&6 else case $LN in @@ -4882,7 +4890,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_LS+set}" = set; then : +if ${ac_cv_path_LS+:} false; then : $as_echo_n "(cached) " >&6 else case $LS in @@ -4941,7 +4949,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_MKDIR+set}" = set; then : +if ${ac_cv_path_MKDIR+:} false; then : $as_echo_n "(cached) " >&6 else case $MKDIR in @@ -5000,7 +5008,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_MKTEMP+set}" = set; then : +if ${ac_cv_path_MKTEMP+:} false; then : $as_echo_n "(cached) " >&6 else case $MKTEMP in @@ -5059,7 +5067,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_MV+set}" = set; then : +if ${ac_cv_path_MV+:} false; then : $as_echo_n "(cached) " >&6 else case $MV in @@ -5118,7 +5126,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PRINTF+set}" = set; then : +if ${ac_cv_path_PRINTF+:} false; then : $as_echo_n "(cached) " >&6 else case $PRINTF in @@ -5177,7 +5185,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_RM+set}" = set; then : +if ${ac_cv_path_RM+:} false; then : $as_echo_n "(cached) " >&6 else case $RM in @@ -5236,7 +5244,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_SH+set}" = set; then : +if ${ac_cv_path_SH+:} false; then : $as_echo_n "(cached) " >&6 else case $SH in @@ -5295,7 +5303,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_SORT+set}" = set; then : +if ${ac_cv_path_SORT+:} false; then : $as_echo_n "(cached) " >&6 else case $SORT in @@ -5354,7 +5362,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TAIL+set}" = set; then : +if ${ac_cv_path_TAIL+:} false; then : $as_echo_n "(cached) " >&6 else case $TAIL in @@ -5413,7 +5421,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TAR+set}" = set; then : +if ${ac_cv_path_TAR+:} false; then : $as_echo_n "(cached) " >&6 else case $TAR in @@ -5472,7 +5480,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TEE+set}" = set; then : +if ${ac_cv_path_TEE+:} false; then : $as_echo_n "(cached) " >&6 else case $TEE in @@ -5531,7 +5539,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TOUCH+set}" = set; then : +if ${ac_cv_path_TOUCH+:} false; then : $as_echo_n "(cached) " >&6 else case $TOUCH in @@ -5590,7 +5598,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TR+set}" = set; then : +if ${ac_cv_path_TR+:} false; then : $as_echo_n "(cached) " >&6 else case $TR in @@ -5649,7 +5657,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_UNAME+set}" = set; then : +if ${ac_cv_path_UNAME+:} false; then : $as_echo_n "(cached) " >&6 else case $UNAME in @@ -5708,7 +5716,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_UNIQ+set}" = set; then : +if ${ac_cv_path_UNIQ+:} false; then : $as_echo_n "(cached) " >&6 else case $UNIQ in @@ -5767,7 +5775,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_WC+set}" = set; then : +if ${ac_cv_path_WC+:} false; then : $as_echo_n "(cached) " >&6 else case $WC in @@ -5826,7 +5834,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_WHICH+set}" = set; then : +if ${ac_cv_path_WHICH+:} false; then : $as_echo_n "(cached) " >&6 else case $WHICH in @@ -5885,7 +5893,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_XARGS+set}" = set; then : +if ${ac_cv_path_XARGS+:} false; then : $as_echo_n "(cached) " >&6 else case $XARGS in @@ -5945,7 +5953,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then : +if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -5995,7 +6003,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then : +if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -6070,7 +6078,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : +if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -6149,7 +6157,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } -if test "${ac_cv_path_FGREP+set}" = set; then : +if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 @@ -6228,7 +6236,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } -if test "${ac_cv_path_SED+set}" = set; then : +if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ @@ -6314,7 +6322,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_NAWK+set}" = set; then : +if ${ac_cv_path_NAWK+:} false; then : $as_echo_n "(cached) " >&6 else case $NAWK in @@ -6378,7 +6386,7 @@ THEPWDCMD=pwd set dummy cygpath; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CYGPATH+set}" = set; then : +if ${ac_cv_path_CYGPATH+:} false; then : $as_echo_n "(cached) " >&6 else case $CYGPATH in @@ -6418,7 +6426,7 @@ fi set dummy readlink; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_READLINK+set}" = set; then : +if ${ac_cv_path_READLINK+:} false; then : $as_echo_n "(cached) " >&6 else case $READLINK in @@ -6458,7 +6466,7 @@ fi set dummy df; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_DF+set}" = set; then : +if ${ac_cv_path_DF+:} false; then : $as_echo_n "(cached) " >&6 else case $DF in @@ -6498,7 +6506,7 @@ fi set dummy SetFile; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_SETFILE+set}" = set; then : +if ${ac_cv_path_SETFILE+:} false; then : $as_echo_n "(cached) " >&6 else case $SETFILE in @@ -6544,7 +6552,7 @@ $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then : +if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias @@ -6578,7 +6586,7 @@ case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then : +if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then @@ -6611,7 +6619,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } -if test "${ac_cv_target+set}" = set; then : +if ${ac_cv_target+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then @@ -8023,7 +8031,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PKGHANDLER+set}" = set; then : +if ${ac_cv_prog_PKGHANDLER+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PKGHANDLER"; then @@ -8388,7 +8396,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHECK_GMAKE+set}" = set; then : +if ${ac_cv_path_CHECK_GMAKE+:} false; then : $as_echo_n "(cached) " >&6 else case $CHECK_GMAKE in @@ -8742,7 +8750,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHECK_MAKE+set}" = set; then : +if ${ac_cv_path_CHECK_MAKE+:} false; then : $as_echo_n "(cached) " >&6 else case $CHECK_MAKE in @@ -9101,7 +9109,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHECK_TOOLSDIR_GMAKE+set}" = set; then : +if ${ac_cv_path_CHECK_TOOLSDIR_GMAKE+:} false; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_GMAKE in @@ -9454,7 +9462,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHECK_TOOLSDIR_MAKE+set}" = set; then : +if ${ac_cv_path_CHECK_TOOLSDIR_MAKE+:} false; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_MAKE in @@ -9850,7 +9858,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_UNZIP+set}" = set; then : +if ${ac_cv_path_UNZIP+:} false; then : $as_echo_n "(cached) " >&6 else case $UNZIP in @@ -9909,7 +9917,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ZIP+set}" = set; then : +if ${ac_cv_path_ZIP+:} false; then : $as_echo_n "(cached) " >&6 else case $ZIP in @@ -9968,7 +9976,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} set dummy ldd; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_LDD+set}" = set; then : +if ${ac_cv_path_LDD+:} false; then : $as_echo_n "(cached) " >&6 else case $LDD in @@ -10014,7 +10022,7 @@ fi set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_OTOOL+set}" = set; then : +if ${ac_cv_path_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else case $OTOOL in @@ -10059,7 +10067,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_READELF+set}" = set; then : +if ${ac_cv_path_READELF+:} false; then : $as_echo_n "(cached) " >&6 else case $READELF in @@ -10102,7 +10110,7 @@ done set dummy hg; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_HG+set}" = set; then : +if ${ac_cv_path_HG+:} false; then : $as_echo_n "(cached) " >&6 else case $HG in @@ -10142,7 +10150,7 @@ fi set dummy stat; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_STAT+set}" = set; then : +if ${ac_cv_path_STAT+:} false; then : $as_echo_n "(cached) " >&6 else case $STAT in @@ -10182,7 +10190,7 @@ fi set dummy time; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TIME+set}" = set; then : +if ${ac_cv_path_TIME+:} false; then : $as_echo_n "(cached) " >&6 else case $TIME in @@ -10227,7 +10235,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_COMM+set}" = set; then : +if ${ac_cv_path_COMM+:} false; then : $as_echo_n "(cached) " >&6 else case $COMM in @@ -10289,7 +10297,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_XATTR+set}" = set; then : +if ${ac_cv_path_XATTR+:} false; then : $as_echo_n "(cached) " >&6 else case $XATTR in @@ -10345,7 +10353,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} set dummy codesign; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CODESIGN+set}" = set; then : +if ${ac_cv_path_CODESIGN+:} false; then : $as_echo_n "(cached) " >&6 else case $CODESIGN in @@ -10409,7 +10417,7 @@ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : +if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -10452,7 +10460,7 @@ if test -z "$ac_cv_path_PKG_CONFIG"; then set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in @@ -10625,7 +10633,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_BDEPS_UNZIP+set}" = set; then : +if ${ac_cv_prog_BDEPS_UNZIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_UNZIP"; then @@ -10671,7 +10679,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_BDEPS_FTP+set}" = set; then : +if ${ac_cv_prog_BDEPS_FTP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_FTP"; then @@ -11971,7 +11979,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } set dummy javac; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_JAVAC_CHECK+set}" = set; then : +if ${ac_cv_path_JAVAC_CHECK+:} false; then : $as_echo_n "(cached) " >&6 else case $JAVAC_CHECK in @@ -12011,7 +12019,7 @@ fi set dummy java; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_JAVA_CHECK+set}" = set; then : +if ${ac_cv_path_JAVA_CHECK+:} false; then : $as_echo_n "(cached) " >&6 else case $JAVA_CHECK in @@ -16340,7 +16348,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_JTREGEXE+set}" = set; then : +if ${ac_cv_path_JTREGEXE+:} false; then : $as_echo_n "(cached) " >&6 else case $JTREGEXE in @@ -16408,7 +16416,7 @@ if test "x$OPENJDK_TARGET_OS" = "xwindows"; then set dummy link; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CYGWIN_LINK+set}" = set; then : +if ${ac_cv_path_CYGWIN_LINK+:} false; then : $as_echo_n "(cached) " >&6 else case $CYGWIN_LINK in @@ -17835,7 +17843,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BUILD_CC+set}" = set; then : +if ${ac_cv_path_BUILD_CC+:} false; then : $as_echo_n "(cached) " >&6 else case $BUILD_CC in @@ -18146,7 +18154,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BUILD_CXX+set}" = set; then : +if ${ac_cv_path_BUILD_CXX+:} false; then : $as_echo_n "(cached) " >&6 else case $BUILD_CXX in @@ -18455,7 +18463,7 @@ $as_echo "$as_me: Rewriting BUILD_CXX to \"$new_complete\"" >&6;} set dummy ld; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BUILD_LD+set}" = set; then : +if ${ac_cv_path_BUILD_LD+:} false; then : $as_echo_n "(cached) " >&6 else case $BUILD_LD in @@ -18971,7 +18979,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TOOLS_DIR_CC+set}" = set; then : +if ${ac_cv_path_TOOLS_DIR_CC+:} false; then : $as_echo_n "(cached) " >&6 else case $TOOLS_DIR_CC in @@ -19023,7 +19031,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_POTENTIAL_CC+set}" = set; then : +if ${ac_cv_path_POTENTIAL_CC+:} false; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CC in @@ -19436,7 +19444,7 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PROPER_COMPILER_CC+set}" = set; then : +if ${ac_cv_prog_PROPER_COMPILER_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CC"; then @@ -19480,7 +19488,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CC"; then @@ -19930,7 +19938,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -19974,7 +19982,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -20255,7 +20263,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : +if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -20306,7 +20314,7 @@ OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : +if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -20343,7 +20351,7 @@ ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : +if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -20421,7 +20429,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : +if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -20544,7 +20552,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TOOLS_DIR_CXX+set}" = set; then : +if ${ac_cv_path_TOOLS_DIR_CXX+:} false; then : $as_echo_n "(cached) " >&6 else case $TOOLS_DIR_CXX in @@ -20596,7 +20604,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_POTENTIAL_CXX+set}" = set; then : +if ${ac_cv_path_POTENTIAL_CXX+:} false; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CXX in @@ -21009,7 +21017,7 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PROPER_COMPILER_CXX+set}" = set; then : +if ${ac_cv_prog_PROPER_COMPILER_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CXX"; then @@ -21053,7 +21061,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+set}" = set; then : +if ${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CXX"; then @@ -21507,7 +21515,7 @@ if test -z "$CXX"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CXX+set}" = set; then : +if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then @@ -21551,7 +21559,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : +if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then @@ -21629,7 +21637,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : +if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21666,7 +21674,7 @@ ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } -if test "${ac_cv_prog_cxx_g+set}" = set; then : +if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag @@ -21764,7 +21772,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJC+set}" = set; then : +if ${ac_cv_prog_OBJC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJC"; then @@ -21808,7 +21816,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJC+set}" = set; then : +if ${ac_cv_prog_ac_ct_OBJC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJC"; then @@ -21884,7 +21892,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Objective C compiler" >&5 $as_echo_n "checking whether we are using the GNU Objective C compiler... " >&6; } -if test "${ac_cv_objc_compiler_gnu+set}" = set; then : +if ${ac_cv_objc_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21921,7 +21929,7 @@ ac_test_OBJCFLAGS=${OBJCFLAGS+set} ac_save_OBJCFLAGS=$OBJCFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $OBJC accepts -g" >&5 $as_echo_n "checking whether $OBJC accepts -g... " >&6; } -if test "${ac_cv_prog_objc_g+set}" = set; then : +if ${ac_cv_prog_objc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_objc_werror_flag=$ac_objc_werror_flag @@ -22297,7 +22305,7 @@ if test "x$OPENJDK_TARGET_OS" != xwindows; then set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AR+set}" = set; then : +if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then @@ -22337,7 +22345,7 @@ if test -z "$ac_cv_prog_AR"; then set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : +if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then @@ -22679,7 +22687,7 @@ if test "x$OPENJDK_TARGET_OS" = xwindows; then : set dummy link; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_WINLD+set}" = set; then : +if ${ac_cv_prog_WINLD+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$WINLD"; then @@ -23018,7 +23026,7 @@ $as_echo "yes" >&6; } set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_MT+set}" = set; then : +if ${ac_cv_prog_MT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MT"; then @@ -23339,7 +23347,7 @@ $as_echo "$as_me: Rewriting MT to \"$new_complete\"" >&6;} set dummy rc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_RC+set}" = set; then : +if ${ac_cv_prog_RC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RC"; then @@ -23730,7 +23738,7 @@ fi set dummy lib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_WINAR+set}" = set; then : +if ${ac_cv_prog_WINAR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$WINAR"; then @@ -24036,7 +24044,7 @@ $as_echo "$as_me: Rewriting WINAR to \"$new_complete\"" >&6;} set dummy dumpbin; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_DUMPBIN+set}" = set; then : +if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then @@ -24355,7 +24363,7 @@ if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then : + if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -24755,7 +24763,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then - if test "${ac_cv_prog_CXXCPP+set}" = set; then : + if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded @@ -25173,7 +25181,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris; then set dummy as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_AS+set}" = set; then : +if ${ac_cv_path_AS+:} false; then : $as_echo_n "(cached) " >&6 else case $AS in @@ -25485,7 +25493,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris; then set dummy nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_NM+set}" = set; then : +if ${ac_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else case $NM in @@ -25791,7 +25799,7 @@ $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} set dummy gnm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_GNM+set}" = set; then : +if ${ac_cv_path_GNM+:} false; then : $as_echo_n "(cached) " >&6 else case $GNM in @@ -26097,7 +26105,7 @@ $as_echo "$as_me: Rewriting GNM to \"$new_complete\"" >&6;} set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_STRIP+set}" = set; then : +if ${ac_cv_path_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else case $STRIP in @@ -26403,7 +26411,7 @@ $as_echo "$as_me: Rewriting STRIP to \"$new_complete\"" >&6;} set dummy mcs; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_MCS+set}" = set; then : +if ${ac_cv_path_MCS+:} false; then : $as_echo_n "(cached) " >&6 else case $MCS in @@ -26711,7 +26719,7 @@ elif test "x$OPENJDK_TARGET_OS" != xwindows; then set dummy ${ac_tool_prefix}nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_NM+set}" = set; then : +if ${ac_cv_prog_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then @@ -26751,7 +26759,7 @@ if test -z "$ac_cv_prog_NM"; then set dummy nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_NM+set}" = set; then : +if ${ac_cv_prog_ac_ct_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NM"; then @@ -27071,7 +27079,7 @@ $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then : +if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -27111,7 +27119,7 @@ if test -z "$ac_cv_prog_STRIP"; then set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -27436,7 +27444,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJCOPY+set}" = set; then : +if ${ac_cv_prog_OBJCOPY+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJCOPY"; then @@ -27480,7 +27488,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJCOPY+set}" = set; then : +if ${ac_cv_prog_ac_ct_OBJCOPY+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJCOPY"; then @@ -27807,7 +27815,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJDUMP+set}" = set; then : +if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then @@ -27851,7 +27859,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then @@ -28175,7 +28183,7 @@ if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_LIPO+set}" = set; then : +if ${ac_cv_path_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else case $LIPO in @@ -28492,7 +28500,7 @@ PATH="$OLD_PATH" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -28669,7 +28677,7 @@ fi for ac_header in stdio.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "stdio.h" "ac_cv_header_stdio_h" "$ac_includes_default" -if test "x$ac_cv_header_stdio_h" = x""yes; then : +if test "x$ac_cv_header_stdio_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDIO_H 1 _ACEOF @@ -28698,7 +28706,7 @@ done # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5 $as_echo_n "checking size of int *... " >&6; } -if test "${ac_cv_sizeof_int_p+set}" = set; then : +if ${ac_cv_sizeof_int_p+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (int *))" "ac_cv_sizeof_int_p" "$ac_includes_default"; then : @@ -28755,7 +28763,7 @@ $as_echo "$OPENJDK_TARGET_CPU_BITS bits" >&6; } # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if test "${ac_cv_c_bigendian+set}" = set; then : +if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown @@ -29923,7 +29931,7 @@ if test "x$with_x" = xno; then else case $x_includes,$x_libraries in #( *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #( - *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then : + *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then : $as_echo_n "(cached) " >&6 else # One or both of the vars are not set, and there is no cached value. @@ -30200,7 +30208,7 @@ if ac_fn_cxx_try_link "$LINENO"; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet... " >&6; } -if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then : +if ${ac_cv_lib_dnet_dnet_ntoa+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30234,14 +30242,14 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_dnet_ntoa" = x""yes; then : +if test "x$ac_cv_lib_dnet_dnet_ntoa" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet_stub" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet_stub... " >&6; } -if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then : +if ${ac_cv_lib_dnet_stub_dnet_ntoa+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30275,7 +30283,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = x""yes; then : +if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" fi @@ -30294,14 +30302,14 @@ rm -f core conftest.err conftest.$ac_objext \ # The functions gethostbyname, getservbyname, and inet_addr are # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. ac_fn_cxx_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" -if test "x$ac_cv_func_gethostbyname" = x""yes; then : +if test "x$ac_cv_func_gethostbyname" = xyes; then : fi if test $ac_cv_func_gethostbyname = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 $as_echo_n "checking for gethostbyname in -lnsl... " >&6; } -if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then : +if ${ac_cv_lib_nsl_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30335,14 +30343,14 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 $as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } -if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then : +if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" fi if test $ac_cv_lib_nsl_gethostbyname = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lbsd" >&5 $as_echo_n "checking for gethostbyname in -lbsd... " >&6; } -if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then : +if ${ac_cv_lib_bsd_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30376,7 +30384,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_gethostbyname" >&5 $as_echo "$ac_cv_lib_bsd_gethostbyname" >&6; } -if test "x$ac_cv_lib_bsd_gethostbyname" = x""yes; then : +if test "x$ac_cv_lib_bsd_gethostbyname" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" fi @@ -30391,14 +30399,14 @@ fi # must be given before -lnsl if both are needed. We assume that # if connect needs -lnsl, so does gethostbyname. ac_fn_cxx_check_func "$LINENO" "connect" "ac_cv_func_connect" -if test "x$ac_cv_func_connect" = x""yes; then : +if test "x$ac_cv_func_connect" = xyes; then : fi if test $ac_cv_func_connect = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 $as_echo_n "checking for connect in -lsocket... " >&6; } -if test "${ac_cv_lib_socket_connect+set}" = set; then : +if ${ac_cv_lib_socket_connect+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30432,7 +30440,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 $as_echo "$ac_cv_lib_socket_connect" >&6; } -if test "x$ac_cv_lib_socket_connect" = x""yes; then : +if test "x$ac_cv_lib_socket_connect" = xyes; then : X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" fi @@ -30440,14 +30448,14 @@ fi # Guillermo Gomez says -lposix is necessary on A/UX. ac_fn_cxx_check_func "$LINENO" "remove" "ac_cv_func_remove" -if test "x$ac_cv_func_remove" = x""yes; then : +if test "x$ac_cv_func_remove" = xyes; then : fi if test $ac_cv_func_remove = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for remove in -lposix" >&5 $as_echo_n "checking for remove in -lposix... " >&6; } -if test "${ac_cv_lib_posix_remove+set}" = set; then : +if ${ac_cv_lib_posix_remove+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30481,7 +30489,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix_remove" >&5 $as_echo "$ac_cv_lib_posix_remove" >&6; } -if test "x$ac_cv_lib_posix_remove" = x""yes; then : +if test "x$ac_cv_lib_posix_remove" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" fi @@ -30489,14 +30497,14 @@ fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. ac_fn_cxx_check_func "$LINENO" "shmat" "ac_cv_func_shmat" -if test "x$ac_cv_func_shmat" = x""yes; then : +if test "x$ac_cv_func_shmat" = xyes; then : fi if test $ac_cv_func_shmat = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shmat in -lipc" >&5 $as_echo_n "checking for shmat in -lipc... " >&6; } -if test "${ac_cv_lib_ipc_shmat+set}" = set; then : +if ${ac_cv_lib_ipc_shmat+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30530,7 +30538,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ipc_shmat" >&5 $as_echo "$ac_cv_lib_ipc_shmat" >&6; } -if test "x$ac_cv_lib_ipc_shmat" = x""yes; then : +if test "x$ac_cv_lib_ipc_shmat" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" fi @@ -30548,7 +30556,7 @@ fi # John Interrante, Karl Berry { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IceConnectionNumber in -lICE" >&5 $as_echo_n "checking for IceConnectionNumber in -lICE... " >&6; } -if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then : +if ${ac_cv_lib_ICE_IceConnectionNumber+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30582,7 +30590,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 $as_echo "$ac_cv_lib_ICE_IceConnectionNumber" >&6; } -if test "x$ac_cv_lib_ICE_IceConnectionNumber" = x""yes; then : +if test "x$ac_cv_lib_ICE_IceConnectionNumber" = xyes; then : X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" fi @@ -31601,7 +31609,7 @@ $as_echo "$FREETYPE2_FOUND" >&6; } LDFLAGS="$FREETYPE2_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FT_Init_FreeType in -lfreetype" >&5 $as_echo_n "checking for FT_Init_FreeType in -lfreetype... " >&6; } -if test "${ac_cv_lib_freetype_FT_Init_FreeType+set}" = set; then : +if ${ac_cv_lib_freetype_FT_Init_FreeType+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31635,7 +31643,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_freetype_FT_Init_FreeType" >&5 $as_echo "$ac_cv_lib_freetype_FT_Init_FreeType" >&6; } -if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = x""yes; then : +if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = xyes; then : FREETYPE2_FOUND=true else as_fn_error $? "Could not find freetype2! $HELP_MSG " "$LINENO" 5 @@ -31923,7 +31931,7 @@ fi for ac_header in alsa/asoundlib.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "alsa/asoundlib.h" "ac_cv_header_alsa_asoundlib_h" "$ac_includes_default" -if test "x$ac_cv_header_alsa_asoundlib_h" = x""yes; then : +if test "x$ac_cv_header_alsa_asoundlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ALSA_ASOUNDLIB_H 1 _ACEOF @@ -31982,7 +31990,7 @@ fi USE_EXTERNAL_LIBJPEG=true { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ljpeg" >&5 $as_echo_n "checking for main in -ljpeg... " >&6; } -if test "${ac_cv_lib_jpeg_main+set}" = set; then : +if ${ac_cv_lib_jpeg_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -32010,7 +32018,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_main" >&5 $as_echo "$ac_cv_lib_jpeg_main" >&6; } -if test "x$ac_cv_lib_jpeg_main" = x""yes; then : +if test "x$ac_cv_lib_jpeg_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBJPEG 1 _ACEOF @@ -32059,7 +32067,7 @@ if test "x${with_giflib}" = "xbundled"; then USE_EXTERNAL_LIBGIF=false elif test "x${with_giflib}" = "xsystem"; then ac_fn_cxx_check_header_mongrel "$LINENO" "gif_lib.h" "ac_cv_header_gif_lib_h" "$ac_includes_default" -if test "x$ac_cv_header_gif_lib_h" = x""yes; then : +if test "x$ac_cv_header_gif_lib_h" = xyes; then : else as_fn_error $? "--with-giflib=system specified, but gif_lib.h not found!" "$LINENO" 5 @@ -32068,7 +32076,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DGifGetCode in -lgif" >&5 $as_echo_n "checking for DGifGetCode in -lgif... " >&6; } -if test "${ac_cv_lib_gif_DGifGetCode+set}" = set; then : +if ${ac_cv_lib_gif_DGifGetCode+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -32102,7 +32110,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gif_DGifGetCode" >&5 $as_echo "$ac_cv_lib_gif_DGifGetCode" >&6; } -if test "x$ac_cv_lib_gif_DGifGetCode" = x""yes; then : +if test "x$ac_cv_lib_gif_DGifGetCode" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBGIF 1 _ACEOF @@ -32134,7 +32142,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compress in -lz" >&5 $as_echo_n "checking for compress in -lz... " >&6; } -if test "${ac_cv_lib_z_compress+set}" = set; then : +if ${ac_cv_lib_z_compress+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -32168,7 +32176,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5 $as_echo "$ac_cv_lib_z_compress" >&6; } -if test "x$ac_cv_lib_z_compress" = x""yes; then : +if test "x$ac_cv_lib_z_compress" = xyes; then : ZLIB_FOUND=yes else ZLIB_FOUND=no @@ -32261,7 +32269,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 $as_echo_n "checking for cos in -lm... " >&6; } -if test "${ac_cv_lib_m_cos+set}" = set; then : +if ${ac_cv_lib_m_cos+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -32295,7 +32303,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 $as_echo "$ac_cv_lib_m_cos" >&6; } -if test "x$ac_cv_lib_m_cos" = x""yes; then : +if test "x$ac_cv_lib_m_cos" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF @@ -32319,7 +32327,7 @@ save_LIBS="$LIBS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlopen+set}" = set; then : +if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -32353,7 +32361,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF @@ -32599,7 +32607,7 @@ if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then set dummy llvm-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_LLVM_CONFIG+set}" = set; then : +if ${ac_cv_prog_LLVM_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LLVM_CONFIG"; then @@ -33211,7 +33219,7 @@ fi set dummy ccache; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CCACHE+set}" = set; then : +if ${ac_cv_path_CCACHE+:} false; then : $as_echo_n "(cached) " >&6 else case $CCACHE in @@ -33472,10 +33480,21 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && + if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -33507,7 +33526,7 @@ LTLIBOBJS=$ac_ltlibobjs -: ${CONFIG_STATUS=./config.status} +: "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -33608,6 +33627,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -33915,7 +33935,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.67. Invocation command line was +generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -33978,7 +33998,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ OpenJDK config.status jdk8 -configured by $0, generated by GNU Autoconf 2.67, +configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. @@ -34129,9 +34149,10 @@ fi # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= + tmp= ac_tmp= trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -34139,12 +34160,13 @@ $debug || { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" + test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -34166,7 +34188,7 @@ else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$tmp/subs1.awk" && +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF @@ -34194,7 +34216,7 @@ done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -34242,7 +34264,7 @@ t delim rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -34274,7 +34296,7 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF @@ -34308,7 +34330,7 @@ fi # test -n "$CONFIG_FILES" # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$tmp/defines.awk" <<\_ACAWK || +cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -34320,8 +34342,8 @@ _ACEOF # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_t=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_t"; then + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 @@ -34441,7 +34463,7 @@ do for ac_f do case $ac_f in - -) ac_f="$tmp/stdin";; + -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -34476,7 +34498,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ + *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; @@ -34602,21 +34624,22 @@ s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$tmp/stdin" + rm -f "$ac_tmp/stdin" case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; @@ -34627,20 +34650,20 @@ which seems to be undefined. Please make sure it is defined" >&2;} if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" - } >"$tmp/config.h" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$tmp/config.h" "$ac_file" \ + mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; diff --git a/common/makefiles/Jprt.gmk b/common/makefiles/Jprt.gmk index 576f34d4b4d..4b19dc45e38 100644 --- a/common/makefiles/Jprt.gmk +++ b/common/makefiles/Jprt.gmk @@ -133,6 +133,15 @@ else ifdef ALT_WIXDIR @$(ECHO) " --with-wix=$(call UnixPath,$(ALT_WIXDIR)) " >> $@.tmp endif + ifdef ALT_INSTALL_LZMA_PATH + @$(ECHO) " --with-lzma-path=$(call UnixPath,$(ALT_INSTALL_LZMA_PATH)) " >> $@.tmp + endif + ifdef ALT_INSTALL_UPX_PATH + @$(ECHO) " --with-upx-path=$(call UnixPath,$(ALT_INSTALL_UPX_PATH)) " >> $@.tmp + endif + ifdef ALT_INSTALL_UPX_FILENAME + @$(ECHO) " --with-upx-filename=$(call UnixPath,$(ALT_INSTALL_UPX_FILENAME)) " >> $@.tmp + endif ifdef ALT_CCSS_SIGNING_DIR @$(ECHO) " --with-ccss-signing=$(call UnixPath,$(ALT_CCSS_SIGNING_DIR)) " >> $@.tmp endif diff --git a/make/deploy-rules.gmk b/make/deploy-rules.gmk index fede83a2f3f..69c493dd0fe 100644 --- a/make/deploy-rules.gmk +++ b/make/deploy-rules.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 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,20 +42,6 @@ else endif DEPLOY_BUILD_TARGETS = sanity deploy -# Only build 7-Zip LZMA file compression if it is available -# Enable 7-Zip LZMA file (de)compression for Java Kernel if it is available -ifeq ($(ARCH_DATA_MODEL), 32) - ifeq ($(PLATFORM), windows) - EC_TMP = $(shell if [ -d $(DEPLOY_TOPDIR)/make/lzma ] ; then \ - $(ECHO) true ; \ - else \ - $(ECHO) false ; \ - fi ) - ifeq ($(EC_TMP), true) - DEPLOY_BUILD_TARGETS += extra-comp-all - endif - endif -endif ifneq ($(JQS), off) ifeq ($(ARCH_DATA_MODEL), 32) @@ -65,22 +51,6 @@ ifneq ($(JQS), off) endif endif -ifeq ($(ARCH_DATA_MODEL), 32) - ifeq ($(PLATFORM), windows) - # Only set up to use UPX compression if it is available - UP_TMP = $(shell if [ -d $(DEPLOY_TOPDIR)/make/upx ] ; then \ - $(ECHO) true ; \ - else \ - $(ECHO) false ; \ - fi ) - ifeq ($(UP_TMP), true) - DEPLOY_BUILD_TARGETS += cmd-comp-all - endif - endif -endif - - - ifndef DEV_ONLY DEPLOY_BUILD_TARGETS += images else From 83d9be97c99ceef9826149ed6cc78d2bf5d016e5 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Wed, 5 Jun 2013 15:25:09 -0700 Subject: [PATCH 167/206] 6983966: remove lzma and upx from repository JDK8 Reviewed-by: tbell, paulk, ngthomas --- jdk/make/common/Defs-windows.gmk | 39 +------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/jdk/make/common/Defs-windows.gmk b/jdk/make/common/Defs-windows.gmk index 50a5a66c477..c5c15b3d387 100644 --- a/jdk/make/common/Defs-windows.gmk +++ b/jdk/make/common/Defs-windows.gmk @@ -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 @@ -432,40 +432,3 @@ RC_FLAGS += -d "JDK_BUILD_ID=$(JDK_RC_BUILD_ID)" \ -d "JDK_COPYRIGHT=$(JDK_RC_COPYRIGHT)" \ -d "JDK_NAME=$(JDK_RC_NAME)" \ -d "JDK_FVER=$(JDK_RC_FVER)" - -# Enable 7-Zip LZMA file (de)compression for Java Kernel if it is available -ifeq ($(ARCH_DATA_MODEL), 32) - ifneq ($(KERNEL), off) - # This is a hack to use until 7-Zip (and UPX) bundles can be put - # under /java/devtools. - ifndef DEPLOY_TOPDIR - DEPLOY_TOPDIR=$(JDK_TOPDIR)/../deploy - endif - # Uncomment this block to cause build failure if above assumption false - #DCHK = $(shell if [ ! -d $(DEPLOY_TOPDIR) ] ; then \ - # $(ECHO) deploy_not_a_peer_of_j2se ; \ - #fi ) - #ifeq ($(DCHK), deploy_not_a_peer_of_j2se) - # If a build failure points to control coming here it means - # it means deploy is not in the same directory - # as j2se. Java Kernel can't tolerate that for the time being. - #endif - EC_TMP = $(shell if [ -d $(DEPLOY_TOPDIR)/make/lzma ] ; then \ - $(ECHO) true ; \ - else \ - $(ECHO) false ; \ - fi ) - ifeq ($(EC_TMP), true) - EXTRA_COMP_INSTALL_PATH = lib\\\\deploy\\\\lzma.dll - # Crazy but true: deploy/make/plugin/jinstall/Makefile.jkernel does - # not include deploy/make/common/Defs-windows.gmk, either directly - # or indirectly. But it does include this file, so redundantly declare - # these variables that are in deploy/make/common/Defs-windows.gmk for - # the sake of the Java Kernel part of the deploy build. Whew! - EXTRA_COMP_LIB_NAME = lzma.dll - EXTRA_COMP_PATH = $(OUTPUTDIR)/tmp/deploy/lzma/win32/obj - EXTRA_COMP_CMD_PATH = $(EXTRA_COMP_PATH)/lzma.exe - EXTRA_COMP_LIB_PATH = $(EXTRA_COMP_PATH)/$(EXTRA_COMP_LIB_NAME) - endif - endif -endif From aa61dce719b385509e67565ecd3ac4d14fc8847d Mon Sep 17 00:00:00 2001 From: Albert Noll Date: Thu, 6 Jun 2013 09:29:38 -0700 Subject: [PATCH 168/206] 8014246: remove assert to catch access to object headers in index_oop_from_field_offset_long Reviewed-by: twisti, jrose --- hotspot/src/share/vm/prims/unsafe.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index c511561341d..f30ab81ae20 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -115,8 +115,6 @@ inline jint invocation_key_to_method_slot(jint key) { inline void* index_oop_from_field_offset_long(oop p, jlong field_offset) { jlong byte_offset = field_offset_to_byte_offset(field_offset); - // Don't allow unsafe to be used to read or write the header word of oops - assert(p == NULL || field_offset >= oopDesc::header_size(), "offset must be outside of header"); #ifdef ASSERT if (p != NULL) { assert(byte_offset >= 0 && byte_offset <= (jlong)MAX_OBJECT_SIZE, "sane offset"); From f6fce94513d5cc667790a96a89868701e76855b8 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Jun 2013 09:54:03 -0700 Subject: [PATCH 169/206] Added tag jdk8-b93 for changeset 2567cad1138a --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 729f6cad52d..bc5928f1afd 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -214,3 +214,4 @@ e1a929afcfc492470d50be0b6b0e8dc77d3760b9 jdk8-b88 69b773a221b956a3386933ecdbfeccee0edeac47 jdk8-b90 cb51fb4789ac0b8be4056482077ddfb8f3bd3805 jdk8-b91 3a36c926a7aafa9d4a892a45ef3678e87ad8359b jdk8-b92 +27c51c6e31c1ef36afa0e6efb031f9b13f26c12b jdk8-b93 From 45fa6739924a6786b5eb52f06839ca6129c3e162 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Jun 2013 09:54:05 -0700 Subject: [PATCH 170/206] Added tag jdk8-b93 for changeset 3898a926fa12 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index f928f750ea0..031e7ca843a 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -214,3 +214,4 @@ fe4150590ee597f4e125fea950aa3b352622cc2d jdk8-b89 c8286839d0df04aba819ec4bef12b86babccf30e jdk8-b90 8f7ffb296385f85a4a6d53f9f2d4a7b13a8fa1ff jdk8-b91 717aa26f8e0a1c0e768aebb3a763aca56db0c83e jdk8-b92 +8dc9d7ccbb2d77fd89bc321bb02e67c152aca257 jdk8-b93 From 7c89126c981356a6db252d3230e253e43f0fb9d2 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Jun 2013 09:54:16 -0700 Subject: [PATCH 171/206] Added tag jdk8-b93 for changeset 2b7343cbcbbf --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 8fd9b705d0f..861d062f7a9 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -346,3 +346,4 @@ b19517cecc2e91636d7c16ba2f35e3d3dc628099 hs25-b33 7cbdf0e3725c0c56a2ff7540fc70b6d4b5890d04 jdk8-b91 38da9f4f67096745f851318d792d6468aa1f6cf8 hs25-b34 092018493d3bbeb1c24278fd8c40ff3d76e1fed7 jdk8-b92 +573d86d412cd9d3df7912194c1a540be50e9544e jdk8-b93 From a273490f39e4b92ffe4ab21746684111e8b2cf7c Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Jun 2013 09:54:40 -0700 Subject: [PATCH 172/206] Added tag jdk8-b93 for changeset 3ea33579af2b --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 5df651317b4..a56af230f42 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -214,3 +214,4 @@ eddbc8ad2435a89f64729512337c9f2669e4dd85 jdk8-b87 668acc0e1034bc1bec6d02be92e0dd4a63d0667e jdk8-b90 e3065fb07877c7e96e8b93416fe2ab9a4c9eb2a5 jdk8-b91 1ab5d8d6eab81e65c6c3cf21739474cd67a0e7cf jdk8-b92 +d583a491d63c49eeda4869525048075da1cb596e jdk8-b93 From 5df715fef2c9431697824def188237a762353e05 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Jun 2013 09:54:43 -0700 Subject: [PATCH 173/206] Added tag jdk8-b93 for changeset a233c04832cf --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 199677923db..d85fa49d18b 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -214,3 +214,4 @@ a5e7c2f093c9996ab3419db1565094a07b059e9c jdk8-b86 3e5b9ea5ac35ea7096da484e24a863cf4552179f jdk8-b90 0bb1a9fa56b037d072efdaae5f5b73a0f23c966c jdk8-b91 a0f604766ca14818e2a7b1558cc399499caabf75 jdk8-b92 +7386eca865e1f7216637cdf8dcf3f5d5c255f208 jdk8-b93 From 5de9fe6192f91cbbc7f5fe2fd4e55df21249023b Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Jun 2013 09:55:00 -0700 Subject: [PATCH 174/206] Added tag jdk8-b93 for changeset 9bf66362d942 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 08ec69310ef..b91e542c25e 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -214,3 +214,4 @@ d5228e624826a10ccc5b05f30ad8d839b58fe48d jdk8-b87 c63eda8f63008a4398d2c22ac8d72f7fef6f9238 jdk8-b90 169451cf0cc53bde5af24f9820ea3f35ec4b4df4 jdk8-b91 a2a2a91075ad85becbe10a39d7fd04ef9bea8df5 jdk8-b92 +691d6c6cd332d98b0f0221445a73906776f31f72 jdk8-b93 From e142a2e82d010d9eb3f773eed11e1c2202383cd7 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Jun 2013 09:55:26 -0700 Subject: [PATCH 175/206] Added tag jdk8-b93 for changeset 1697301ac053 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 3d445226a63..c25eb0a4526 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -214,3 +214,4 @@ ec434cfd2752a7742c875c2fe7d556d8b81c0f3a jdk8-b89 e19283cd30a43fca94d8f7639c73ef66db493b1e jdk8-b90 997c0fae2b12108959387862be54b78ca0ae3fca jdk8-b91 149890642a0ed5138a4f16fe08ddbfeb8f8a1cb4 jdk8-b92 +2c5a568ee36eb2d9471483b7a310c49ed545db55 jdk8-b93 From f80e242127a49294e764d1b47415316f99a2514c Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 6 Jun 2013 20:48:44 -0700 Subject: [PATCH 176/206] Added tag jdk8-b93 for changeset 0fc814e0feae --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index b4d15f59f0d..a7273323492 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -202,3 +202,4 @@ e0378f0a50dafdcfb7b04f6401d320f89884baa1 jdk8-b85 67ca019e3713dd71c884d753de02fd0021981969 jdk8-b90 6b9f4120380091b8b1751a825b9f84bf1be224fe jdk8-b91 dee23cce5235b594a96d3361b65eacc97bd5a583 jdk8-b92 +ddbf41575a2bdb12ccb9f91e169018bf04073038 jdk8-b93 From 8030137fd52b34f5a5d3634250739da0c3d6d531 Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Fri, 7 Jun 2013 09:25:19 -0700 Subject: [PATCH 177/206] Added tag hs25-b36 for changeset 0403dabe9186 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index f563fa5d379..2f2c612f5d4 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -348,3 +348,4 @@ b19517cecc2e91636d7c16ba2f35e3d3dc628099 hs25-b33 092018493d3bbeb1c24278fd8c40ff3d76e1fed7 jdk8-b92 573d86d412cd9d3df7912194c1a540be50e9544e jdk8-b93 b786c04b7be15194febe88dc1f0c9443e737a84b hs25-b35 +3c78a14da19d26d6937af5f98b97e2a21c653b04 hs25-b36 From 37d4e6871bf8f886a7ea5d94e89a8f2dd5742e8d Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Mon, 10 Jun 2013 11:52:32 +0200 Subject: [PATCH 178/206] 8015492: Remove DoubleStream.range methods Reviewed-by: alanb --- .../java/util/stream/DoubleStream.java | 71 ----------- .../classes/java/util/stream/Streams.java | 81 ------------ .../stream/DoubleStreamTestDataProvider.java | 22 ---- .../tests/java/util/stream/ExplodeOpTest.java | 4 +- .../tests/java/util/stream/ForEachOpTest.java | 2 +- .../tests/java/util/stream/RangeTest.java | 118 ------------------ .../java/util/stream/StreamBuilderTest.java | 10 +- .../util/stream/StreamSpliteratorTest.java | 2 +- 8 files changed, 9 insertions(+), 301 deletions(-) diff --git a/jdk/src/share/classes/java/util/stream/DoubleStream.java b/jdk/src/share/classes/java/util/stream/DoubleStream.java index f402b5daee6..1706c31572c 100644 --- a/jdk/src/share/classes/java/util/stream/DoubleStream.java +++ b/jdk/src/share/classes/java/util/stream/DoubleStream.java @@ -753,75 +753,4 @@ public interface DoubleStream extends BaseStream { }, Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL)); } - - /** - * Returns a sequential {@code DoubleStream} from {@code startInclusive} (inclusive) - * to {@code endExclusive} (exclusive) by an incremental step of 1.0. - * - * @implSpec - * The implementation behaves as if: - *

    {@code
    -     *     doubleRange(startInclusive, endExclusive, 1.0);
    -     * }
    - * - * @param startInclusive the (inclusive) initial value - * @param endExclusive the exclusive upper bound - * @return a sequential {@code DoubleStream} for the range of {@code double} - * elements - */ - public static DoubleStream range(double startInclusive, double endExclusive) { - return range(startInclusive, endExclusive, 1.0); - } - - /** - * Returns a sequential {@code DoubleStream} from {@code startInclusive} - * (inclusive) to {@code endExclusive} (exclusive) by {@code step}. If - * {@code startInclusive} is greater than or equal to {@code - * endExclusive}, an empty stream is returned. - * - * An equivalent sequence of increasing values can be produced - * sequentially using a {@code for} loop as follows: - *
    {@code
    -     *     long size = (long) Math.ceil((startInclusive - endExclusive) / step);
    -     *     long i = 0
    -     *     for (double v = startInclusive; i < size; i++, v = startInclusive + step * i) {
    -     *         ...
    -     *     }
    -     * }
    - * - * @param startInclusive the (inclusive) initial value - * @param endExclusive the exclusive upper bound - * @param step the difference between consecutive values - * @return a sequential {@code DoubleStream} for tne range of {@code double} - * elements - * @throws IllegalArgumentException if {@code step} is less than or equal to - * 0. is {@code NaN}, or the count of elements in the range would be - * greater than {@code Long.MAX_VALUE} - */ - public static DoubleStream range(double startInclusive, double endExclusive, double step) { - // @@@ Need to check for ranges that may not produce distinct values - // such as when the step is very small - // Also clarify the size of the range which may produce more or less - // than expected - if (step <= 0 || Double.isNaN(step)) { - throw new IllegalArgumentException(String.format("Illegal step: %f", step)); - } else { - double range = endExclusive - startInclusive; - if (range <= 0) { - return empty(); - } - double size = Math.ceil((endExclusive - startInclusive) / step); - if (Double.isNaN(size)) { - throw new IllegalArgumentException( - String.format("Illegal range: %f size is NaN", size)); - } else if (size > Long.MAX_VALUE) { - throw new IllegalArgumentException( - String.format("Illegal range: size %f > Long.MAX_VALUE", size)); - } else { - return StreamSupport.doubleStream( - new Streams.RangeDoubleSpliterator( - startInclusive, endExclusive, step, 0, (long) size)); - } - } - } } diff --git a/jdk/src/share/classes/java/util/stream/Streams.java b/jdk/src/share/classes/java/util/stream/Streams.java index 9693839de62..22b973f742f 100644 --- a/jdk/src/share/classes/java/util/stream/Streams.java +++ b/jdk/src/share/classes/java/util/stream/Streams.java @@ -192,87 +192,6 @@ class Streams { } } - /** - * A {@code double} range spliterator. - * - *

    The traversing and splitting logic is equivalent to that of - * {@code RangeLongSpliterator} for increasing values with a {@code step} of - * {@code 1}. - * - *

    A {@code double} value is calculated from the function - * {@code start + i * step} where {@code i} is the absolute position of the - * value when traversing an instance of this class that has not been split. - * This ensures the same values are produced at the same absolute positions - * regardless of how an instance of this class is split or traversed. - */ - static final class RangeDoubleSpliterator implements Spliterator.OfDouble { - private final double from; - private final double upTo; - private final double step; - - private long lFrom; - private final long lUpTo; - - RangeDoubleSpliterator(double from, double upTo, double step, long lFrom, long lUpTo) { - this.from = from; - this.upTo = upTo; - this.step = step; - this.lFrom = lFrom; - this.lUpTo = lUpTo; - } - - @Override - public boolean tryAdvance(DoubleConsumer consumer) { - boolean hasNext = lFrom < lUpTo; - if (hasNext) { - consumer.accept(from + lFrom * step); - lFrom++; - } - return hasNext; - } - - @Override - public void forEachRemaining(DoubleConsumer consumer) { - double hOrigin = from; - double hStep = step; - long hLUpTo = lUpTo; - long i = lFrom; - for (; i < hLUpTo; i++) { - consumer.accept(hOrigin + i * hStep); - } - lFrom = i; - } - - @Override - public long estimateSize() { - return lUpTo - lFrom; - } - - @Override - public int characteristics() { - return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED | - Spliterator.IMMUTABLE | Spliterator.NONNULL | - Spliterator.DISTINCT | Spliterator.SORTED; - } - - @Override - public Comparator getComparator() { - return null; - } - - @Override - public Spliterator.OfDouble trySplit() { - return estimateSize() <= 1 - ? null - : new RangeDoubleSpliterator(from, upTo, step, lFrom, lFrom = lFrom + midPoint()); - } - - private long midPoint() { - // Size is known to be >= 2 - return (lUpTo - lFrom) / 2; - } - } - private static abstract class AbstractStreamBuilderImpl> implements Spliterator { // >= 0 when building, < 0 when built // -1 == no elements diff --git a/jdk/test/java/util/stream/bootlib/java/util/stream/DoubleStreamTestDataProvider.java b/jdk/test/java/util/stream/bootlib/java/util/stream/DoubleStreamTestDataProvider.java index da108752d26..0eb7c874249 100644 --- a/jdk/test/java/util/stream/bootlib/java/util/stream/DoubleStreamTestDataProvider.java +++ b/jdk/test/java/util/stream/bootlib/java/util/stream/DoubleStreamTestDataProvider.java @@ -92,15 +92,6 @@ public class DoubleStreamTestDataProvider { } list.add(new Object[]{"SpinedList:" + name, TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)}); - - list.add(streamDataDescr("Primitives.range(0,l): " + doubles.length, - () -> DoubleStream.range(0, doubles.length))); - list.add(streamDataDescr("Primitives.range(0,l,2): " + doubles.length, - () -> DoubleStream.range(0, doubles.length, 2))); - list.add(streamDataDescr("Primitives.range(0,l,3): " + doubles.length, - () -> DoubleStream.range(0, doubles.length, 3))); - list.add(streamDataDescr("Primitives.range(0,l,7): " + doubles.length, - () -> DoubleStream.range(0, doubles.length, 7))); } testData = list.toArray(new Object[0][]); } @@ -128,15 +119,6 @@ public class DoubleStreamTestDataProvider { () -> Spliterators.spliterator(isl.iterator(), doubles.length, 0))); spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name, () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0))); - - spliterators.add(splitDescr("Primitives.range(0,l):" + name, - () -> DoubleStream.range(0, doubles.length).spliterator())); - spliterators.add(splitDescr("Primitives.range(0,l,2):" + name, - () -> DoubleStream.range(0, doubles.length, 2).spliterator())); - spliterators.add(splitDescr("Primitives.range(0,l,3):" + name, - () -> DoubleStream.range(0, doubles.length, 3).spliterator())); - spliterators.add(splitDescr("Primitives.range(0,l,7):" + name, - () -> DoubleStream.range(0, doubles.length, 7).spliterator())); // Need more! } spliteratorTestData = spliterators.toArray(new Object[0][]); @@ -144,10 +126,6 @@ public class DoubleStreamTestDataProvider { } - static Object[] streamDataDescr(String description, Supplier s) { - return new Object[] { description, TestData.Factory.ofDoubleSupplier(description, s) }; - } - static Object[] splitDescr(String description, Supplier s) { return new Object[] { description, s }; } diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java index dcb88fb61cb..63b3e51d2de 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java @@ -110,7 +110,7 @@ public class ExplodeOpTest extends OpTestCase { result = exerciseOps(data, s -> DoubleStream.empty()); assertEquals(0, result.size()); - exerciseOps(data, s -> s.flatMap(e -> DoubleStream.range(0, e))); - exerciseOps(data, s -> s.flatMap(e -> DoubleStream.range(0, e).limit(10))); + exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).doubles())); + exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).limit(10).doubles())); } } diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java index 4a078a485da..a79c52d1748 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java @@ -205,7 +205,7 @@ public class ForEachOpTest extends OpTestCase { public void testDoubleForEachOrdered() { List input = countTo(10000); TestData.OfDouble data = TestData.Factory.ofDoubleSupplier("[1, 10000]", - () -> DoubleStream.range(1, 10001)); + () -> IntStream.range(1, 10001).doubles()); Function> terminalFunc = s -> { List l = new ArrayList<>(); diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/RangeTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/RangeTest.java index 182b98c50c1..1a23f550fec 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/RangeTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/RangeTest.java @@ -221,124 +221,6 @@ public class RangeTest extends OpTestCase { // - public void testDoubleRangeErrors() { - for (double start : Arrays.asList(1, 10, -1, -10)) { - for (double end : Arrays.asList(1, 10, -1, -10)) { - for (double step : Arrays.asList(0.0, +0.0, -0.0, 1.0, -1.0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY)) { - try { - if (step > 0) - executeAndNoCatch(() -> DoubleStream.range(start, end, step)); - else - executeAndCatch(() -> DoubleStream.range(start, end, step)); - } - catch (AssertionError e) { - System.out.printf("start=%f, end=%f, step=%f%n", start, end, step); - throw e; - } - } - } - } - - for (double start : Arrays.asList(0.0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NaN)) { - for (double end : Arrays.asList(0.0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NaN)) { - for (double step : Arrays.asList(1.0, -1.0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NaN)) { - try { - if ((start == 0.0 && end == 0.0 && step > 0) - || (start > end && step > 0)) { - executeAndNoCatch(() -> DoubleStream.range(start, end, step)); - } - else { - executeAndCatch(() -> DoubleStream.range(start, end, step)); - } - } - catch (AssertionError e) { - System.out.printf("start=%f, end=%f, step=%f%n", start, end, step); - throw e; - } - } - } - } - } - - public void testDoubleRange() { - // Without step - for (double start : Arrays.asList(1, 1000, -1, -1000)) { - for (double end : Arrays.asList(1, 1000, -1, -1000)) { - double step = 1; - double size = start < end ? Math.ceil((end - start) / step) : 0; - double[] exp = new double[(int) size]; - for (long i = 0; i < size; i++) { - exp[(int) i] = start + i * step; - } - - double[] inc = DoubleStream.range(start, end).toArray(); - assertEquals(inc.length, (int) size); - assertTrue(Arrays.equals(exp, inc)); - - withData(doubleRangeData(start, end, step)).stream(s -> s). - expectedResult(exp).exercise(); - } - } - - // With step - for (double start : Arrays.asList(1, 1000, -1, -1000)) { - for (double end : Arrays.asList(1, 1000, -1, -1000)) { - for (double step : Arrays.asList(1, -1, -2, 2)) { - if (step <= 0) - continue; - double size = start < end ? Math.ceil((end - start) / step) : 0; - double[] exp = new double[(int) size]; - for (long i = 0; i < size; i++) { - exp[(int) i] = start + i * step; - } - - double[] inc = DoubleStream.range(start, end, step).toArray(); - assertEquals(inc.length, (int) size); - assertTrue(Arrays.equals(exp, inc)); - - withData(doubleRangeData(start, end, step)).stream(s -> s). - expectedResult(exp).exercise(); - } - } - } - - // With non-integer values - for (double step : Arrays.asList(Math.PI / 1000.0, Math.PI / 1000.0, Math.PI / 10000.0)) { - double start = -Math.PI; - double end = Math.PI; - double size = start < end ? Math.ceil((end - start) / step) : 0; - double[] exp = new double[(int) size]; - for (long i = 0; i < size; i++) { - exp[(int) i] = start + i * step; - } - - withData(doubleRangeData(start, end, step)).stream(s -> s). - expectedResult(exp).exercise(); - } - } - - TestData.OfDouble doubleRangeData(double start, double end, double step) { - return TestData.Factory.ofDoubleSupplier("double range", () -> DoubleStream.range(start, end, step)); - } - - public void tesDoubleRangeReduce() { - withData(doubleRangeData(0, 10000, 1)). - terminal(s -> s.reduce(0, Double::sum)).exercise(); - } - - public void testDoubleInfiniteRangeLimit() { - withData(TestData.Factory.ofDoubleSupplier( - "double range", () -> DoubleStream.iterate(0, i -> i + 1).limit(10000))). - terminal(s -> s.reduce(0, Double::sum)).exercise(); - } - - public void testDoubleInfiniteRangeFindFirst() { - double first = DoubleStream.iterate(0, i -> i + 1).filter(i -> i > 10000).findFirst().getAsDouble(); - assertEquals(first, DoubleStream.iterate(0, i -> i + 1).parallel().filter(i -> i > 10000).findFirst().getAsDouble()); - } - - // - private static int[] reverse(int[] a) { int[] b = new int[a.length]; for (int i = 0; i < a.length; i++) { diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java index 8898c104df9..018b5de5c6a 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java @@ -275,7 +275,7 @@ public class StreamBuilderTest extends OpTestCase { @Test(dataProvider = "sizes") public void testDoubleAfterBuilding(int size) { StreamBuilder.OfDouble sb = DoubleStream.builder(); - DoubleStream.range(0, size).forEach(sb); + IntStream.range(0, size).doubles().forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); @@ -287,13 +287,13 @@ public class StreamBuilderTest extends OpTestCase { public void testDoubleStreamBuilder(int size) { testDoubleStreamBuilder(size, (s) -> { StreamBuilder.OfDouble sb = DoubleStream.builder(); - DoubleStream.range(0, s).forEach(sb); + IntStream.range(0, s).doubles().forEach(sb); return sb.build(); }); testDoubleStreamBuilder(size, (s) -> { StreamBuilder.OfDouble sb = DoubleStream.builder(); - DoubleStream.range(0, s).forEach(i -> { + IntStream.range(0, s).doubles().forEach(i -> { StreamBuilder.OfDouble _sb = sb.add(i); assertTrue(sb == _sb); }); @@ -307,12 +307,12 @@ public class StreamBuilderTest extends OpTestCase { withData(data). stream(s -> s). - expectedResult(DoubleStream.range(0, size).toArray()). + expectedResult(IntStream.range(0, size).doubles().toArray()). exercise(); withData(data). stream(s -> s.map(i -> i)). - expectedResult(DoubleStream.range(0, size).toArray()). + expectedResult(IntStream.range(0, size).doubles().toArray()). exercise(); } diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java index bc56b2f77ec..403ee27193a 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java @@ -526,7 +526,7 @@ public class StreamSpliteratorTest extends OpTestCase { for (boolean proxyEstimateSize : new boolean[]{false, true}) { // Size is assumed to be larger than the target size for no splitting // @@@ Need way to obtain the target size - Spliterator.OfDouble sp = intermediateOp.apply(DoubleStream.range(0, 1000)).spliterator(); + Spliterator.OfDouble sp = intermediateOp.apply(IntStream.range(0, 1000).doubles()).spliterator(); ProxyNoExactSizeSpliterator.OfDouble psp = new ProxyNoExactSizeSpliterator.OfDouble(sp, proxyEstimateSize); DoubleStream s = StreamSupport.doubleParallelStream(psp); terminalOp.accept(s); From 350636532e10587eef43d1e0cb4b4f1f9a3a274c Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Mon, 10 Jun 2013 12:20:34 +0200 Subject: [PATCH 179/206] 8015798: Rename IntStream.longs/doubles and LongStream.doubles to asXxxStream Reviewed-by: alanb --- .../classes/java/util/stream/IntPipeline.java | 6 +++--- .../classes/java/util/stream/IntStream.java | 4 ++-- .../classes/java/util/stream/LongPipeline.java | 2 +- .../classes/java/util/stream/LongStream.java | 2 +- .../java/util/stream/SpinedBufferTest.java | 2 +- .../util/stream/DoublePrimitiveOpsTests.java | 6 +++--- .../tests/java/util/stream/ExplodeOpTest.java | 4 ++-- .../tests/java/util/stream/ForEachOpTest.java | 2 +- .../tests/java/util/stream/MapOpTest.java | 16 +++------------- .../tests/java/util/stream/MatchOpTest.java | 18 +++++++++--------- .../tests/java/util/stream/MinMaxTest.java | 4 ++-- .../java/util/stream/PrimitiveSumTest.java | 2 +- .../java/util/stream/StreamBuilderTest.java | 10 +++++----- .../util/stream/StreamSpliteratorTest.java | 2 +- 14 files changed, 35 insertions(+), 45 deletions(-) diff --git a/jdk/src/share/classes/java/util/stream/IntPipeline.java b/jdk/src/share/classes/java/util/stream/IntPipeline.java index ec6a4eb0bd3..324ed43bda0 100644 --- a/jdk/src/share/classes/java/util/stream/IntPipeline.java +++ b/jdk/src/share/classes/java/util/stream/IntPipeline.java @@ -183,7 +183,7 @@ abstract class IntPipeline // Stateless intermediate ops from IntStream @Override - public final LongStream longs() { + public final LongStream asLongStream() { return new LongPipeline.StatelessOp(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override @@ -199,7 +199,7 @@ abstract class IntPipeline } @Override - public final DoubleStream doubles() { + public final DoubleStream asDoubleStream() { return new DoublePipeline.StatelessOp(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override @@ -424,7 +424,7 @@ abstract class IntPipeline @Override public final long count() { - return longs().map(e -> 1L).sum(); + return asLongStream().map(e -> 1L).sum(); } @Override diff --git a/jdk/src/share/classes/java/util/stream/IntStream.java b/jdk/src/share/classes/java/util/stream/IntStream.java index 576a6aadea2..35cbe29cc18 100644 --- a/jdk/src/share/classes/java/util/stream/IntStream.java +++ b/jdk/src/share/classes/java/util/stream/IntStream.java @@ -625,7 +625,7 @@ public interface IntStream extends BaseStream { * @return a {@code LongStream} consisting of the elements of this stream, * converted to {@code long} */ - LongStream longs(); + LongStream asLongStream(); /** * Returns a {@code DoubleStream} consisting of the elements of this stream, @@ -634,7 +634,7 @@ public interface IntStream extends BaseStream { * @return a {@code DoubleStream} consisting of the elements of this stream, * converted to {@code double} */ - DoubleStream doubles(); + DoubleStream asDoubleStream(); /** * Returns a {@code Stream} consisting of the elements of this stream, diff --git a/jdk/src/share/classes/java/util/stream/LongPipeline.java b/jdk/src/share/classes/java/util/stream/LongPipeline.java index 1a4da10b040..f2002570991 100644 --- a/jdk/src/share/classes/java/util/stream/LongPipeline.java +++ b/jdk/src/share/classes/java/util/stream/LongPipeline.java @@ -180,7 +180,7 @@ abstract class LongPipeline // Stateless intermediate ops from LongStream @Override - public final DoubleStream doubles() { + public final DoubleStream asDoubleStream() { return new DoublePipeline.StatelessOp(this, StreamShape.LONG_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override diff --git a/jdk/src/share/classes/java/util/stream/LongStream.java b/jdk/src/share/classes/java/util/stream/LongStream.java index 22fae149baa..cbdae128f98 100644 --- a/jdk/src/share/classes/java/util/stream/LongStream.java +++ b/jdk/src/share/classes/java/util/stream/LongStream.java @@ -625,7 +625,7 @@ public interface LongStream extends BaseStream { * @return a {@code DoubleStream} consisting of the elements of this stream, * converted to {@code double} */ - DoubleStream doubles(); + DoubleStream asDoubleStream(); /** * Returns a {@code Stream} consisting of the elements of this stream, diff --git a/jdk/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java b/jdk/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java index 3fee90b6106..ad891f74694 100644 --- a/jdk/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java +++ b/jdk/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java @@ -300,7 +300,7 @@ public class SpinedBufferTest { for (int size : sizes) { // @@@ replace with double range when implemented - double[] array = LongStream.range(0, size).doubles().toArray(); + double[] array = LongStream.range(0, size).asDoubleStream().toArray(); SpinedBuffer.OfDouble sb = new SpinedBuffer.OfDouble(); Arrays.stream(array).forEach(sb); diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DoublePrimitiveOpsTests.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DoublePrimitiveOpsTests.java index 4a66d1a86d4..c476f18c624 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DoublePrimitiveOpsTests.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DoublePrimitiveOpsTests.java @@ -44,12 +44,12 @@ public class DoublePrimitiveOpsTests { public void testToArray() { { - double[] array = LongStream.range(1, 10).doubles().map(i -> i * 2).toArray(); + double[] array = LongStream.range(1, 10).asDoubleStream().map(i -> i * 2).toArray(); assertEquals(array, new double[]{2, 4, 6, 8, 10, 12, 14, 16, 18}); } { - double[] array = LongStream.range(1, 10).parallel().doubles().map(i -> i * 2).toArray(); + double[] array = LongStream.range(1, 10).parallel().asDoubleStream().map(i -> i * 2).toArray(); assertEquals(array, new double[]{2, 4, 6, 8, 10, 12, 14, 16, 18}); } } @@ -99,7 +99,7 @@ public class DoublePrimitiveOpsTests { } { - double[] actual = LongStream.range(1, 100).parallel().doubles().limit(9).toArray(); + double[] actual = LongStream.range(1, 100).parallel().asDoubleStream().limit(9).toArray(); Assert.assertTrue(Arrays.equals(expected, actual)); } } diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java index 63b3e51d2de..4332a0cc786 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java @@ -110,7 +110,7 @@ public class ExplodeOpTest extends OpTestCase { result = exerciseOps(data, s -> DoubleStream.empty()); assertEquals(0, result.size()); - exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).doubles())); - exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).limit(10).doubles())); + exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).asDoubleStream())); + exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).limit(10).asDoubleStream())); } } diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java index a79c52d1748..99f4fdd82f5 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java @@ -205,7 +205,7 @@ public class ForEachOpTest extends OpTestCase { public void testDoubleForEachOrdered() { List input = countTo(10000); TestData.OfDouble data = TestData.Factory.ofDoubleSupplier("[1, 10000]", - () -> IntStream.range(1, 10001).doubles()); + () -> IntStream.range(1, 10001).asDoubleStream()); Function> terminalFunc = s -> { List l = new ArrayList<>(); diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MapOpTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MapOpTest.java index 9225ddd9223..4f7aaf6fa02 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MapOpTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MapOpTest.java @@ -24,16 +24,6 @@ package org.openjdk.tests.java.util.stream; import org.testng.annotations.Test; -import java.util.function.DoubleToIntFunction; -import java.util.function.DoubleToLongFunction; -import java.util.function.Function; -import java.util.function.IntToDoubleFunction; -import java.util.function.IntToLongFunction; -import java.util.function.LongToDoubleFunction; -import java.util.function.LongToIntFunction; -import java.util.function.ToDoubleFunction; -import java.util.function.ToIntFunction; -import java.util.function.ToLongFunction; import java.util.stream.*; import static java.util.stream.LambdaTestHelpers.*; @@ -98,8 +88,8 @@ public class MapOpTest extends OpTestCase { exerciseOps(data, s -> s.mapToObj(i -> i)); exerciseOps(data, s -> s.map(i -> 0)); exerciseOps(data, s -> s.map(i -> i * 2)); - exerciseOps(data, s -> s.longs()); - exerciseOps(data, s -> s.doubles()); + exerciseOps(data, s -> s.asLongStream()); + exerciseOps(data, s -> s.asDoubleStream()); exerciseOps(data, s -> s.boxed()); exerciseOps(data, s -> s.mapToObj(Integer::toString)); exerciseOps(data, s -> s.mapToLong(i -> i)); @@ -113,7 +103,7 @@ public class MapOpTest extends OpTestCase { exerciseOps(data, s -> s.mapToObj(i -> i)); exerciseOps(data, s -> s.map(i -> 0L)); exerciseOps(data, s -> s.map(i -> i * 2L)); - exerciseOps(data, s -> s.doubles()); + exerciseOps(data, s -> s.asDoubleStream()); exerciseOps(data, s -> s.boxed()); exerciseOps(data, s -> s.mapToObj(e -> Long.toString(e))); exerciseOps(data, s -> s.mapToInt(i -> (int) i)); diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MatchOpTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MatchOpTest.java index a6516118915..84c43d0a748 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MatchOpTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MatchOpTest.java @@ -318,17 +318,17 @@ public class MatchOpTest extends OpTestCase { } public void testDoubleStreamMatches() { - assertDoublePredicates(() -> LongStream.range(0, 0).doubles(), Kind.ANY, DOUBLE_PREDICATES, false, false, false, false); - assertDoublePredicates(() -> LongStream.range(0, 0).doubles(), Kind.ALL, DOUBLE_PREDICATES, true, true, true, true); - assertDoublePredicates(() -> LongStream.range(0, 0).doubles(), Kind.NONE, DOUBLE_PREDICATES, true, true, true, true); + assertDoublePredicates(() -> LongStream.range(0, 0).asDoubleStream(), Kind.ANY, DOUBLE_PREDICATES, false, false, false, false); + assertDoublePredicates(() -> LongStream.range(0, 0).asDoubleStream(), Kind.ALL, DOUBLE_PREDICATES, true, true, true, true); + assertDoublePredicates(() -> LongStream.range(0, 0).asDoubleStream(), Kind.NONE, DOUBLE_PREDICATES, true, true, true, true); - assertDoublePredicates(() -> LongStream.range(1, 2).doubles(), Kind.ANY, DOUBLE_PREDICATES, true, false, false, true); - assertDoublePredicates(() -> LongStream.range(1, 2).doubles(), Kind.ALL, DOUBLE_PREDICATES, true, false, false, true); - assertDoublePredicates(() -> LongStream.range(1, 2).doubles(), Kind.NONE, DOUBLE_PREDICATES, false, true, true, false); + assertDoublePredicates(() -> LongStream.range(1, 2).asDoubleStream(), Kind.ANY, DOUBLE_PREDICATES, true, false, false, true); + assertDoublePredicates(() -> LongStream.range(1, 2).asDoubleStream(), Kind.ALL, DOUBLE_PREDICATES, true, false, false, true); + assertDoublePredicates(() -> LongStream.range(1, 2).asDoubleStream(), Kind.NONE, DOUBLE_PREDICATES, false, true, true, false); - assertDoublePredicates(() -> LongStream.range(1, 6).doubles(), Kind.ANY, DOUBLE_PREDICATES, true, false, true, true); - assertDoublePredicates(() -> LongStream.range(1, 6).doubles(), Kind.ALL, DOUBLE_PREDICATES, true, false, false, false); - assertDoublePredicates(() -> LongStream.range(1, 6).doubles(), Kind.NONE, DOUBLE_PREDICATES, false, true, false, false); + assertDoublePredicates(() -> LongStream.range(1, 6).asDoubleStream(), Kind.ANY, DOUBLE_PREDICATES, true, false, true, true); + assertDoublePredicates(() -> LongStream.range(1, 6).asDoubleStream(), Kind.ALL, DOUBLE_PREDICATES, true, false, false, false); + assertDoublePredicates(() -> LongStream.range(1, 6).asDoubleStream(), Kind.NONE, DOUBLE_PREDICATES, false, true, false, false); } @Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class) diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MinMaxTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MinMaxTest.java index 6ae36097dbc..eed4a82bbe2 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MinMaxTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MinMaxTest.java @@ -80,8 +80,8 @@ public class MinMaxTest extends OpTestCase { public void testDoubleMinMax() { assertEquals(DoubleStream.empty().min(), OptionalDouble.empty()); assertEquals(DoubleStream.empty().max(), OptionalDouble.empty()); - assertEquals(1.0, LongStream.range(1, 1001).doubles().min().getAsDouble()); - assertEquals(1000.0, LongStream.range(1, 1001).doubles().max().getAsDouble()); + assertEquals(1.0, LongStream.range(1, 1001).asDoubleStream().min().getAsDouble()); + assertEquals(1000.0, LongStream.range(1, 1001).asDoubleStream().max().getAsDouble()); } @Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class) diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveSumTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveSumTest.java index 98c93513d05..6f2822f9d32 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveSumTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveSumTest.java @@ -34,7 +34,7 @@ public class PrimitiveSumTest extends OpTestCase { withData(data). terminal(s -> (long) s.sum()). - expectedResult(data.stream().longs().reduce(0, LambdaTestHelpers.lrPlus)). + expectedResult(data.stream().asLongStream().reduce(0, LambdaTestHelpers.lrPlus)). exercise(); } diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java index 018b5de5c6a..5a2760872fa 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java @@ -275,7 +275,7 @@ public class StreamBuilderTest extends OpTestCase { @Test(dataProvider = "sizes") public void testDoubleAfterBuilding(int size) { StreamBuilder.OfDouble sb = DoubleStream.builder(); - IntStream.range(0, size).doubles().forEach(sb); + IntStream.range(0, size).asDoubleStream().forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); @@ -287,13 +287,13 @@ public class StreamBuilderTest extends OpTestCase { public void testDoubleStreamBuilder(int size) { testDoubleStreamBuilder(size, (s) -> { StreamBuilder.OfDouble sb = DoubleStream.builder(); - IntStream.range(0, s).doubles().forEach(sb); + IntStream.range(0, s).asDoubleStream().forEach(sb); return sb.build(); }); testDoubleStreamBuilder(size, (s) -> { StreamBuilder.OfDouble sb = DoubleStream.builder(); - IntStream.range(0, s).doubles().forEach(i -> { + IntStream.range(0, s).asDoubleStream().forEach(i -> { StreamBuilder.OfDouble _sb = sb.add(i); assertTrue(sb == _sb); }); @@ -307,12 +307,12 @@ public class StreamBuilderTest extends OpTestCase { withData(data). stream(s -> s). - expectedResult(IntStream.range(0, size).doubles().toArray()). + expectedResult(IntStream.range(0, size).asDoubleStream().toArray()). exercise(); withData(data). stream(s -> s.map(i -> i)). - expectedResult(IntStream.range(0, size).doubles().toArray()). + expectedResult(IntStream.range(0, size).asDoubleStream().toArray()). exercise(); } diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java index 403ee27193a..8a4d502dc2b 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java @@ -526,7 +526,7 @@ public class StreamSpliteratorTest extends OpTestCase { for (boolean proxyEstimateSize : new boolean[]{false, true}) { // Size is assumed to be larger than the target size for no splitting // @@@ Need way to obtain the target size - Spliterator.OfDouble sp = intermediateOp.apply(IntStream.range(0, 1000).doubles()).spliterator(); + Spliterator.OfDouble sp = intermediateOp.apply(IntStream.range(0, 1000).asDoubleStream()).spliterator(); ProxyNoExactSizeSpliterator.OfDouble psp = new ProxyNoExactSizeSpliterator.OfDouble(sp, proxyEstimateSize); DoubleStream s = StreamSupport.doubleParallelStream(psp); terminalOp.accept(s); From cde3ef7ba09f85f71b2166fbce43a0b91b859142 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Mon, 10 Jun 2013 12:26:20 +0200 Subject: [PATCH 180/206] 8015792: Rename Spliterators.spliteratorFromIterator to Spliterators.iterator Reviewed-by: chegar --- jdk/src/share/classes/java/util/Spliterators.java | 8 ++++---- .../classes/java/util/stream/DoublePipeline.java | 2 +- .../classes/java/util/stream/IntPipeline.java | 2 +- .../classes/java/util/stream/LongPipeline.java | 2 +- .../java/util/stream/ReferencePipeline.java | 2 +- .../classes/java/util/stream/SpinedBuffer.java | 8 ++++---- .../SpliteratorTraversingAndSplittingTest.java | 14 +++++++------- .../stream/bootlib/java/util/stream/TestData.java | 8 ++++---- .../boottest/java/util/stream/DoubleNodeTest.java | 2 +- .../boottest/java/util/stream/IntNodeTest.java | 2 +- .../boottest/java/util/stream/LongNodeTest.java | 2 +- .../tests/java/util/stream/SortedOpTest.java | 6 +++--- 12 files changed, 29 insertions(+), 29 deletions(-) diff --git a/jdk/src/share/classes/java/util/Spliterators.java b/jdk/src/share/classes/java/util/Spliterators.java index 860f37a812b..f0d7a4e3175 100644 --- a/jdk/src/share/classes/java/util/Spliterators.java +++ b/jdk/src/share/classes/java/util/Spliterators.java @@ -663,7 +663,7 @@ public final class Spliterators { * @return An iterator * @throws NullPointerException if the given spliterator is {@code null} */ - public static Iterator iteratorFromSpliterator(Spliterator spliterator) { + public static Iterator iterator(Spliterator spliterator) { Objects.requireNonNull(spliterator); class Adapter implements Iterator, Consumer { boolean valueReady = false; @@ -708,7 +708,7 @@ public final class Spliterators { * @return An iterator * @throws NullPointerException if the given spliterator is {@code null} */ - public static PrimitiveIterator.OfInt iteratorFromSpliterator(Spliterator.OfInt spliterator) { + public static PrimitiveIterator.OfInt iterator(Spliterator.OfInt spliterator) { Objects.requireNonNull(spliterator); class Adapter implements PrimitiveIterator.OfInt, IntConsumer { boolean valueReady = false; @@ -753,7 +753,7 @@ public final class Spliterators { * @return An iterator * @throws NullPointerException if the given spliterator is {@code null} */ - public static PrimitiveIterator.OfLong iteratorFromSpliterator(Spliterator.OfLong spliterator) { + public static PrimitiveIterator.OfLong iterator(Spliterator.OfLong spliterator) { Objects.requireNonNull(spliterator); class Adapter implements PrimitiveIterator.OfLong, LongConsumer { boolean valueReady = false; @@ -798,7 +798,7 @@ public final class Spliterators { * @return An iterator * @throws NullPointerException if the given spliterator is {@code null} */ - public static PrimitiveIterator.OfDouble iteratorFromSpliterator(Spliterator.OfDouble spliterator) { + public static PrimitiveIterator.OfDouble iterator(Spliterator.OfDouble spliterator) { Objects.requireNonNull(spliterator); class Adapter implements PrimitiveIterator.OfDouble, DoubleConsumer { boolean valueReady = false; diff --git a/jdk/src/share/classes/java/util/stream/DoublePipeline.java b/jdk/src/share/classes/java/util/stream/DoublePipeline.java index b403a433fbf..5b1b4c7b4f3 100644 --- a/jdk/src/share/classes/java/util/stream/DoublePipeline.java +++ b/jdk/src/share/classes/java/util/stream/DoublePipeline.java @@ -168,7 +168,7 @@ abstract class DoublePipeline @Override public final PrimitiveIterator.OfDouble iterator() { - return Spliterators.iteratorFromSpliterator(spliterator()); + return Spliterators.iterator(spliterator()); } @Override diff --git a/jdk/src/share/classes/java/util/stream/IntPipeline.java b/jdk/src/share/classes/java/util/stream/IntPipeline.java index 324ed43bda0..c96588a6a69 100644 --- a/jdk/src/share/classes/java/util/stream/IntPipeline.java +++ b/jdk/src/share/classes/java/util/stream/IntPipeline.java @@ -172,7 +172,7 @@ abstract class IntPipeline @Override public final PrimitiveIterator.OfInt iterator() { - return Spliterators.iteratorFromSpliterator(spliterator()); + return Spliterators.iterator(spliterator()); } @Override diff --git a/jdk/src/share/classes/java/util/stream/LongPipeline.java b/jdk/src/share/classes/java/util/stream/LongPipeline.java index f2002570991..2c7e2f4a032 100644 --- a/jdk/src/share/classes/java/util/stream/LongPipeline.java +++ b/jdk/src/share/classes/java/util/stream/LongPipeline.java @@ -169,7 +169,7 @@ abstract class LongPipeline @Override public final PrimitiveIterator.OfLong iterator() { - return Spliterators.iteratorFromSpliterator(spliterator()); + return Spliterators.iterator(spliterator()); } @Override diff --git a/jdk/src/share/classes/java/util/stream/ReferencePipeline.java b/jdk/src/share/classes/java/util/stream/ReferencePipeline.java index 6fc4cc0e7ff..92a139fa618 100644 --- a/jdk/src/share/classes/java/util/stream/ReferencePipeline.java +++ b/jdk/src/share/classes/java/util/stream/ReferencePipeline.java @@ -137,7 +137,7 @@ abstract class ReferencePipeline @Override public final Iterator iterator() { - return Spliterators.iteratorFromSpliterator(spliterator()); + return Spliterators.iterator(spliterator()); } diff --git a/jdk/src/share/classes/java/util/stream/SpinedBuffer.java b/jdk/src/share/classes/java/util/stream/SpinedBuffer.java index 8c051f00ca4..68625e2dd1d 100644 --- a/jdk/src/share/classes/java/util/stream/SpinedBuffer.java +++ b/jdk/src/share/classes/java/util/stream/SpinedBuffer.java @@ -227,7 +227,7 @@ class SpinedBuffer @Override public Iterator iterator() { - return Spliterators.iteratorFromSpliterator(spliterator()); + return Spliterators.iterator(spliterator()); } @Override @@ -712,7 +712,7 @@ class SpinedBuffer @Override public PrimitiveIterator.OfInt iterator() { - return Spliterators.iteratorFromSpliterator(spliterator()); + return Spliterators.iterator(spliterator()); } public Spliterator.OfInt spliterator() { @@ -815,7 +815,7 @@ class SpinedBuffer @Override public PrimitiveIterator.OfLong iterator() { - return Spliterators.iteratorFromSpliterator(spliterator()); + return Spliterators.iterator(spliterator()); } @@ -919,7 +919,7 @@ class SpinedBuffer @Override public PrimitiveIterator.OfDouble iterator() { - return Spliterators.iteratorFromSpliterator(spliterator()); + return Spliterators.iterator(spliterator()); } public Spliterator.OfDouble spliterator() { diff --git a/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java b/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java index 5990dde97c5..d58c2b9d544 100644 --- a/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java +++ b/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java @@ -170,7 +170,7 @@ public class SpliteratorTraversingAndSplittingTest { () -> Spliterators.spliteratorUnknownSize(exp.iterator(), 0)); db.add("Spliterators.spliterator(Spliterators.iteratorFromSpliterator(Spliterator ), ...)", - () -> Spliterators.spliterator(Spliterators.iteratorFromSpliterator(exp.spliterator()), exp.size(), 0)); + () -> Spliterators.spliterator(Spliterators.iterator(exp.spliterator()), exp.size(), 0)); db.add("Spliterators.spliterator(T[], ...)", () -> Spliterators.spliterator(exp.toArray(new Integer[0]), 0)); @@ -549,10 +549,10 @@ public class SpliteratorTraversingAndSplittingTest { () -> Arrays.spliterator(exp)); db.add("Spliterators.spliterator(PrimitiveIterator.OfInt, ...)", - () -> Spliterators.spliterator(Spliterators.iteratorFromSpliterator(Arrays.spliterator(exp)), exp.length, 0)); + () -> Spliterators.spliterator(Spliterators.iterator(Arrays.spliterator(exp)), exp.length, 0)); db.add("Spliterators.spliteratorUnknownSize(PrimitiveIterator.OfInt, ...)", - () -> Spliterators.spliteratorUnknownSize(Spliterators.iteratorFromSpliterator(Arrays.spliterator(exp)), 0)); + () -> Spliterators.spliteratorUnknownSize(Spliterators.iterator(Arrays.spliterator(exp)), 0)); class IntSpliteratorFromArray extends Spliterators.AbstractIntSpliterator { int[] a; @@ -702,10 +702,10 @@ public class SpliteratorTraversingAndSplittingTest { () -> Arrays.spliterator(exp)); db.add("Spliterators.spliterator(PrimitiveIterator.OfLong, ...)", - () -> Spliterators.spliterator(Spliterators.iteratorFromSpliterator(Arrays.spliterator(exp)), exp.length, 0)); + () -> Spliterators.spliterator(Spliterators.iterator(Arrays.spliterator(exp)), exp.length, 0)); db.add("Spliterators.spliteratorUnknownSize(PrimitiveIterator.OfLong, ...)", - () -> Spliterators.spliteratorUnknownSize(Spliterators.iteratorFromSpliterator(Arrays.spliterator(exp)), 0)); + () -> Spliterators.spliteratorUnknownSize(Spliterators.iterator(Arrays.spliterator(exp)), 0)); class LongSpliteratorFromArray extends Spliterators.AbstractLongSpliterator { long[] a; @@ -862,10 +862,10 @@ public class SpliteratorTraversingAndSplittingTest { () -> Arrays.spliterator(exp)); db.add("Spliterators.spliterator(PrimitiveIterator.OfDouble, ...)", - () -> Spliterators.spliterator(Spliterators.iteratorFromSpliterator(Arrays.spliterator(exp)), exp.length, 0)); + () -> Spliterators.spliterator(Spliterators.iterator(Arrays.spliterator(exp)), exp.length, 0)); db.add("Spliterators.spliteratorUnknownSize(PrimitiveIterator.OfDouble, ...)", - () -> Spliterators.spliteratorUnknownSize(Spliterators.iteratorFromSpliterator(Arrays.spliterator(exp)), 0)); + () -> Spliterators.spliteratorUnknownSize(Spliterators.iterator(Arrays.spliterator(exp)), 0)); class DoubleSpliteratorFromArray extends Spliterators.AbstractDoubleSpliterator { double[] a; diff --git a/jdk/test/java/util/stream/bootlib/java/util/stream/TestData.java b/jdk/test/java/util/stream/bootlib/java/util/stream/TestData.java index e8b65d2bdf0..c204b318ed6 100644 --- a/jdk/test/java/util/stream/bootlib/java/util/stream/TestData.java +++ b/jdk/test/java/util/stream/bootlib/java/util/stream/TestData.java @@ -45,7 +45,7 @@ public interface TestData> @Override default Iterator iterator() { - return Spliterators.iteratorFromSpliterator(spliterator()); + return Spliterators.iterator(spliterator()); } Spliterator spliterator(); @@ -292,7 +292,7 @@ public interface TestData> @Override public PrimitiveIterator.OfInt iterator() { - return Spliterators.iteratorFromSpliterator(spliterator()); + return Spliterators.iterator(spliterator()); } @Override @@ -317,7 +317,7 @@ public interface TestData> @Override public PrimitiveIterator.OfLong iterator() { - return Spliterators.iteratorFromSpliterator(spliterator()); + return Spliterators.iterator(spliterator()); } @Override @@ -342,7 +342,7 @@ public interface TestData> @Override public PrimitiveIterator.OfDouble iterator() { - return Spliterators.iteratorFromSpliterator(spliterator()); + return Spliterators.iterator(spliterator()); } @Override diff --git a/jdk/test/java/util/stream/boottest/java/util/stream/DoubleNodeTest.java b/jdk/test/java/util/stream/boottest/java/util/stream/DoubleNodeTest.java index 7ad4801e421..c348102cf08 100644 --- a/jdk/test/java/util/stream/boottest/java/util/stream/DoubleNodeTest.java +++ b/jdk/test/java/util/stream/boottest/java/util/stream/DoubleNodeTest.java @@ -48,7 +48,7 @@ public class DoubleNodeTest extends OpTestCase { List> nodes = new ArrayList<>(); nodes.add(Nodes.node(array)); - nodes.add(degenerateTree(Spliterators.iteratorFromSpliterator(Arrays.spliterator(array)))); + nodes.add(degenerateTree(Spliterators.iterator(Arrays.spliterator(array)))); nodes.add(tree(toList(array), l -> Nodes.node(toDoubleArray(l)))); nodes.add(fill(array, Nodes.doubleBuilder(array.length))); nodes.add(fill(array, Nodes.doubleBuilder())); diff --git a/jdk/test/java/util/stream/boottest/java/util/stream/IntNodeTest.java b/jdk/test/java/util/stream/boottest/java/util/stream/IntNodeTest.java index 0d345ad451a..b9292578d45 100644 --- a/jdk/test/java/util/stream/boottest/java/util/stream/IntNodeTest.java +++ b/jdk/test/java/util/stream/boottest/java/util/stream/IntNodeTest.java @@ -48,7 +48,7 @@ public class IntNodeTest extends OpTestCase { List> nodes = new ArrayList<>(); nodes.add(Nodes.node(array)); - nodes.add(degenerateTree(Spliterators.iteratorFromSpliterator(Arrays.spliterator(array)))); + nodes.add(degenerateTree(Spliterators.iterator(Arrays.spliterator(array)))); nodes.add(tree(toList(array), l -> Nodes.node(toIntArray(l)))); nodes.add(fill(array, Nodes.intBuilder(array.length))); nodes.add(fill(array, Nodes.intBuilder())); diff --git a/jdk/test/java/util/stream/boottest/java/util/stream/LongNodeTest.java b/jdk/test/java/util/stream/boottest/java/util/stream/LongNodeTest.java index 0b101a04ad9..a14bcd0ee7b 100644 --- a/jdk/test/java/util/stream/boottest/java/util/stream/LongNodeTest.java +++ b/jdk/test/java/util/stream/boottest/java/util/stream/LongNodeTest.java @@ -48,7 +48,7 @@ public class LongNodeTest extends OpTestCase { List> nodes = new ArrayList<>(); nodes.add(Nodes.node(array)); - nodes.add(degenerateTree(Spliterators.iteratorFromSpliterator(Arrays.spliterator(array)))); + nodes.add(degenerateTree(Spliterators.iterator(Arrays.spliterator(array)))); nodes.add(tree(toList(array), l -> Nodes.node(toLongArray(l)))); nodes.add(fill(array, Nodes.longBuilder(array.length))); nodes.add(fill(array, Nodes.longBuilder())); diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SortedOpTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SortedOpTest.java index 2d1886b70c8..93ac4eae386 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SortedOpTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SortedOpTest.java @@ -150,7 +150,7 @@ public class SortedOpTest extends OpTestCase { } private IntStream unknownSizeIntStream(int[] a) { - return StreamSupport.intStream(Spliterators.spliteratorUnknownSize(Spliterators.iteratorFromSpliterator(Arrays.spliterator(a)), 0)); + return StreamSupport.intStream(Spliterators.spliteratorUnknownSize(Spliterators.iterator(Arrays.spliterator(a)), 0)); } @Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class) @@ -193,7 +193,7 @@ public class SortedOpTest extends OpTestCase { } private LongStream unknownSizeLongStream(long[] a) { - return StreamSupport.longStream(Spliterators.spliteratorUnknownSize(Spliterators.iteratorFromSpliterator(Arrays.spliterator(a)), 0)); + return StreamSupport.longStream(Spliterators.spliteratorUnknownSize(Spliterators.iterator(Arrays.spliterator(a)), 0)); } @Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class) @@ -236,7 +236,7 @@ public class SortedOpTest extends OpTestCase { } private DoubleStream unknownSizeDoubleStream(double[] a) { - return StreamSupport.doubleStream(Spliterators.spliteratorUnknownSize(Spliterators.iteratorFromSpliterator(Arrays.spliterator(a)), 0)); + return StreamSupport.doubleStream(Spliterators.spliteratorUnknownSize(Spliterators.iterator(Arrays.spliterator(a)), 0)); } @Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class) From 451a0034a1a120f2db2e17018eb12d6f990ca99b Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Mon, 10 Jun 2013 12:58:32 +0100 Subject: [PATCH 181/206] 8016217: More javadoc warnings Reviewed-by: lancea, chegar, psandoz --- .../classes/java/io/BufferedInputStream.java | 2 +- .../share/classes/java/io/BufferedReader.java | 4 +- .../share/classes/java/io/BufferedWriter.java | 2 +- jdk/src/share/classes/java/io/Console.java | 4 +- .../classes/java/io/PipedInputStream.java | 4 +- .../share/classes/java/io/PipedReader.java | 4 +- .../share/classes/java/io/PrintStream.java | 8 +- .../classes/java/io/PushbackInputStream.java | 2 +- .../share/classes/java/io/PushbackReader.java | 2 +- .../share/classes/java/io/StringReader.java | 2 +- .../share/classes/java/lang/Character.java | 4 +- .../share/classes/java/lang/ClassLoader.java | 2 +- .../share/classes/java/lang/Comparable.java | 2 +- jdk/src/share/classes/java/lang/Double.java | 10 +- jdk/src/share/classes/java/lang/Float.java | 10 +- .../classes/java/lang/StackTraceElement.java | 4 +- .../java/lang/instrument/Instrumentation.java | 20 +- .../java/lang/invoke/MethodHandle.java | 20 +- .../java/lang/invoke/MethodHandles.java | 4 +- .../java/lang/management/MemoryUsage.java | 4 +- .../java/lang/management/RuntimeMXBean.java | 2 +- .../java/lang/management/ThreadMXBean.java | 12 +- .../share/classes/java/net/CookieManager.java | 4 +- .../share/classes/java/net/CookiePolicy.java | 2 +- .../classes/java/net/DatagramSocket.java | 10 +- .../classes/java/net/HttpURLConnection.java | 4 +- .../classes/java/net/InetSocketAddress.java | 2 +- .../classes/java/net/MulticastSocket.java | 2 +- .../share/classes/java/net/ServerSocket.java | 6 +- jdk/src/share/classes/java/net/Socket.java | 6 +- .../java/net/StandardSocketOptions.java | 4 +- jdk/src/share/classes/java/net/URI.java | 2 +- .../share/classes/java/net/URLConnection.java | 4 +- .../classes/java/nio/X-Buffer.java.template | 28 +- .../java/nio/channels/SelectableChannel.java | 6 +- .../java/nio/channels/SelectionKey.java | 34 +- .../nio/charset/Charset-X-Coder.java.template | 4 +- jdk/src/share/classes/java/nio/file/Path.java | 4 +- .../share/classes/java/security/KeyStore.java | 2 +- .../classes/java/security/SecureRandom.java | 2 +- .../cert/CertPathValidatorException.java | 8 +- .../security/cert/CertificateFactory.java | 4 +- .../java/security/cert/X509Extension.java | 6 +- .../java/security/spec/EllipticCurve.java | 4 +- .../classes/java/sql/DatabaseMetaData.java | 514 +++++++++--------- .../share/classes/java/sql/DriverManager.java | 2 +- jdk/src/share/classes/java/sql/ResultSet.java | 2 +- jdk/src/share/classes/java/sql/Statement.java | 18 +- .../classes/java/text/CharacterIterator.java | 12 +- .../share/classes/java/text/ChoiceFormat.java | 2 +- jdk/src/share/classes/java/text/Collator.java | 4 +- jdk/src/share/classes/java/util/Calendar.java | 8 +- .../share/classes/java/util/Collections.java | 8 +- jdk/src/share/classes/java/util/Date.java | 7 +- .../classes/java/util/LinkedHashMap.java | 4 +- jdk/src/share/classes/java/util/Random.java | 2 +- .../classes/java/util/ResourceBundle.java | 4 +- jdk/src/share/classes/java/util/Scanner.java | 28 +- .../share/classes/java/util/TimerTask.java | 4 +- .../share/classes/java/util/jar/Pack200.java | 4 +- .../java/util/logging/ConsoleHandler.java | 2 +- .../java/util/logging/FileHandler.java | 4 +- .../java/util/logging/MemoryHandler.java | 4 +- .../classes/java/util/prefs/Preferences.java | 84 +-- .../classes/java/util/regex/MatchResult.java | 2 +- .../classes/java/util/regex/Pattern.java | 2 +- .../java/util/stream/package-info.java | 2 +- .../java/util/zip/DeflaterInputStream.java | 5 +- .../java/util/zip/DeflaterOutputStream.java | 4 +- .../java/util/zip/GZIPInputStream.java | 2 +- .../java/util/zip/GZIPOutputStream.java | 5 +- .../java/util/zip/InflaterInputStream.java | 4 +- .../java/util/zip/InflaterOutputStream.java | 6 +- .../classes/java/util/zip/ZipInputStream.java | 2 +- .../javax/crypto/spec/IvParameterSpec.java | 2 +- .../javax/crypto/spec/RC5ParameterSpec.java | 4 +- .../javax/crypto/spec/SecretKeySpec.java | 2 +- .../classes/javax/naming/BinaryRefAddr.java | 4 +- .../javax/naming/directory/Attribute.java | 8 +- .../classes/javax/naming/ldap/LdapName.java | 6 +- .../naming/ldap/PagedResultsControl.java | 8 +- .../javax/naming/ldap/SortControl.java | 4 +- .../classes/javax/net/ssl/SNIHostName.java | 4 +- .../classes/javax/net/ssl/SSLEngine.java | 12 +- .../javax/net/ssl/SSLEngineResult.java | 2 +- .../javax/net/ssl/SSLSessionContext.java | 4 +- .../javax/script/ScriptEngineFactory.java | 14 +- .../auth/callback/CallbackHandler.java | 4 +- .../classes/javax/security/sasl/Sasl.java | 8 +- .../javax/security/sasl/SaslClient.java | 8 +- .../javax/security/sasl/SaslServer.java | 4 +- .../javax/smartcardio/ResponseAPDU.java | 2 +- .../share/classes/javax/sql/DataSource.java | 4 +- .../classes/javax/sql/rowset/BaseRowSet.java | 16 +- .../javax/sql/rowset/CachedRowSet.java | 24 +- .../classes/javax/sql/rowset/Predicate.java | 21 +- .../javax/sql/rowset/RowSetMetaDataImpl.java | 8 +- .../javax/sql/rowset/spi/SyncFactory.java | 2 - .../javax/sql/rowset/spi/SyncResolver.java | 8 +- .../javax/xml/crypto/dsig/Manifest.java | 18 +- 100 files changed, 617 insertions(+), 611 deletions(-) diff --git a/jdk/src/share/classes/java/io/BufferedInputStream.java b/jdk/src/share/classes/java/io/BufferedInputStream.java index fcc7e702db6..a161a988109 100644 --- a/jdk/src/share/classes/java/io/BufferedInputStream.java +++ b/jdk/src/share/classes/java/io/BufferedInputStream.java @@ -185,7 +185,7 @@ class BufferedInputStream extends FilterInputStream { * * @param in the underlying input stream. * @param size the buffer size. - * @exception IllegalArgumentException if size <= 0. + * @exception IllegalArgumentException if {@code size <= 0}. */ public BufferedInputStream(InputStream in, int size) { super(in); diff --git a/jdk/src/share/classes/java/io/BufferedReader.java b/jdk/src/share/classes/java/io/BufferedReader.java index d742233a0fd..ebf398078bf 100644 --- a/jdk/src/share/classes/java/io/BufferedReader.java +++ b/jdk/src/share/classes/java/io/BufferedReader.java @@ -95,7 +95,7 @@ public class BufferedReader extends Reader { * @param in A Reader * @param sz Input-buffer size * - * @exception IllegalArgumentException If sz is <= 0 + * @exception IllegalArgumentException If {@code sz <= 0} */ public BufferedReader(Reader in, int sz) { super(in); @@ -484,7 +484,7 @@ public class BufferedReader extends Reader { * whose size is no smaller than limit. * Therefore large values should be used with care. * - * @exception IllegalArgumentException If readAheadLimit is < 0 + * @exception IllegalArgumentException If {@code readAheadLimit < 0} * @exception IOException If an I/O error occurs */ public void mark(int readAheadLimit) throws IOException { diff --git a/jdk/src/share/classes/java/io/BufferedWriter.java b/jdk/src/share/classes/java/io/BufferedWriter.java index 83a467e7266..01dfb175e82 100644 --- a/jdk/src/share/classes/java/io/BufferedWriter.java +++ b/jdk/src/share/classes/java/io/BufferedWriter.java @@ -95,7 +95,7 @@ public class BufferedWriter extends Writer { * @param out A Writer * @param sz Output-buffer size, a positive integer * - * @exception IllegalArgumentException If sz is <= 0 + * @exception IllegalArgumentException If {@code sz <= 0} */ public BufferedWriter(Writer out, int sz) { super(out); diff --git a/jdk/src/share/classes/java/io/Console.java b/jdk/src/share/classes/java/io/Console.java index c4987dc0934..c100f8a0ccd 100644 --- a/jdk/src/share/classes/java/io/Console.java +++ b/jdk/src/share/classes/java/io/Console.java @@ -75,7 +75,7 @@ import sun.nio.cs.StreamEncoder; * manually zero the returned character array after processing to minimize the * lifetime of sensitive data in memory. * - *

    + * 
    {@code
      * Console cons;
      * char[] passwd;
      * if ((cons = System.console()) != null &&
    @@ -83,7 +83,7 @@ import sun.nio.cs.StreamEncoder;
      *     ...
      *     java.util.Arrays.fill(passwd, ' ');
      * }
    - * 
    + * }
    * * @author Xueming Shen * @since 1.6 diff --git a/jdk/src/share/classes/java/io/PipedInputStream.java b/jdk/src/share/classes/java/io/PipedInputStream.java index ca2115430d7..4ad8fbd81d8 100644 --- a/jdk/src/share/classes/java/io/PipedInputStream.java +++ b/jdk/src/share/classes/java/io/PipedInputStream.java @@ -117,7 +117,7 @@ public class PipedInputStream extends InputStream { * @param src the stream to connect to. * @param pipeSize the size of the pipe's buffer. * @exception IOException if an I/O error occurs. - * @exception IllegalArgumentException if pipeSize <= 0. + * @exception IllegalArgumentException if {@code pipeSize <= 0}. * @since 1.6 */ public PipedInputStream(PipedOutputStream src, int pipeSize) @@ -147,7 +147,7 @@ public class PipedInputStream extends InputStream { * connected} to a PipedOutputStream before being used. * * @param pipeSize the size of the pipe's buffer. - * @exception IllegalArgumentException if pipeSize <= 0. + * @exception IllegalArgumentException if {@code pipeSize <= 0}. * @since 1.6 */ public PipedInputStream(int pipeSize) { diff --git a/jdk/src/share/classes/java/io/PipedReader.java b/jdk/src/share/classes/java/io/PipedReader.java index 95cfe1d7bd0..bb86022af6f 100644 --- a/jdk/src/share/classes/java/io/PipedReader.java +++ b/jdk/src/share/classes/java/io/PipedReader.java @@ -91,7 +91,7 @@ public class PipedReader extends Reader { * @param src the stream to connect to. * @param pipeSize the size of the pipe's buffer. * @exception IOException if an I/O error occurs. - * @exception IllegalArgumentException if pipeSize <= 0. + * @exception IllegalArgumentException if {@code pipeSize <= 0}. * @since 1.6 */ public PipedReader(PipedWriter src, int pipeSize) throws IOException { @@ -120,7 +120,7 @@ public class PipedReader extends Reader { * before being used. * * @param pipeSize the size of the pipe's buffer. - * @exception IllegalArgumentException if pipeSize <= 0. + * @exception IllegalArgumentException if {@code pipeSize <= 0}. * @since 1.6 */ public PipedReader(int pipeSize) { diff --git a/jdk/src/share/classes/java/io/PrintStream.java b/jdk/src/share/classes/java/io/PrintStream.java index c4cd01f470f..b803c6a657f 100644 --- a/jdk/src/share/classes/java/io/PrintStream.java +++ b/jdk/src/share/classes/java/io/PrintStream.java @@ -851,7 +851,7 @@ public class PrintStream extends FilterOutputStream * null argument depends on the conversion. * - * @throws IllegalFormatException + * @throws java.util.IllegalFormatException * If a format string contains an illegal syntax, a format * specifier that is incompatible with the given arguments, * insufficient arguments given the format string, or other @@ -901,7 +901,7 @@ public class PrintStream extends FilterOutputStream * null argument depends on the conversion. * - * @throws IllegalFormatException + * @throws java.util.IllegalFormatException * If a format string contains an illegal syntax, a format * specifier that is incompatible with the given arguments, * insufficient arguments given the format string, or other @@ -944,7 +944,7 @@ public class PrintStream extends FilterOutputStream * null argument depends on the conversion. * - * @throws IllegalFormatException + * @throws java.util.IllegalFormatException * If a format string contains an illegal syntax, a format * specifier that is incompatible with the given arguments, * insufficient arguments given the format string, or other @@ -1001,7 +1001,7 @@ public class PrintStream extends FilterOutputStream * null argument depends on the conversion. * - * @throws IllegalFormatException + * @throws java.util.IllegalFormatException * If a format string contains an illegal syntax, a format * specifier that is incompatible with the given arguments, * insufficient arguments given the format string, or other diff --git a/jdk/src/share/classes/java/io/PushbackInputStream.java b/jdk/src/share/classes/java/io/PushbackInputStream.java index af0b525a6f2..b81bec424bc 100644 --- a/jdk/src/share/classes/java/io/PushbackInputStream.java +++ b/jdk/src/share/classes/java/io/PushbackInputStream.java @@ -85,7 +85,7 @@ class PushbackInputStream extends FilterInputStream { * * @param in the input stream from which bytes will be read. * @param size the size of the pushback buffer. - * @exception IllegalArgumentException if size is <= 0 + * @exception IllegalArgumentException if {@code size <= 0} * @since JDK1.1 */ public PushbackInputStream(InputStream in, int size) { diff --git a/jdk/src/share/classes/java/io/PushbackReader.java b/jdk/src/share/classes/java/io/PushbackReader.java index 2f5b18cfefc..98ebd5dab9c 100644 --- a/jdk/src/share/classes/java/io/PushbackReader.java +++ b/jdk/src/share/classes/java/io/PushbackReader.java @@ -47,7 +47,7 @@ public class PushbackReader extends FilterReader { * * @param in The reader from which characters will be read * @param size The size of the pushback buffer - * @exception IllegalArgumentException if size is <= 0 + * @exception IllegalArgumentException if {@code size <= 0} */ public PushbackReader(Reader in, int size) { super(in); diff --git a/jdk/src/share/classes/java/io/StringReader.java b/jdk/src/share/classes/java/io/StringReader.java index 3778408e5f4..0cdf8fd2197 100644 --- a/jdk/src/share/classes/java/io/StringReader.java +++ b/jdk/src/share/classes/java/io/StringReader.java @@ -163,7 +163,7 @@ public class StringReader extends Reader { * is no actual limit, so this argument must not * be negative, but is otherwise ignored. * - * @exception IllegalArgumentException If readAheadLimit is < 0 + * @exception IllegalArgumentException If {@code readAheadLimit < 0} * @exception IOException If an I/O error occurs */ public void mark(int readAheadLimit) throws IOException { diff --git a/jdk/src/share/classes/java/lang/Character.java b/jdk/src/share/classes/java/lang/Character.java index 531263d3894..e512e582612 100644 --- a/jdk/src/share/classes/java/lang/Character.java +++ b/jdk/src/share/classes/java/lang/Character.java @@ -4782,9 +4782,9 @@ class Character implements java.io.Serializable, Comparable { * Unicode surrogate pair. *

    This method is equivalent to the expression: - *

    +     * 
    {@code
          * isHighSurrogate(high) && isLowSurrogate(low)
    -     * 
    + * }
    * * @param high the high-surrogate code value to be tested * @param low the low-surrogate code value to be tested diff --git a/jdk/src/share/classes/java/lang/ClassLoader.java b/jdk/src/share/classes/java/lang/ClassLoader.java index 8d0205f54f1..f26eafd980a 100644 --- a/jdk/src/share/classes/java/lang/ClassLoader.java +++ b/jdk/src/share/classes/java/lang/ClassLoader.java @@ -702,7 +702,7 @@ public abstract class ClassLoader { * bootstrap class loader. If name is not null, it * must be equal to the binary name of the class * specified by the byte array "b", otherwise a {@link - * NoClassDefFoundError} will be thrown.

    + * NoClassDefFoundError NoClassDefFoundError} will be thrown.

    * * @param name * The expected binary name of the class, or diff --git a/jdk/src/share/classes/java/lang/Comparable.java b/jdk/src/share/classes/java/lang/Comparable.java index 123e10aa4da..9d607679a61 100644 --- a/jdk/src/share/classes/java/lang/Comparable.java +++ b/jdk/src/share/classes/java/lang/Comparable.java @@ -56,7 +56,7 @@ import java.util.*; * method.

    * * For example, if one adds two keys a and b such that - * (!a.equals(b) && a.compareTo(b) == 0) to a sorted + * {@code (!a.equals(b) && a.compareTo(b) == 0)} to a sorted * set that does not use an explicit comparator, the second add * operation returns false (and the size of the sorted set does not increase) * because a and b are equivalent from the sorted set's diff --git a/jdk/src/share/classes/java/lang/Double.java b/jdk/src/share/classes/java/lang/Double.java index a32d04cf75f..3f0e2cddd0f 100644 --- a/jdk/src/share/classes/java/lang/Double.java +++ b/jdk/src/share/classes/java/lang/Double.java @@ -917,13 +917,13 @@ public final class Double extends Number implements Comparable { *

    In all other cases, let s, e, and m be three * values that can be computed from the argument: * - *

    -     * int s = ((bits >> 63) == 0) ? 1 : -1;
    -     * int e = (int)((bits >> 52) & 0x7ffL);
    +     * 
    {@code
    +     * int s = ((bits >> 63) == 0) ? 1 : -1;
    +     * int e = (int)((bits >> 52) & 0x7ffL);
          * long m = (e == 0) ?
    -     *                 (bits & 0xfffffffffffffL) << 1 :
    +     *                 (bits & 0xfffffffffffffL) << 1 :
          *                 (bits & 0xfffffffffffffL) | 0x10000000000000L;
    -     * 
    + * }
    * * Then the floating-point result equals the value of the mathematical * expression s·m·2e-1075. diff --git a/jdk/src/share/classes/java/lang/Float.java b/jdk/src/share/classes/java/lang/Float.java index 5b077111fe0..e46dff02a3b 100644 --- a/jdk/src/share/classes/java/lang/Float.java +++ b/jdk/src/share/classes/java/lang/Float.java @@ -821,13 +821,13 @@ public final class Float extends Number implements Comparable { *

    In all other cases, let s, e, and m be three * values that can be computed from the argument: * - *

    -     * int s = ((bits >> 31) == 0) ? 1 : -1;
    -     * int e = ((bits >> 23) & 0xff);
    +     * 
    {@code
    +     * int s = ((bits >> 31) == 0) ? 1 : -1;
    +     * int e = ((bits >> 23) & 0xff);
          * int m = (e == 0) ?
    -     *                 (bits & 0x7fffff) << 1 :
    +     *                 (bits & 0x7fffff) << 1 :
          *                 (bits & 0x7fffff) | 0x800000;
    -     * 
    + * }
    * * Then the floating-point result equals the value of the mathematical * expression s·m·2e-150. diff --git a/jdk/src/share/classes/java/lang/StackTraceElement.java b/jdk/src/share/classes/java/lang/StackTraceElement.java index b973d0f4293..4543749bb00 100644 --- a/jdk/src/share/classes/java/lang/StackTraceElement.java +++ b/jdk/src/share/classes/java/lang/StackTraceElement.java @@ -181,12 +181,12 @@ public final class StackTraceElement implements java.io.Serializable { * {@code StackTraceElement} instance representing the same execution * point as this instance. Two stack trace elements {@code a} and * {@code b} are equal if and only if: - *
    +     * 
    {@code
          *     equals(a.getFileName(), b.getFileName()) &&
          *     a.getLineNumber() == b.getLineNumber()) &&
          *     equals(a.getClassName(), b.getClassName()) &&
          *     equals(a.getMethodName(), b.getMethodName())
    -     * 
    + * }
    * where {@code equals} has the semantics of {@link * java.util.Objects#equals(Object, Object) Objects.equals}. * diff --git a/jdk/src/share/classes/java/lang/instrument/Instrumentation.java b/jdk/src/share/classes/java/lang/instrument/Instrumentation.java index 3d2083d6c61..1844837fd3b 100644 --- a/jdk/src/share/classes/java/lang/instrument/Instrumentation.java +++ b/jdk/src/share/classes/java/lang/instrument/Instrumentation.java @@ -593,24 +593,28 @@ public interface Instrumentation { * and the normal automatic resolution. For * RegisterNatives, the JVM will attempt this * association: - *
    -     *   method(foo) -> nativeImplementation(foo)
    + *
    {@code
    +     *   method(foo) -> nativeImplementation(foo)
    +     * }
    *

    * When this fails, the resolution will be retried with * the specified prefix prepended to the method name, * yielding the correct resolution: - *

    -     *   method(wrapped_foo) -> nativeImplementation(foo)
    + *
    {@code
    +     *   method(wrapped_foo) -> nativeImplementation(foo)
    +     * }
    *

    * For automatic resolution, the JVM will attempt: - *

    -     *   method(wrapped_foo) -> nativeImplementation(wrapped_foo)
    + *
    {@code
    +     *   method(wrapped_foo) -> nativeImplementation(wrapped_foo)
    +     * }
    *

    * When this fails, the resolution will be retried with * the specified prefix deleted from the implementation name, * yielding the correct resolution: - *

    -     *   method(wrapped_foo) -> nativeImplementation(foo)
    + *
    {@code
    +     *   method(wrapped_foo) -> nativeImplementation(foo)
    +     * }
    *

    * Note that since the prefix is only used when standard * resolution fails, native methods can be wrapped selectively. diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandle.java b/jdk/src/share/classes/java/lang/invoke/MethodHandle.java index 774faff5afb..06084056fb4 100644 --- a/jdk/src/share/classes/java/lang/invoke/MethodHandle.java +++ b/jdk/src/share/classes/java/lang/invoke/MethodHandle.java @@ -251,7 +251,7 @@ import java.util.logging.Logger; * *

    Usage examples

    * Here are some examples of usage: - *

    + * 

    {@code
     Object x, y; String s; int i;
     MethodType mt; MethodHandle mh;
     MethodHandles.Lookup lookup = MethodHandles.lookup();
    @@ -287,7 +287,7 @@ mt = MethodType.methodType(void.class, String.class);
     mh = lookup.findVirtual(java.io.PrintStream.class, "println", mt);
     mh.invokeExact(System.out, "Hello, world.");
     // invokeExact(Ljava/io/PrintStream;Ljava/lang/String;)V
    - * 
    + * }
    * Each of the above calls to {@code invokeExact} or plain {@code invoke} * generates a single invokevirtual instruction with * the symbolic type descriptor indicated in the following comment. @@ -754,7 +754,7 @@ public abstract class MethodHandle { * (The array may also be null when zero elements are required.) *

    * Here are some simple examples of array-spreading method handles: - *

    +     * 
    {@code
     MethodHandle equals = publicLookup()
       .findVirtual(String.class, "equals", methodType(boolean.class, Object.class));
     assert( (boolean) equals.invokeExact("me", (Object)"me"));
    @@ -790,7 +790,7 @@ MethodHandle caString3 = caToString.asCollector(char[].class, 3);
     assertEquals("[A, B, C]", (String) caString3.invokeExact('A', 'B', 'C'));
     MethodHandle caToString2 = caString3.asSpreader(char[].class, 2);
     assertEquals("[A, B, C]", (String) caToString2.invokeExact('A', "BC".toCharArray()));
    -     * 
    + * }
    * @param arrayType usually {@code Object[]}, the type of the array argument from which to extract the spread arguments * @param arrayLength the number of arguments to spread from an incoming array argument * @return a new method handle which spreads its final array argument, @@ -878,7 +878,7 @@ assertEquals("[A, B, C]", (String) caToString2.invokeExact('A', "BC".toCharArray * number of collected arguments, use {@link #asVarargsCollector asVarargsCollector} instead. *

    * Here are some examples of array-collecting method handles: - *

    +     * 
    {@code
     MethodHandle deepToString = publicLookup()
       .findStatic(Arrays.class, "deepToString", methodType(String.class, Object[].class));
     assertEquals("[won]",   (String) deepToString.invokeExact(new Object[]{"won"}));
    @@ -904,7 +904,7 @@ MethodHandle longsToString = publicLookup()
       .findStatic(Arrays.class, "toString", methodType(String.class, long[].class))
       .asCollector(long[].class, 1);
     assertEquals("[123]", (String) longsToString.invokeExact((long)123));
    -     * 
    + * }
    * @param arrayType often {@code Object[]}, the type of the array argument which will collect the arguments * @param arrayLength the number of arguments to collect into a new array argument * @return a new method handle which collects some trailing argument @@ -1041,7 +1041,7 @@ assertEquals("[123]", (String) longsToString.invokeExact((long)123)); * It may (or may not) return the original variable arity method handle. *

    * Here is an example, of a list-making variable arity method handle: - *

    +     * 
    {@code
     MethodHandle deepToString = publicLookup()
       .findStatic(Arrays.class, "deepToString", methodType(String.class, Object[].class));
     MethodHandle ts1 = deepToString.asVarargsCollector(Object[].class);
    @@ -1063,7 +1063,7 @@ assertEquals("[three, thee, tee]", asList.invoke((Object[])argv).toString());
     List ls = (List) asList.invoke((Object)argv);
     assertEquals(1, ls.size());
     assertEquals("[three, thee, tee]", Arrays.toString((Object[])ls.get(0)));
    -     * 
    + * }
    *

    * Discussion: * These rules are designed as a dynamically-typed variation @@ -1134,7 +1134,7 @@ assertEquals("[three, thee, tee]", Arrays.toString((Object[])ls.get(0))); * a previous argument to {@code asVarargsCollector}. *

    * Here is an example, of a list-making variable arity method handle: - *

    +     * 
    {@code
     MethodHandle asListVar = publicLookup()
       .findStatic(Arrays.class, "asList", methodType(List.class, Object[].class))
       .asVarargsCollector(Object[].class);
    @@ -1153,7 +1153,7 @@ assertEquals("[three, thee, tee]", asListVar.invoke(argv).toString());
     assertEquals("[three, thee, tee]", asListFix.invoke(argv).toString());
     assertEquals(1, ((List) asListVar.invoke((Object)argv)).size());
     assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
    -     * 
    + * }
    * * @return a new method handle which accepts only a fixed number of arguments * @see #asVarargsCollector diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/share/classes/java/lang/invoke/MethodHandles.java index fa3cb607855..9c54f3cf7f1 100644 --- a/jdk/src/share/classes/java/lang/invoke/MethodHandles.java +++ b/jdk/src/share/classes/java/lang/invoke/MethodHandles.java @@ -1593,7 +1593,7 @@ publicLookup().findVirtual(MethodHandle.class, "invoke", type) * As in the case of {@link #dropArguments(MethodHandle,int,List) dropArguments}, * incoming arguments which are not mentioned in the reordering array * are may be any type, as determined only by {@code newType}. - *
    +     * 
    {@code
     import static java.lang.invoke.MethodHandles.*;
     import static java.lang.invoke.MethodType.*;
     ...
    @@ -1609,7 +1609,7 @@ assert(add.type().equals(intfn2));
     MethodHandle twice = permuteArguments(add, intfn1, 0, 0);
     assert(twice.type().equals(intfn1));
     assert((int)twice.invokeExact(21) == 42);
    -     * 
    + * }
    * @param target the method handle to invoke after arguments are reordered * @param newType the expected type of the new method handle * @param reorder an index array which controls the reordering diff --git a/jdk/src/share/classes/java/lang/management/MemoryUsage.java b/jdk/src/share/classes/java/lang/management/MemoryUsage.java index c223c710728..4dc23c0fe46 100644 --- a/jdk/src/share/classes/java/lang/management/MemoryUsage.java +++ b/jdk/src/share/classes/java/lang/management/MemoryUsage.java @@ -72,8 +72,8 @@ import sun.management.MemoryUsageCompositeData; * The amount of used and committed memory will always be less than * or equal to max if max is defined. * A memory allocation may fail if it attempts to increase the - * used memory such that used > committed even - * if used <= max would still be true (for example, + * used memory such that used > committed even + * if used <= max would still be true (for example, * when the system is low on virtual memory). * * diff --git a/jdk/src/share/classes/java/lang/management/RuntimeMXBean.java b/jdk/src/share/classes/java/lang/management/RuntimeMXBean.java index 62463af44e4..e4142d3e439 100644 --- a/jdk/src/share/classes/java/lang/management/RuntimeMXBean.java +++ b/jdk/src/share/classes/java/lang/management/RuntimeMXBean.java @@ -308,7 +308,7 @@ public interface RuntimeMXBean extends PlatformManagedObject { * *

    * MBeanServer access:
    - * The mapped type of Map is + * The mapped type of {@code Map} is * {@link javax.management.openmbean.TabularData TabularData} * with two items in each row as follows: *

    diff --git a/jdk/src/share/classes/java/lang/management/ThreadMXBean.java b/jdk/src/share/classes/java/lang/management/ThreadMXBean.java index f804af1942f..30251d51f60 100644 --- a/jdk/src/share/classes/java/lang/management/ThreadMXBean.java +++ b/jdk/src/share/classes/java/lang/management/ThreadMXBean.java @@ -198,7 +198,7 @@ public interface ThreadMXBean extends PlatformManagedObject { * null if the thread of the given ID is not alive or * it does not exist. * - * @throws IllegalArgumentException if id <= 0. + * @throws IllegalArgumentException if {@code id <= 0}. * @throws java.lang.SecurityException if a security manager * exists and the caller does not have * ManagementPermission("monitor"). @@ -236,7 +236,7 @@ public interface ThreadMXBean extends PlatformManagedObject { * with no stack trace, no locked monitor and no synchronizer info. * * @throws IllegalArgumentException if any element in the input array - * ids is <= 0. + * ids is {@code <= 0}. * @throws java.lang.SecurityException if a security manager * exists and the caller does not have * ManagementPermission("monitor"). @@ -282,7 +282,7 @@ public interface ThreadMXBean extends PlatformManagedObject { * null if the thread of the given ID is not alive or * it does not exist. * - * @throws IllegalArgumentException if id <= 0. + * @throws IllegalArgumentException if {@code id <= 0}. * @throws IllegalArgumentException if maxDepth is negative. * @throws java.lang.SecurityException if a security manager * exists and the caller does not have @@ -336,7 +336,7 @@ public interface ThreadMXBean extends PlatformManagedObject { * * @throws IllegalArgumentException if maxDepth is negative. * @throws IllegalArgumentException if any element in the input array - * ids is <= 0. + * ids is {@code <= 0}. * @throws java.lang.SecurityException if a security manager * exists and the caller does not have * ManagementPermission("monitor"). @@ -466,7 +466,7 @@ public interface ThreadMXBean extends PlatformManagedObject { * and CPU time measurement is enabled; * -1 otherwise. * - * @throws IllegalArgumentException if id <= 0 . + * @throws IllegalArgumentException if {@code id <= 0}. * @throws java.lang.UnsupportedOperationException if the Java * virtual machine does not support CPU time measurement for * other threads. @@ -501,7 +501,7 @@ public interface ThreadMXBean extends PlatformManagedObject { * and CPU time measurement is enabled; * -1 otherwise. * - * @throws IllegalArgumentException if id <= 0 . + * @throws IllegalArgumentException if {@code id <= 0}. * @throws java.lang.UnsupportedOperationException if the Java * virtual machine does not support CPU time measurement for * other threads. diff --git a/jdk/src/share/classes/java/net/CookieManager.java b/jdk/src/share/classes/java/net/CookieManager.java index 90c7262b478..fde828f95ea 100644 --- a/jdk/src/share/classes/java/net/CookieManager.java +++ b/jdk/src/share/classes/java/net/CookieManager.java @@ -41,7 +41,7 @@ import sun.util.logging.PlatformLogger; * *

    The HTTP cookie management in java.net package looks like: *

    - *
    + * 
    {@code
      *                  use
      * CookieHandler <------- HttpURLConnection
      *       ^
    @@ -58,7 +58,7 @@ import sun.util.logging.PlatformLogger;
      *                            | impl
      *                            |
      *                  Internal in-memory implementation
    - * 
    + * }
    *
      *
    • * CookieHandler is at the core of cookie management. User can call diff --git a/jdk/src/share/classes/java/net/CookiePolicy.java b/jdk/src/share/classes/java/net/CookiePolicy.java index aae5c1a8053..3de98f904da 100644 --- a/jdk/src/share/classes/java/net/CookiePolicy.java +++ b/jdk/src/share/classes/java/net/CookiePolicy.java @@ -30,7 +30,7 @@ package java.net; * and which should be rejected. Three pre-defined policy implementations * are provided, namely ACCEPT_ALL, ACCEPT_NONE and ACCEPT_ORIGINAL_SERVER. * - *

      See RFC 2965 sec. 3.3 & 7 for more detail. + *

      See RFC 2965 sec. 3.3 and 7 for more detail. * * @author Edward Wang * @since 1.6 diff --git a/jdk/src/share/classes/java/net/DatagramSocket.java b/jdk/src/share/classes/java/net/DatagramSocket.java index ad0af4850d5..d6ffca23755 100644 --- a/jdk/src/share/classes/java/net/DatagramSocket.java +++ b/jdk/src/share/classes/java/net/DatagramSocket.java @@ -334,12 +334,12 @@ class DatagramSocket implements java.io.Closeable { } /** - * Binds this DatagramSocket to a specific address & port. + * Binds this DatagramSocket to a specific address and port. *

      * If the address is null, then the system will pick up * an ephemeral port and a valid local address to bind the socket. *

      - * @param addr The address & port to bind to. + * @param addr The address and port to bind to. * @throws SocketException if any error happens during the bind, or if the * socket is already bound. * @throws SecurityException if a security manager exists and its @@ -844,7 +844,7 @@ class DatagramSocket implements java.io.Closeable { * a java.net.SocketTimeoutException is raised, though the * DatagramSocket is still valid. The option must be enabled * prior to entering the blocking operation to have effect. The - * timeout must be > 0. + * timeout must be {@code > 0}. * A timeout of zero is interpreted as an infinite timeout. * * @param timeout the specified timeout in milliseconds. @@ -1101,8 +1101,8 @@ class DatagramSocket implements java.io.Closeable { * As the underlying network implementation may ignore this * value applications should consider it a hint. * - *

      The tc must be in the range 0 <= tc <= - * 255 or an IllegalArgumentException will be thrown. + *

      The tc must be in the range {@code 0 <= tc <= + * 255} or an IllegalArgumentException will be thrown. *

      Notes: *

      For Internet Protocol v4 the value consists of an * integer, the least significant 8 bits of which diff --git a/jdk/src/share/classes/java/net/HttpURLConnection.java b/jdk/src/share/classes/java/net/HttpURLConnection.java index 193b9cef1c1..b93f1e731bd 100644 --- a/jdk/src/share/classes/java/net/HttpURLConnection.java +++ b/jdk/src/share/classes/java/net/HttpURLConnection.java @@ -109,7 +109,7 @@ abstract public class HttpURLConnection extends URLConnection { * server. In this case, {@link #getHeaderField(int) getHeaderField(0)} returns the status * line, but getHeaderFieldKey(0) returns null. * - * @param n an index, where n >=0. + * @param n an index, where {@code n >=0}. * @return the key for the nth header field, * or null if the key does not exist. */ @@ -260,7 +260,7 @@ abstract public class HttpURLConnection extends URLConnection { * {@link #getHeaderFieldKey getHeaderFieldKey} method to iterate through all * the headers in the message. * - * @param n an index, where n>=0. + * @param n an index, where {@code n>=0}. * @return the value of the nth header field, * or null if the value does not exist. * @see java.net.HttpURLConnection#getHeaderFieldKey(int) diff --git a/jdk/src/share/classes/java/net/InetSocketAddress.java b/jdk/src/share/classes/java/net/InetSocketAddress.java index 4ad95043470..44604c664aa 100644 --- a/jdk/src/share/classes/java/net/InetSocketAddress.java +++ b/jdk/src/share/classes/java/net/InetSocketAddress.java @@ -389,7 +389,7 @@ public class InetSocketAddress * Two instances of InetSocketAddress represent the same * address if both the InetAddresses (or hostnames if it is unresolved) and port * numbers are equal. - * If both addresses are unresolved, then the hostname & the port number + * If both addresses are unresolved, then the hostname and the port number * are compared. * * Note: Hostnames are case insensitive. e.g. "FooBar" and "foobar" are diff --git a/jdk/src/share/classes/java/net/MulticastSocket.java b/jdk/src/share/classes/java/net/MulticastSocket.java index ad4c7566aa1..0a4d7c1023d 100644 --- a/jdk/src/share/classes/java/net/MulticastSocket.java +++ b/jdk/src/share/classes/java/net/MulticastSocket.java @@ -201,7 +201,7 @@ class MulticastSocket extends DatagramSocket { * scope of the multicasts. * *

      The ttl is an unsigned 8-bit quantity, and so must be - * in the range 0 <= ttl <= 0xFF . + * in the range {@code 0 <= ttl <= 0xFF }. * * @param ttl the time-to-live * @exception IOException if an I/O exception occurs diff --git a/jdk/src/share/classes/java/net/ServerSocket.java b/jdk/src/share/classes/java/net/ServerSocket.java index b47e4420e44..52600bff6f9 100644 --- a/jdk/src/share/classes/java/net/ServerSocket.java +++ b/jdk/src/share/classes/java/net/ServerSocket.java @@ -316,7 +316,7 @@ class ServerSocket implements java.io.Closeable { * If the address is null, then the system will pick up * an ephemeral port and a valid local address to bind the socket. *

      - * @param endpoint The IP address & port number to bind to. + * @param endpoint The IP address and port number to bind to. * @throws IOException if the bind operation fails, or if the socket * is already bound. * @throws SecurityException if a SecurityManager is present and @@ -343,7 +343,7 @@ class ServerSocket implements java.io.Closeable { * or may choose to ignore the parameter altogther. The value provided * should be greater than 0. If it is less than or equal to * 0, then an implementation specific default will be used. - * @param endpoint The IP address & port number to bind to. + * @param endpoint The IP address and port number to bind to. * @param backlog requested maximum length of the queue of * incoming connections. * @throws IOException if the bind operation fails, or if the socket @@ -614,7 +614,7 @@ class ServerSocket implements java.io.Closeable { * a java.net.SocketTimeoutException is raised, though the * ServerSocket is still valid. The option must be enabled * prior to entering the blocking operation to have effect. The - * timeout must be > 0. + * timeout must be {@code > 0}. * A timeout of zero is interpreted as an infinite timeout. * @param timeout the specified timeout, in milliseconds * @exception SocketException if there is an error in diff --git a/jdk/src/share/classes/java/net/Socket.java b/jdk/src/share/classes/java/net/Socket.java index e0635c1bf9f..08b7ae616c5 100644 --- a/jdk/src/share/classes/java/net/Socket.java +++ b/jdk/src/share/classes/java/net/Socket.java @@ -1086,7 +1086,7 @@ class Socket implements java.io.Closeable { * expires, a java.net.SocketTimeoutException is raised, though the * Socket is still valid. The option must be enabled * prior to entering the blocking operation to have effect. The - * timeout must be > 0. + * timeout must be {@code > 0}. * A timeout of zero is interpreted as an infinite timeout. * * @param timeout the specified timeout, in milliseconds. @@ -1295,8 +1295,8 @@ class Socket implements java.io.Closeable { * As the underlying network implementation may ignore this * value applications should consider it a hint. * - *

      The tc must be in the range 0 <= tc <= - * 255 or an IllegalArgumentException will be thrown. + *

      The tc must be in the range {@code 0 <= tc <= + * 255} or an IllegalArgumentException will be thrown. *

      Notes: *

      For Internet Protocol v4 the value consists of an * integer, the least significant 8 bits of which diff --git a/jdk/src/share/classes/java/net/StandardSocketOptions.java b/jdk/src/share/classes/java/net/StandardSocketOptions.java index 9aeed2b5a28..84fedd804f1 100644 --- a/jdk/src/share/classes/java/net/StandardSocketOptions.java +++ b/jdk/src/share/classes/java/net/StandardSocketOptions.java @@ -277,8 +277,8 @@ public final class StandardSocketOptions { * The time-to-live for Internet Protocol (IP) multicast datagrams. * *

      The value of this socket option is an {@code Integer} in the range - * 0 <= value <= 255. It is used to control - * the scope of multicast datagrams sent by the datagram-oriented socket. + * {@code 0 <= value <= 255}. It is used to control the scope of multicast + * datagrams sent by the datagram-oriented socket. * In the case of an {@link StandardProtocolFamily#INET IPv4} socket * the option is the time-to-live (TTL) on multicast datagrams sent by the * socket. Datagrams with a TTL of zero are not transmitted on the network diff --git a/jdk/src/share/classes/java/net/URI.java b/jdk/src/share/classes/java/net/URI.java index b4b22ded16b..ed90f090c29 100644 --- a/jdk/src/share/classes/java/net/URI.java +++ b/jdk/src/share/classes/java/net/URI.java @@ -258,7 +258,7 @@ import java.lang.NullPointerException; // for javadoc * All alphanum characters together with those in the string * "_-!.~'()*" * punct - * The characters in the string ",;:$&+=" + * The characters in the string ",;:$&+=" * reserved * All punct characters together with those in the string * "?/[]@" diff --git a/jdk/src/share/classes/java/net/URLConnection.java b/jdk/src/share/classes/java/net/URLConnection.java index f1c51880734..b69c00f94a3 100644 --- a/jdk/src/share/classes/java/net/URLConnection.java +++ b/jdk/src/share/classes/java/net/URLConnection.java @@ -662,7 +662,7 @@ public abstract class URLConnection { * Returns the key for the nth header field. * It returns null if there are fewer than n+1 fields. * - * @param n an index, where n>=0 + * @param n an index, where {@code n>=0} * @return the key for the nth header field, * or null if there are fewer than n+1 * fields. @@ -680,7 +680,7 @@ public abstract class URLConnection { * {@link #getHeaderFieldKey(int) getHeaderFieldKey} method to iterate through all * the headers in the message. * - * @param n an index, where n>=0 + * @param n an index, where {@code n>=0} * @return the value of the nth header field * or null if there are fewer than n+1 fields * @see java.net.URLConnection#getHeaderFieldKey(int) diff --git a/jdk/src/share/classes/java/nio/X-Buffer.java.template b/jdk/src/share/classes/java/nio/X-Buffer.java.template index 475818d300d..738b18b51a1 100644 --- a/jdk/src/share/classes/java/nio/X-Buffer.java.template +++ b/jdk/src/share/classes/java/nio/X-Buffer.java.template @@ -652,9 +652,10 @@ public abstract class $Type$Buffer * src.get(dst, off, len) has exactly the same effect as * the loop * - *

      +     * 
      {@code
            *     for (int i = off; i < off + len; i++)
      -     *         dst[i] = src.get(); 
      + * dst[i] = src.get(): + * }
      * * except that it first checks that there are sufficient $type$s in * this buffer and it is potentially much more efficient.

      @@ -788,9 +789,10 @@ public abstract class $Type$Buffer * dst.put(src, off, len) has exactly the same effect as * the loop * - *
      +     * 
      {@code
            *     for (int i = off; i < off + len; i++)
      -     *         dst.put(a[i]); 
      + * dst.put(a[i]); + * }
      * * except that it first checks that there is sufficient space in this * buffer and it is potentially much more efficient.

      @@ -874,9 +876,10 @@ public abstract class $Type$Buffer * dst.put(src, start, end) has exactly the same effect * as the loop * - *
      +     * 
      {@code
            *     for (int i = start; i < end; i++)
      -     *         dst.put(src.charAt(i)); 
      + * dst.put(src.charAt(i)); + * }
      * * except that it first checks that there is sufficient space in this * buffer and it is potentially much more efficient.

      @@ -1038,12 +1041,13 @@ public abstract class $Type$Buffer * write was incomplete. The following loop, for example, copies bytes * from one channel to another via the buffer buf: * - *
      -     * buf.clear();          // Prepare buffer for use
      -     * while (in.read(buf) >= 0 || buf.position != 0) {
      -     *     buf.flip();
      -     *     out.write(buf);
      -     *     buf.compact();    // In case of partial write
      +     * 
      {@code
      +     *   buf.clear();          // Prepare buffer for use
      +     *   while (in.read(buf) >= 0 || buf.position != 0) {
      +     *       buf.flip();
      +     *       out.write(buf);
      +     *       buf.compact();    // In case of partial write
      +     *   }
            * }
      * #end[byte] diff --git a/jdk/src/share/classes/java/nio/channels/SelectableChannel.java b/jdk/src/share/classes/java/nio/channels/SelectableChannel.java index 8b7c7125786..35569e86ed7 100644 --- a/jdk/src/share/classes/java/nio/channels/SelectableChannel.java +++ b/jdk/src/share/classes/java/nio/channels/SelectableChannel.java @@ -208,7 +208,7 @@ public abstract class SelectableChannel * @throws IllegalArgumentException * If a bit in the ops set does not correspond to an * operation that is supported by this channel, that is, if - * set & ~validOps() != 0 + * {@code set & ~validOps() != 0} * * @return A key representing the registration of this channel with * the given selector @@ -265,8 +265,8 @@ public abstract class SelectableChannel * * @throws IllegalArgumentException * If a bit in ops does not correspond to an operation - * that is supported by this channel, that is, if set & - * ~validOps() != 0 + * that is supported by this channel, that is, if {@code set & + * ~validOps() != 0} * * @return A key representing the registration of this channel with * the given selector diff --git a/jdk/src/share/classes/java/nio/channels/SelectionKey.java b/jdk/src/share/classes/java/nio/channels/SelectionKey.java index ee339db09e9..2280cb9e216 100644 --- a/jdk/src/share/classes/java/nio/channels/SelectionKey.java +++ b/jdk/src/share/classes/java/nio/channels/SelectionKey.java @@ -191,7 +191,7 @@ public abstract class SelectionKey { * @throws IllegalArgumentException * If a bit in the set does not correspond to an operation that * is supported by this key's channel, that is, if - * (ops & ~channel().validOps()) != 0 + * {@code (ops & ~channel().validOps()) != 0} * * @throws CancelledKeyException * If this key has been cancelled @@ -272,15 +272,15 @@ public abstract class SelectionKey { *

      An invocation of this method of the form k.isReadable() * behaves in exactly the same way as the expression * - *

      -     * k.readyOps() & OP_READ != 0
      + *
      {@code
      +     * k.readyOps() & OP_READ != 0
      +     * }
      * *

      If this key's channel does not support read operations then this * method always returns false.

      * * @return true if, and only if, - * readyOps() & OP_READ is - * nonzero + {@code readyOps() & OP_READ} is nonzero * * @throws CancelledKeyException * If this key has been cancelled @@ -295,15 +295,15 @@ public abstract class SelectionKey { *

      An invocation of this method of the form k.isWritable() * behaves in exactly the same way as the expression * - *

      -     * k.readyOps() & OP_WRITE != 0
      + *
      {@code
      +     * k.readyOps() & OP_WRITE != 0
      +     * }
      * *

      If this key's channel does not support write operations then this * method always returns false.

      * * @return true if, and only if, - * readyOps() & OP_WRITE - * is nonzero + * {@code readyOps() & OP_WRITE} is nonzero * * @throws CancelledKeyException * If this key has been cancelled @@ -319,15 +319,15 @@ public abstract class SelectionKey { *

      An invocation of this method of the form k.isConnectable() * behaves in exactly the same way as the expression * - *

      -     * k.readyOps() & OP_CONNECT != 0
      + *
      {@code
      +     * k.readyOps() & OP_CONNECT != 0
      +     * }
      * *

      If this key's channel does not support socket-connect operations * then this method always returns false.

      * * @return true if, and only if, - * readyOps() & OP_CONNECT - * is nonzero + * {@code readyOps() & OP_CONNECT} is nonzero * * @throws CancelledKeyException * If this key has been cancelled @@ -343,15 +343,15 @@ public abstract class SelectionKey { *

      An invocation of this method of the form k.isAcceptable() * behaves in exactly the same way as the expression * - *

      -     * k.readyOps() & OP_ACCEPT != 0
      + *
      {@code
      +     * k.readyOps() & OP_ACCEPT != 0
      +     * }
      * *

      If this key's channel does not support socket-accept operations then * this method always returns false.

      * * @return true if, and only if, - * readyOps() & OP_ACCEPT - * is nonzero + * {@code readyOps() & OP_ACCEPT} is nonzero * * @throws CancelledKeyException * If this key has been cancelled diff --git a/jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java.template b/jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java.template index 2449d56cf44..8b115cc0fd2 100644 --- a/jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java.template +++ b/jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java.template @@ -260,7 +260,7 @@ public abstract class Charset$Coder$ { * method, passing the new replacement, after checking that the new * replacement is acceptable.

      * - * @param newReplacement + * @param newReplacement The replacement value * #if[decoder] * The new replacement; must not be null @@ -305,7 +305,7 @@ public abstract class Charset$Coder$ { * should be overridden by $coder$s that require notification of changes to * the replacement.

      * - * @param newReplacement + * @param newReplacement The replacement value */ protected void implReplaceWith($replType$ newReplacement) { } diff --git a/jdk/src/share/classes/java/nio/file/Path.java b/jdk/src/share/classes/java/nio/file/Path.java index a7933a34815..57782765854 100644 --- a/jdk/src/share/classes/java/nio/file/Path.java +++ b/jdk/src/share/classes/java/nio/file/Path.java @@ -64,7 +64,7 @@ import java.util.Iterator; * those developing custom file system implementations. Methods may be added to * this interface in future releases.

      * - *

      Accessing Files

      + *

      Accessing Files

      *

      Paths may be used with the {@link Files} class to operate on files, * directories, and other types of files. For example, suppose we want a {@link * java.io.BufferedReader} to read text from a file "{@code access.log}". The @@ -87,7 +87,7 @@ import java.util.Iterator; * addition, the {@link #toFile toFile} method is useful to construct a {@code * File} from the {@code String} representation of a {@code Path}. * - *

      Concurrency

      + *

      Concurrency

      *

      Implementations of this interface are immutable and safe for use by * multiple concurrent threads. * diff --git a/jdk/src/share/classes/java/security/KeyStore.java b/jdk/src/share/classes/java/security/KeyStore.java index 75d405771a7..5f1482c75ad 100644 --- a/jdk/src/share/classes/java/security/KeyStore.java +++ b/jdk/src/share/classes/java/security/KeyStore.java @@ -317,7 +317,7 @@ public class KeyStore { * been specified by properties in the domain configuration data. * It is cloned to prevent subsequent modification. * - * @exception NullPointerExcetion if {@code configuration} or + * @exception NullPointerException if {@code configuration} or * {@code protectionParams} is {@code null} */ public DomainLoadStoreParameter(URI configuration, diff --git a/jdk/src/share/classes/java/security/SecureRandom.java b/jdk/src/share/classes/java/security/SecureRandom.java index 1b4872fa6eb..7d25b147ed3 100644 --- a/jdk/src/share/classes/java/security/SecureRandom.java +++ b/jdk/src/share/classes/java/security/SecureRandom.java @@ -466,7 +466,7 @@ public class SecureRandom extends java.util.Random { * nextLong, and nextFloat). * * @param numBits number of pseudo-random bits to be generated, where - * 0 <= numBits <= 32. + * {@code 0 <= numBits <= 32}. * * @return an int containing the user-specified number * of pseudo-random bits (right justified, with leading zeros). diff --git a/jdk/src/share/classes/java/security/cert/CertPathValidatorException.java b/jdk/src/share/classes/java/security/cert/CertPathValidatorException.java index 9eedb620d9a..03cae751a0f 100644 --- a/jdk/src/share/classes/java/security/cert/CertPathValidatorException.java +++ b/jdk/src/share/classes/java/security/cert/CertPathValidatorException.java @@ -141,8 +141,8 @@ public class CertPathValidatorException extends GeneralSecurityException { * that caused the error (or -1 if not applicable). Note that * the list of certificates in a CertPath is zero based. * @throws IndexOutOfBoundsException if the index is out of range - * (index < -1 || (certPath != null && index >= - * certPath.getCertificates().size()) + * {@code (index < -1 || (certPath != null && index >= + * certPath.getCertificates().size()) } * @throws IllegalArgumentException if certPath is * null and index is not -1 */ @@ -164,8 +164,8 @@ public class CertPathValidatorException extends GeneralSecurityException { * the list of certificates in a CertPath is zero based. * @param reason the reason the validation failed * @throws IndexOutOfBoundsException if the index is out of range - * (index < -1 || (certPath != null && index >= - * certPath.getCertificates().size()) + * {@code (index < -1 || (certPath != null && index >= + * certPath.getCertificates().size()) } * @throws IllegalArgumentException if certPath is * null and index is not -1 * @throws NullPointerException if reason is null diff --git a/jdk/src/share/classes/java/security/cert/CertificateFactory.java b/jdk/src/share/classes/java/security/cert/CertificateFactory.java index 57a3fe15f45..d0762df16be 100644 --- a/jdk/src/share/classes/java/security/cert/CertificateFactory.java +++ b/jdk/src/share/classes/java/security/cert/CertificateFactory.java @@ -65,7 +65,7 @@ import sun.security.jca.GetInstance.Instance; * read position of the input stream is positioned to the next certificate in * the file:

      * - *

      + * 
      {@code
        * FileInputStream fis = new FileInputStream(filename);
        * BufferedInputStream bis = new BufferedInputStream(fis);
        *
      @@ -75,7 +75,7 @@ import sun.security.jca.GetInstance.Instance;
        *    Certificate cert = cf.generateCertificate(bis);
        *    System.out.println(cert.toString());
        * }
      - * 
      + * }
      * *

      The following example parses a PKCS#7-formatted certificate reply stored * in a file and extracts all the certificates from it:

      diff --git a/jdk/src/share/classes/java/security/cert/X509Extension.java b/jdk/src/share/classes/java/security/cert/X509Extension.java index e2c362ee3ff..ee63e662347 100644 --- a/jdk/src/share/classes/java/security/cert/X509Extension.java +++ b/jdk/src/share/classes/java/security/cert/X509Extension.java @@ -84,12 +84,12 @@ public interface X509Extension { * * Here is sample code to get a Set of critical extensions from an * X509Certificate and print the OIDs: - *

      
      +     * 
      {@code
            * X509Certificate cert = null;
            * try (InputStream inStrm = new FileInputStream("DER-encoded-Cert")) {
            *     CertificateFactory cf = CertificateFactory.getInstance("X.509");
            *     cert = (X509Certificate)cf.generateCertificate(inStrm);
      -     * }

      + * } * * Set critSet = cert.getCriticalExtensionOIDs(); * if (critSet != null && !critSet.isEmpty()) { @@ -98,7 +98,7 @@ public interface X509Extension { * System.out.println(oid); * } * } - *

      + * }
      * @return a Set (or an empty Set if none are marked critical) of * the extension OID strings for extensions that are marked critical. * If there are no extensions present at all, then this method returns diff --git a/jdk/src/share/classes/java/security/spec/EllipticCurve.java b/jdk/src/share/classes/java/security/spec/EllipticCurve.java index a270ee72494..d9eef25caf8 100644 --- a/jdk/src/share/classes/java/security/spec/EllipticCurve.java +++ b/jdk/src/share/classes/java/security/spec/EllipticCurve.java @@ -184,9 +184,9 @@ public class EllipticCurve { * Returns a hash code value for this elliptic curve. * @return a hash code value computed from the hash codes of the field, A, * and B, as follows: - * + *
      {@code
            *     (field.hashCode() << 6) + (a.hashCode() << 4) + (b.hashCode() << 2)
      -     * 
      +     * }
      */ public int hashCode() { return (field.hashCode() << 6 + diff --git a/jdk/src/share/classes/java/sql/DatabaseMetaData.java b/jdk/src/share/classes/java/sql/DatabaseMetaData.java index 7330b8eac02..035365512b7 100644 --- a/jdk/src/share/classes/java/sql/DatabaseMetaData.java +++ b/jdk/src/share/classes/java/sql/DatabaseMetaData.java @@ -1218,21 +1218,21 @@ public interface DatabaseMetaData extends Wrapper { * *

      Each procedure description has the the following columns: *

        - *
      1. PROCEDURE_CAT String => procedure catalog (may be null) - *
      2. PROCEDURE_SCHEM String => procedure schema (may be null) - *
      3. PROCEDURE_NAME String => procedure name + *
      4. PROCEDURE_CAT String {@code =>} procedure catalog (may be null) + *
      5. PROCEDURE_SCHEM String {@code =>} procedure schema (may be null) + *
      6. PROCEDURE_NAME String {@code =>} procedure name *
      7. reserved for future use *
      8. reserved for future use *
      9. reserved for future use - *
      10. REMARKS String => explanatory comment on the procedure - *
      11. PROCEDURE_TYPE short => kind of procedure: + *
      12. REMARKS String {@code =>} explanatory comment on the procedure + *
      13. PROCEDURE_TYPE short {@code =>} kind of procedure: *
          *
        • procedureResultUnknown - Cannot determine if a return value * will be returned *
        • procedureNoResult - Does not return a return value *
        • procedureReturnsResult - Returns a return value *
        - *
      14. SPECIFIC_NAME String => The name which uniquely identifies this + *
      15. SPECIFIC_NAME String {@code =>} The name which uniquely identifies this * procedure within its schema. *
      *

      @@ -1297,11 +1297,11 @@ public interface DatabaseMetaData extends Wrapper { *

      Each row in the ResultSet is a parameter description or * column description with the following fields: *

        - *
      1. PROCEDURE_CAT String => procedure catalog (may be null) - *
      2. PROCEDURE_SCHEM String => procedure schema (may be null) - *
      3. PROCEDURE_NAME String => procedure name - *
      4. COLUMN_NAME String => column/parameter name - *
      5. COLUMN_TYPE Short => kind of column/parameter: + *
      6. PROCEDURE_CAT String {@code =>} procedure catalog (may be null) + *
      7. PROCEDURE_SCHEM String {@code =>} procedure schema (may be null) + *
      8. PROCEDURE_NAME String {@code =>} procedure name + *
      9. COLUMN_NAME String {@code =>} column/parameter name + *
      10. COLUMN_TYPE Short {@code =>} kind of column/parameter: *
          *
        • procedureColumnUnknown - nobody knows *
        • procedureColumnIn - IN parameter @@ -1310,44 +1310,44 @@ public interface DatabaseMetaData extends Wrapper { *
        • procedureColumnReturn - procedure return value *
        • procedureColumnResult - result column in ResultSet *
        - *
      11. DATA_TYPE int => SQL type from java.sql.Types - *
      12. TYPE_NAME String => SQL type name, for a UDT type the + *
      13. DATA_TYPE int {@code =>} SQL type from java.sql.Types + *
      14. TYPE_NAME String {@code =>} SQL type name, for a UDT type the * type name is fully qualified - *
      15. PRECISION int => precision - *
      16. LENGTH int => length in bytes of data - *
      17. SCALE short => scale - null is returned for data types where + *
      18. PRECISION int {@code =>} precision + *
      19. LENGTH int {@code =>} length in bytes of data + *
      20. SCALE short {@code =>} scale - null is returned for data types where * SCALE is not applicable. - *
      21. RADIX short => radix - *
      22. NULLABLE short => can it contain NULL. + *
      23. RADIX short {@code =>} radix + *
      24. NULLABLE short {@code =>} can it contain NULL. *
          *
        • procedureNoNulls - does not allow NULL values *
        • procedureNullable - allows NULL values *
        • procedureNullableUnknown - nullability unknown *
        - *
      25. REMARKS String => comment describing parameter/column - *
      26. COLUMN_DEF String => default value for the column, which should be interpreted as a string when the value is enclosed in single quotes (may be null) + *
      27. REMARKS String {@code =>} comment describing parameter/column + *
      28. COLUMN_DEF String {@code =>} default value for the column, which should be interpreted as a string when the value is enclosed in single quotes (may be null) *
          *
        • The string NULL (not enclosed in quotes) - if NULL was specified as the default value *
        • TRUNCATE (not enclosed in quotes) - if the specified default value cannot be represented without truncation *
        • NULL - if a default value was not specified *
        - *
      29. SQL_DATA_TYPE int => reserved for future use - *
      30. SQL_DATETIME_SUB int => reserved for future use - *
      31. CHAR_OCTET_LENGTH int => the maximum length of binary and character based columns. For any other datatype the returned value is a + *
      32. SQL_DATA_TYPE int {@code =>} reserved for future use + *
      33. SQL_DATETIME_SUB int {@code =>} reserved for future use + *
      34. CHAR_OCTET_LENGTH int {@code =>} the maximum length of binary and character based columns. For any other datatype the returned value is a * NULL - *
      35. ORDINAL_POSITION int => the ordinal position, starting from 1, for the input and output parameters for a procedure. A value of 0 + *
      36. ORDINAL_POSITION int {@code =>} the ordinal position, starting from 1, for the input and output parameters for a procedure. A value of 0 *is returned if this row describes the procedure's return value. For result set columns, it is the *ordinal position of the column in the result set starting from 1. If there are *multiple result sets, the column ordinal positions are implementation * defined. - *
      37. IS_NULLABLE String => ISO rules are used to determine the nullability for a column. + *
      38. IS_NULLABLE String {@code =>} ISO rules are used to determine the nullability for a column. *
          *
        • YES --- if the column can include NULLs *
        • NO --- if the column cannot include NULLs *
        • empty string --- if the nullability for the * column is unknown *
        - *
      39. SPECIFIC_NAME String => the name which uniquely identifies this procedure within its schema. + *
      40. SPECIFIC_NAME String {@code =>} the name which uniquely identifies this procedure within its schema. *
      * *

      Note: Some databases may not return the column @@ -1481,19 +1481,19 @@ public interface DatabaseMetaData extends Wrapper { *

      * Each table description has the following columns: *

        - *
      1. TABLE_CAT String => table catalog (may be null) - *
      2. TABLE_SCHEM String => table schema (may be null) - *
      3. TABLE_NAME String => table name - *
      4. TABLE_TYPE String => table type. Typical types are "TABLE", + *
      5. TABLE_CAT String {@code =>} table catalog (may be null) + *
      6. TABLE_SCHEM String {@code =>} table schema (may be null) + *
      7. TABLE_NAME String {@code =>} table name + *
      8. TABLE_TYPE String {@code =>} table type. Typical types are "TABLE", * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", * "LOCAL TEMPORARY", "ALIAS", "SYNONYM". - *
      9. REMARKS String => explanatory comment on the table - *
      10. TYPE_CAT String => the types catalog (may be null) - *
      11. TYPE_SCHEM String => the types schema (may be null) - *
      12. TYPE_NAME String => type name (may be null) - *
      13. SELF_REFERENCING_COL_NAME String => name of the designated + *
      14. REMARKS String {@code =>} explanatory comment on the table + *
      15. TYPE_CAT String {@code =>} the types catalog (may be null) + *
      16. TYPE_SCHEM String {@code =>} the types schema (may be null) + *
      17. TYPE_NAME String {@code =>} type name (may be null) + *
      18. SELF_REFERENCING_COL_NAME String {@code =>} name of the designated * "identifier" column of a typed table (may be null) - *
      19. REF_GENERATION String => specifies how values in + *
      20. REF_GENERATION String {@code =>} specifies how values in * SELF_REFERENCING_COL_NAME are created. Values are * "SYSTEM", "USER", "DERIVED". (may be null) *
      @@ -1528,8 +1528,8 @@ public interface DatabaseMetaData extends Wrapper { * *

      The schema columns are: *

        - *
      1. TABLE_SCHEM String => schema name - *
      2. TABLE_CATALOG String => catalog name (may be null) + *
      3. TABLE_SCHEM String {@code =>} schema name + *
      4. TABLE_CATALOG String {@code =>} catalog name (may be null) *
      * * @return a ResultSet object in which each row is a @@ -1545,7 +1545,7 @@ public interface DatabaseMetaData extends Wrapper { * *

      The catalog column is: *

        - *
      1. TABLE_CAT String => catalog name + *
      2. TABLE_CAT String {@code =>} catalog name *
      * * @return a ResultSet object in which each row has a @@ -1560,7 +1560,7 @@ public interface DatabaseMetaData extends Wrapper { * *

      The table type is: *

        - *
      1. TABLE_TYPE String => table type. Typical types are "TABLE", + *
      2. TABLE_TYPE String {@code =>} table type. Typical types are "TABLE", * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", * "LOCAL TEMPORARY", "ALIAS", "SYNONYM". *
      @@ -1582,55 +1582,55 @@ public interface DatabaseMetaData extends Wrapper { * *

      Each column description has the following columns: *

        - *
      1. TABLE_CAT String => table catalog (may be null) - *
      2. TABLE_SCHEM String => table schema (may be null) - *
      3. TABLE_NAME String => table name - *
      4. COLUMN_NAME String => column name - *
      5. DATA_TYPE int => SQL type from java.sql.Types - *
      6. TYPE_NAME String => Data source dependent type name, + *
      7. TABLE_CAT String {@code =>} table catalog (may be null) + *
      8. TABLE_SCHEM String {@code =>} table schema (may be null) + *
      9. TABLE_NAME String {@code =>} table name + *
      10. COLUMN_NAME String {@code =>} column name + *
      11. DATA_TYPE int {@code =>} SQL type from java.sql.Types + *
      12. TYPE_NAME String {@code =>} Data source dependent type name, * for a UDT the type name is fully qualified - *
      13. COLUMN_SIZE int => column size. + *
      14. COLUMN_SIZE int {@code =>} column size. *
      15. BUFFER_LENGTH is not used. - *
      16. DECIMAL_DIGITS int => the number of fractional digits. Null is returned for data types where + *
      17. DECIMAL_DIGITS int {@code =>} the number of fractional digits. Null is returned for data types where * DECIMAL_DIGITS is not applicable. - *
      18. NUM_PREC_RADIX int => Radix (typically either 10 or 2) - *
      19. NULLABLE int => is NULL allowed. + *
      20. NUM_PREC_RADIX int {@code =>} Radix (typically either 10 or 2) + *
      21. NULLABLE int {@code =>} is NULL allowed. *
          *
        • columnNoNulls - might not allow NULL values *
        • columnNullable - definitely allows NULL values *
        • columnNullableUnknown - nullability unknown *
        - *
      22. REMARKS String => comment describing column (may be null) - *
      23. COLUMN_DEF String => default value for the column, which should be interpreted as a string when the value is enclosed in single quotes (may be null) - *
      24. SQL_DATA_TYPE int => unused - *
      25. SQL_DATETIME_SUB int => unused - *
      26. CHAR_OCTET_LENGTH int => for char types the + *
      27. REMARKS String {@code =>} comment describing column (may be null) + *
      28. COLUMN_DEF String {@code =>} default value for the column, which should be interpreted as a string when the value is enclosed in single quotes (may be null) + *
      29. SQL_DATA_TYPE int {@code =>} unused + *
      30. SQL_DATETIME_SUB int {@code =>} unused + *
      31. CHAR_OCTET_LENGTH int {@code =>} for char types the * maximum number of bytes in the column - *
      32. ORDINAL_POSITION int => index of column in table + *
      33. ORDINAL_POSITION int {@code =>} index of column in table * (starting at 1) - *
      34. IS_NULLABLE String => ISO rules are used to determine the nullability for a column. + *
      35. IS_NULLABLE String {@code =>} ISO rules are used to determine the nullability for a column. *
          *
        • YES --- if the column can include NULLs *
        • NO --- if the column cannot include NULLs *
        • empty string --- if the nullability for the * column is unknown *
        - *
      36. SCOPE_CATALOG String => catalog of table that is the scope + *
      37. SCOPE_CATALOG String {@code =>} catalog of table that is the scope * of a reference attribute (null if DATA_TYPE isn't REF) - *
      38. SCOPE_SCHEMA String => schema of table that is the scope + *
      39. SCOPE_SCHEMA String {@code =>} schema of table that is the scope * of a reference attribute (null if the DATA_TYPE isn't REF) - *
      40. SCOPE_TABLE String => table name that this the scope + *
      41. SCOPE_TABLE String {@code =>} table name that this the scope * of a reference attribute (null if the DATA_TYPE isn't REF) - *
      42. SOURCE_DATA_TYPE short => source type of a distinct type or user-generated + *
      43. SOURCE_DATA_TYPE short {@code =>} source type of a distinct type or user-generated * Ref type, SQL type from java.sql.Types (null if DATA_TYPE * isn't DISTINCT or user-generated REF) - *
      44. IS_AUTOINCREMENT String => Indicates whether this column is auto incremented + *
      45. IS_AUTOINCREMENT String {@code =>} Indicates whether this column is auto incremented *
          *
        • YES --- if the column is auto incremented *
        • NO --- if the column is not auto incremented *
        • empty string --- if it cannot be determined whether the column is auto incremented *
        - *
      46. IS_GENERATEDCOLUMN String => Indicates whether this is a generated column + *
      47. IS_GENERATEDCOLUMN String {@code =>} Indicates whether this is a generated column *
          *
        • YES --- if this a generated column *
        • NO --- if this not a generated column @@ -1703,15 +1703,15 @@ public interface DatabaseMetaData extends Wrapper { * *

          Each privilige description has the following columns: *

            - *
          1. TABLE_CAT String => table catalog (may be null) - *
          2. TABLE_SCHEM String => table schema (may be null) - *
          3. TABLE_NAME String => table name - *
          4. COLUMN_NAME String => column name - *
          5. GRANTOR String => grantor of access (may be null) - *
          6. GRANTEE String => grantee of access - *
          7. PRIVILEGE String => name of access (SELECT, + *
          8. TABLE_CAT String {@code =>} table catalog (may be null) + *
          9. TABLE_SCHEM String {@code =>} table schema (may be null) + *
          10. TABLE_NAME String {@code =>} table name + *
          11. COLUMN_NAME String {@code =>} column name + *
          12. GRANTOR String {@code =>} grantor of access (may be null) + *
          13. GRANTEE String {@code =>} grantee of access + *
          14. PRIVILEGE String {@code =>} name of access (SELECT, * INSERT, UPDATE, REFRENCES, ...) - *
          15. IS_GRANTABLE String => "YES" if grantee is permitted + *
          16. IS_GRANTABLE String {@code =>} "YES" if grantee is permitted * to grant to others; "NO" if not; null if unknown *
          * @@ -1749,14 +1749,14 @@ public interface DatabaseMetaData extends Wrapper { * *

          Each privilige description has the following columns: *

            - *
          1. TABLE_CAT String => table catalog (may be null) - *
          2. TABLE_SCHEM String => table schema (may be null) - *
          3. TABLE_NAME String => table name - *
          4. GRANTOR String => grantor of access (may be null) - *
          5. GRANTEE String => grantee of access - *
          6. PRIVILEGE String => name of access (SELECT, + *
          7. TABLE_CAT String {@code =>} table catalog (may be null) + *
          8. TABLE_SCHEM String {@code =>} table schema (may be null) + *
          9. TABLE_NAME String {@code =>} table name + *
          10. GRANTOR String {@code =>} grantor of access (may be null) + *
          11. GRANTEE String {@code =>} grantee of access + *
          12. PRIVILEGE String {@code =>} name of access (SELECT, * INSERT, UPDATE, REFRENCES, ...) - *
          13. IS_GRANTABLE String => "YES" if grantee is permitted + *
          14. IS_GRANTABLE String {@code =>} "YES" if grantee is permitted * to grant to others; "NO" if not; null if unknown *
          * @@ -1783,21 +1783,21 @@ public interface DatabaseMetaData extends Wrapper { * *

          Each column description has the following columns: *

            - *
          1. SCOPE short => actual scope of result + *
          2. SCOPE short {@code =>} actual scope of result *
              *
            • bestRowTemporary - very temporary, while using row *
            • bestRowTransaction - valid for remainder of current transaction *
            • bestRowSession - valid for remainder of current session *
            - *
          3. COLUMN_NAME String => column name - *
          4. DATA_TYPE int => SQL data type from java.sql.Types - *
          5. TYPE_NAME String => Data source dependent type name, + *
          6. COLUMN_NAME String {@code =>} column name + *
          7. DATA_TYPE int {@code =>} SQL data type from java.sql.Types + *
          8. TYPE_NAME String {@code =>} Data source dependent type name, * for a UDT the type name is fully qualified - *
          9. COLUMN_SIZE int => precision - *
          10. BUFFER_LENGTH int => not used - *
          11. DECIMAL_DIGITS short => scale - Null is returned for data types where + *
          12. COLUMN_SIZE int {@code =>} precision + *
          13. BUFFER_LENGTH int {@code =>} not used + *
          14. DECIMAL_DIGITS short {@code =>} scale - Null is returned for data types where * DECIMAL_DIGITS is not applicable. - *
          15. PSEUDO_COLUMN short => is this a pseudo column + *
          16. PSEUDO_COLUMN short {@code =>} is this a pseudo column * like an Oracle ROWID *
              *
            • bestRowUnknown - may or may not be pseudo column @@ -1902,15 +1902,15 @@ public interface DatabaseMetaData extends Wrapper { * *

              Each column description has the following columns: *

                - *
              1. SCOPE short => is not used - *
              2. COLUMN_NAME String => column name - *
              3. DATA_TYPE int => SQL data type from java.sql.Types - *
              4. TYPE_NAME String => Data source-dependent type name - *
              5. COLUMN_SIZE int => precision - *
              6. BUFFER_LENGTH int => length of column value in bytes - *
              7. DECIMAL_DIGITS short => scale - Null is returned for data types where + *
              8. SCOPE short {@code =>} is not used + *
              9. COLUMN_NAME String {@code =>} column name + *
              10. DATA_TYPE int {@code =>} SQL data type from java.sql.Types + *
              11. TYPE_NAME String {@code =>} Data source-dependent type name + *
              12. COLUMN_SIZE int {@code =>} precision + *
              13. BUFFER_LENGTH int {@code =>} length of column value in bytes + *
              14. DECIMAL_DIGITS short {@code =>} scale - Null is returned for data types where * DECIMAL_DIGITS is not applicable. - *
              15. PSEUDO_COLUMN short => whether this is pseudo column + *
              16. PSEUDO_COLUMN short {@code =>} whether this is pseudo column * like an Oracle ROWID *
                  *
                • versionColumnUnknown - may or may not be pseudo column @@ -1978,14 +1978,14 @@ public interface DatabaseMetaData extends Wrapper { * *

                  Each primary key column description has the following columns: *

                    - *
                  1. TABLE_CAT String => table catalog (may be null) - *
                  2. TABLE_SCHEM String => table schema (may be null) - *
                  3. TABLE_NAME String => table name - *
                  4. COLUMN_NAME String => column name - *
                  5. KEY_SEQ short => sequence number within primary key( a value + *
                  6. TABLE_CAT String {@code =>} table catalog (may be null) + *
                  7. TABLE_SCHEM String {@code =>} table schema (may be null) + *
                  8. TABLE_NAME String {@code =>} table name + *
                  9. COLUMN_NAME String {@code =>} column name + *
                  10. KEY_SEQ short {@code =>} sequence number within primary key( a value * of 1 represents the first column of the primary key, a value of 2 would * represent the second column within the primary key). - *
                  11. PK_NAME String => primary key name (may be null) + *
                  12. PK_NAME String {@code =>} primary key name (may be null) *
                  * * @param catalog a catalog name; must match the catalog name as it @@ -2012,22 +2012,22 @@ public interface DatabaseMetaData extends Wrapper { * *

                  Each primary key column description has the following columns: *

                    - *
                  1. PKTABLE_CAT String => primary key table catalog + *
                  2. PKTABLE_CAT String {@code =>} primary key table catalog * being imported (may be null) - *
                  3. PKTABLE_SCHEM String => primary key table schema + *
                  4. PKTABLE_SCHEM String {@code =>} primary key table schema * being imported (may be null) - *
                  5. PKTABLE_NAME String => primary key table name + *
                  6. PKTABLE_NAME String {@code =>} primary key table name * being imported - *
                  7. PKCOLUMN_NAME String => primary key column name + *
                  8. PKCOLUMN_NAME String {@code =>} primary key column name * being imported - *
                  9. FKTABLE_CAT String => foreign key table catalog (may be null) - *
                  10. FKTABLE_SCHEM String => foreign key table schema (may be null) - *
                  11. FKTABLE_NAME String => foreign key table name - *
                  12. FKCOLUMN_NAME String => foreign key column name - *
                  13. KEY_SEQ short => sequence number within a foreign key( a value + *
                  14. FKTABLE_CAT String {@code =>} foreign key table catalog (may be null) + *
                  15. FKTABLE_SCHEM String {@code =>} foreign key table schema (may be null) + *
                  16. FKTABLE_NAME String {@code =>} foreign key table name + *
                  17. FKCOLUMN_NAME String {@code =>} foreign key column name + *
                  18. KEY_SEQ short {@code =>} sequence number within a foreign key( a value * of 1 represents the first column of the foreign key, a value of 2 would * represent the second column within the foreign key). - *
                  19. UPDATE_RULE short => What happens to a + *
                  20. UPDATE_RULE short {@code =>} What happens to a * foreign key when the primary key is updated: *
                      *
                    • importedNoAction - do not allow update of primary @@ -2041,7 +2041,7 @@ public interface DatabaseMetaData extends Wrapper { *
                    • importedKeyRestrict - same as importedKeyNoAction * (for ODBC 2.x compatibility) *
                    - *
                  21. DELETE_RULE short => What happens to + *
                  22. DELETE_RULE short {@code =>} What happens to * the foreign key when primary is deleted. *
                      *
                    • importedKeyNoAction - do not allow delete of primary @@ -2054,9 +2054,9 @@ public interface DatabaseMetaData extends Wrapper { *
                    • importedKeySetDefault - change imported key to default if * its primary key has been deleted *
                    - *
                  23. FK_NAME String => foreign key name (may be null) - *
                  24. PK_NAME String => primary key name (may be null) - *
                  25. DEFERRABILITY short => can the evaluation of foreign key + *
                  26. FK_NAME String {@code =>} foreign key name (may be null) + *
                  27. PK_NAME String {@code =>} primary key name (may be null) + *
                  28. DEFERRABILITY short {@code =>} can the evaluation of foreign key * constraints be deferred until commit *
                      *
                    • importedKeyInitiallyDeferred - see SQL92 for definition @@ -2195,22 +2195,22 @@ public interface DatabaseMetaData extends Wrapper { * *

                      Each foreign key column description has the following columns: *

                        - *
                      1. PKTABLE_CAT String => primary key table catalog (may be null) - *
                      2. PKTABLE_SCHEM String => primary key table schema (may be null) - *
                      3. PKTABLE_NAME String => primary key table name - *
                      4. PKCOLUMN_NAME String => primary key column name - *
                      5. FKTABLE_CAT String => foreign key table catalog (may be null) + *
                      6. PKTABLE_CAT String {@code =>} primary key table catalog (may be null) + *
                      7. PKTABLE_SCHEM String {@code =>} primary key table schema (may be null) + *
                      8. PKTABLE_NAME String {@code =>} primary key table name + *
                      9. PKCOLUMN_NAME String {@code =>} primary key column name + *
                      10. FKTABLE_CAT String {@code =>} foreign key table catalog (may be null) * being exported (may be null) - *
                      11. FKTABLE_SCHEM String => foreign key table schema (may be null) + *
                      12. FKTABLE_SCHEM String {@code =>} foreign key table schema (may be null) * being exported (may be null) - *
                      13. FKTABLE_NAME String => foreign key table name + *
                      14. FKTABLE_NAME String {@code =>} foreign key table name * being exported - *
                      15. FKCOLUMN_NAME String => foreign key column name + *
                      16. FKCOLUMN_NAME String {@code =>} foreign key column name * being exported - *
                      17. KEY_SEQ short => sequence number within foreign key( a value + *
                      18. KEY_SEQ short {@code =>} sequence number within foreign key( a value * of 1 represents the first column of the foreign key, a value of 2 would * represent the second column within the foreign key). - *
                      19. UPDATE_RULE short => What happens to + *
                      20. UPDATE_RULE short {@code =>} What happens to * foreign key when primary is updated: *
                          *
                        • importedNoAction - do not allow update of primary @@ -2224,7 +2224,7 @@ public interface DatabaseMetaData extends Wrapper { *
                        • importedKeyRestrict - same as importedKeyNoAction * (for ODBC 2.x compatibility) *
                        - *
                      21. DELETE_RULE short => What happens to + *
                      22. DELETE_RULE short {@code =>} What happens to * the foreign key when primary is deleted. *
                          *
                        • importedKeyNoAction - do not allow delete of primary @@ -2237,9 +2237,9 @@ public interface DatabaseMetaData extends Wrapper { *
                        • importedKeySetDefault - change imported key to default if * its primary key has been deleted *
                        - *
                      23. FK_NAME String => foreign key name (may be null) - *
                      24. PK_NAME String => primary key name (may be null) - *
                      25. DEFERRABILITY short => can the evaluation of foreign key + *
                      26. FK_NAME String {@code =>} foreign key name (may be null) + *
                      27. PK_NAME String {@code =>} primary key name (may be null) + *
                      28. DEFERRABILITY short {@code =>} can the evaluation of foreign key * constraints be deferred until commit *
                          *
                        • importedKeyInitiallyDeferred - see SQL92 for definition @@ -2276,22 +2276,22 @@ public interface DatabaseMetaData extends Wrapper { * *

                          Each foreign key column description has the following columns: *

                            - *
                          1. PKTABLE_CAT String => parent key table catalog (may be null) - *
                          2. PKTABLE_SCHEM String => parent key table schema (may be null) - *
                          3. PKTABLE_NAME String => parent key table name - *
                          4. PKCOLUMN_NAME String => parent key column name - *
                          5. FKTABLE_CAT String => foreign key table catalog (may be null) + *
                          6. PKTABLE_CAT String {@code =>} parent key table catalog (may be null) + *
                          7. PKTABLE_SCHEM String {@code =>} parent key table schema (may be null) + *
                          8. PKTABLE_NAME String {@code =>} parent key table name + *
                          9. PKCOLUMN_NAME String {@code =>} parent key column name + *
                          10. FKTABLE_CAT String {@code =>} foreign key table catalog (may be null) * being exported (may be null) - *
                          11. FKTABLE_SCHEM String => foreign key table schema (may be null) + *
                          12. FKTABLE_SCHEM String {@code =>} foreign key table schema (may be null) * being exported (may be null) - *
                          13. FKTABLE_NAME String => foreign key table name + *
                          14. FKTABLE_NAME String {@code =>} foreign key table name * being exported - *
                          15. FKCOLUMN_NAME String => foreign key column name + *
                          16. FKCOLUMN_NAME String {@code =>} foreign key column name * being exported - *
                          17. KEY_SEQ short => sequence number within foreign key( a value + *
                          18. KEY_SEQ short {@code =>} sequence number within foreign key( a value * of 1 represents the first column of the foreign key, a value of 2 would * represent the second column within the foreign key). - *
                          19. UPDATE_RULE short => What happens to + *
                          20. UPDATE_RULE short {@code =>} What happens to * foreign key when parent key is updated: *
                              *
                            • importedNoAction - do not allow update of parent @@ -2305,7 +2305,7 @@ public interface DatabaseMetaData extends Wrapper { *
                            • importedKeyRestrict - same as importedKeyNoAction * (for ODBC 2.x compatibility) *
                            - *
                          21. DELETE_RULE short => What happens to + *
                          22. DELETE_RULE short {@code =>} What happens to * the foreign key when parent key is deleted. *
                              *
                            • importedKeyNoAction - do not allow delete of parent @@ -2318,9 +2318,9 @@ public interface DatabaseMetaData extends Wrapper { *
                            • importedKeySetDefault - change imported key to default if * its parent key has been deleted *
                            - *
                          23. FK_NAME String => foreign key name (may be null) - *
                          24. PK_NAME String => parent key name (may be null) - *
                          25. DEFERRABILITY short => can the evaluation of foreign key + *
                          26. FK_NAME String {@code =>} foreign key name (may be null) + *
                          27. PK_NAME String {@code =>} parent key name (may be null) + *
                          28. DEFERRABILITY short {@code =>} can the evaluation of foreign key * constraints be deferred until commit *
                              *
                            • importedKeyInitiallyDeferred - see SQL92 for definition @@ -2371,40 +2371,40 @@ public interface DatabaseMetaData extends Wrapper { * *

                              Each type description has the following columns: *

                                - *
                              1. TYPE_NAME String => Type name - *
                              2. DATA_TYPE int => SQL data type from java.sql.Types - *
                              3. PRECISION int => maximum precision - *
                              4. LITERAL_PREFIX String => prefix used to quote a literal + *
                              5. TYPE_NAME String {@code =>} Type name + *
                              6. DATA_TYPE int {@code =>} SQL data type from java.sql.Types + *
                              7. PRECISION int {@code =>} maximum precision + *
                              8. LITERAL_PREFIX String {@code =>} prefix used to quote a literal * (may be null) - *
                              9. LITERAL_SUFFIX String => suffix used to quote a literal + *
                              10. LITERAL_SUFFIX String {@code =>} suffix used to quote a literal (may be null) - *
                              11. CREATE_PARAMS String => parameters used in creating + *
                              12. CREATE_PARAMS String {@code =>} parameters used in creating * the type (may be null) - *
                              13. NULLABLE short => can you use NULL for this type. + *
                              14. NULLABLE short {@code =>} can you use NULL for this type. *
                                  *
                                • typeNoNulls - does not allow NULL values *
                                • typeNullable - allows NULL values *
                                • typeNullableUnknown - nullability unknown *
                                - *
                              15. CASE_SENSITIVE boolean=> is it case sensitive. - *
                              16. SEARCHABLE short => can you use "WHERE" based on this type: + *
                              17. CASE_SENSITIVE boolean{@code =>} is it case sensitive. + *
                              18. SEARCHABLE short {@code =>} can you use "WHERE" based on this type: *
                                  *
                                • typePredNone - No support *
                                • typePredChar - Only supported with WHERE .. LIKE *
                                • typePredBasic - Supported except for WHERE .. LIKE *
                                • typeSearchable - Supported for all WHERE .. *
                                - *
                              19. UNSIGNED_ATTRIBUTE boolean => is it unsigned. - *
                              20. FIXED_PREC_SCALE boolean => can it be a money value. - *
                              21. AUTO_INCREMENT boolean => can it be used for an + *
                              22. UNSIGNED_ATTRIBUTE boolean {@code =>} is it unsigned. + *
                              23. FIXED_PREC_SCALE boolean {@code =>} can it be a money value. + *
                              24. AUTO_INCREMENT boolean {@code =>} can it be used for an * auto-increment value. - *
                              25. LOCAL_TYPE_NAME String => localized version of type name + *
                              26. LOCAL_TYPE_NAME String {@code =>} localized version of type name * (may be null) - *
                              27. MINIMUM_SCALE short => minimum scale supported - *
                              28. MAXIMUM_SCALE short => maximum scale supported - *
                              29. SQL_DATA_TYPE int => unused - *
                              30. SQL_DATETIME_SUB int => unused - *
                              31. NUM_PREC_RADIX int => usually 2 or 10 + *
                              32. MINIMUM_SCALE short {@code =>} minimum scale supported + *
                              33. MAXIMUM_SCALE short {@code =>} maximum scale supported + *
                              34. SQL_DATA_TYPE int {@code =>} unused + *
                              35. SQL_DATETIME_SUB int {@code =>} unused + *
                              36. NUM_PREC_RADIX int {@code =>} usually 2 or 10 *
                              * *

                              The PRECISION column represents the maximum column size that the server supports for the given datatype. @@ -2498,16 +2498,16 @@ public interface DatabaseMetaData extends Wrapper { * *

                              Each index column description has the following columns: *

                                - *
                              1. TABLE_CAT String => table catalog (may be null) - *
                              2. TABLE_SCHEM String => table schema (may be null) - *
                              3. TABLE_NAME String => table name - *
                              4. NON_UNIQUE boolean => Can index values be non-unique. + *
                              5. TABLE_CAT String {@code =>} table catalog (may be null) + *
                              6. TABLE_SCHEM String {@code =>} table schema (may be null) + *
                              7. TABLE_NAME String {@code =>} table name + *
                              8. NON_UNIQUE boolean {@code =>} Can index values be non-unique. * false when TYPE is tableIndexStatistic - *
                              9. INDEX_QUALIFIER String => index catalog (may be null); + *
                              10. INDEX_QUALIFIER String {@code =>} index catalog (may be null); * null when TYPE is tableIndexStatistic - *
                              11. INDEX_NAME String => index name; null when TYPE is + *
                              12. INDEX_NAME String {@code =>} index name; null when TYPE is * tableIndexStatistic - *
                              13. TYPE short => index type: + *
                              14. TYPE short {@code =>} index type: *
                                  *
                                • tableIndexStatistic - this identifies table statistics that are * returned in conjuction with a table's index descriptions @@ -2515,20 +2515,20 @@ public interface DatabaseMetaData extends Wrapper { *
                                • tableIndexHashed - this is a hashed index *
                                • tableIndexOther - this is some other style of index *
                                - *
                              15. ORDINAL_POSITION short => column sequence number + *
                              16. ORDINAL_POSITION short {@code =>} column sequence number * within index; zero when TYPE is tableIndexStatistic - *
                              17. COLUMN_NAME String => column name; null when TYPE is + *
                              18. COLUMN_NAME String {@code =>} column name; null when TYPE is * tableIndexStatistic - *
                              19. ASC_OR_DESC String => column sort sequence, "A" => ascending, - * "D" => descending, may be null if sort sequence is not supported; + *
                              20. ASC_OR_DESC String {@code =>} column sort sequence, "A" {@code =>} ascending, + * "D" {@code =>} descending, may be null if sort sequence is not supported; * null when TYPE is tableIndexStatistic - *
                              21. CARDINALITY long => When TYPE is tableIndexStatistic, then + *
                              22. CARDINALITY long {@code =>} When TYPE is tableIndexStatistic, then * this is the number of rows in the table; otherwise, it is the * number of unique values in the index. - *
                              23. PAGES long => When TYPE is tableIndexStatisic then + *
                              24. PAGES long {@code =>} When TYPE is tableIndexStatisic then * this is the number of pages used for the table, otherwise it * is the number of pages used for the current index. - *
                              25. FILTER_CONDITION String => Filter condition, if any. + *
                              26. FILTER_CONDITION String {@code =>} Filter condition, if any. * (may be null) *
                              * @@ -2781,14 +2781,14 @@ public interface DatabaseMetaData extends Wrapper { * *

                              Each type description has the following columns: *

                                - *
                              1. TYPE_CAT String => the type's catalog (may be null) - *
                              2. TYPE_SCHEM String => type's schema (may be null) - *
                              3. TYPE_NAME String => type name - *
                              4. CLASS_NAME String => Java class name - *
                              5. DATA_TYPE int => type value defined in java.sql.Types. + *
                              6. TYPE_CAT String {@code =>} the type's catalog (may be null) + *
                              7. TYPE_SCHEM String {@code =>} type's schema (may be null) + *
                              8. TYPE_NAME String {@code =>} type name + *
                              9. CLASS_NAME String {@code =>} Java class name + *
                              10. DATA_TYPE int {@code =>} type value defined in java.sql.Types. * One of JAVA_OBJECT, STRUCT, or DISTINCT - *
                              11. REMARKS String => explanatory comment on the type - *
                              12. BASE_TYPE short => type code of the source type of a + *
                              13. REMARKS String {@code =>} explanatory comment on the type + *
                              14. BASE_TYPE short {@code =>} type code of the source type of a * DISTINCT type or the type that implements the user-generated * reference type of the SELF_REFERENCING_COLUMN of a structured * type as defined in java.sql.Types (null if DATA_TYPE is not @@ -2894,14 +2894,14 @@ public interface DatabaseMetaData extends Wrapper { * describes the designated UDT and a direct supertype. A row has the following * columns: *
                                  - *
                                1. TYPE_CAT String => the UDT's catalog (may be null) - *
                                2. TYPE_SCHEM String => UDT's schema (may be null) - *
                                3. TYPE_NAME String => type name of the UDT - *
                                4. SUPERTYPE_CAT String => the direct super type's catalog + *
                                5. TYPE_CAT String {@code =>} the UDT's catalog (may be null) + *
                                6. TYPE_SCHEM String {@code =>} UDT's schema (may be null) + *
                                7. TYPE_NAME String {@code =>} type name of the UDT + *
                                8. SUPERTYPE_CAT String {@code =>} the direct super type's catalog * (may be null) - *
                                9. SUPERTYPE_SCHEM String => the direct super type's schema + *
                                10. SUPERTYPE_SCHEM String {@code =>} the direct super type's schema * (may be null) - *
                                11. SUPERTYPE_NAME String => the direct super type's name + *
                                12. SUPERTYPE_NAME String {@code =>} the direct super type's name *
                                * *

                                Note: If the driver does not support type hierarchies, an @@ -2936,10 +2936,10 @@ public interface DatabaseMetaData extends Wrapper { * *

                                Each type description has the following columns: *

                                  - *
                                1. TABLE_CAT String => the type's catalog (may be null) - *
                                2. TABLE_SCHEM String => type's schema (may be null) - *
                                3. TABLE_NAME String => type name - *
                                4. SUPERTABLE_NAME String => the direct super type's name + *
                                5. TABLE_CAT String {@code =>} the type's catalog (may be null) + *
                                6. TABLE_SCHEM String {@code =>} type's schema (may be null) + *
                                7. TABLE_NAME String {@code =>} type name + *
                                8. SUPERTABLE_NAME String {@code =>} the direct super type's name *
                                * *

                                Note: If the driver does not support type hierarchies, an @@ -3001,35 +3001,35 @@ public interface DatabaseMetaData extends Wrapper { * The ResultSet object that is returned has the following * columns: *

                                  - *
                                1. TYPE_CAT String => type catalog (may be null) - *
                                2. TYPE_SCHEM String => type schema (may be null) - *
                                3. TYPE_NAME String => type name - *
                                4. ATTR_NAME String => attribute name - *
                                5. DATA_TYPE int => attribute type SQL type from java.sql.Types - *
                                6. ATTR_TYPE_NAME String => Data source dependent type name. + *
                                7. TYPE_CAT String {@code =>} type catalog (may be null) + *
                                8. TYPE_SCHEM String {@code =>} type schema (may be null) + *
                                9. TYPE_NAME String {@code =>} type name + *
                                10. ATTR_NAME String {@code =>} attribute name + *
                                11. DATA_TYPE int {@code =>} attribute type SQL type from java.sql.Types + *
                                12. ATTR_TYPE_NAME String {@code =>} Data source dependent type name. * For a UDT, the type name is fully qualified. For a REF, the type name is * fully qualified and represents the target type of the reference type. - *
                                13. ATTR_SIZE int => column size. For char or date + *
                                14. ATTR_SIZE int {@code =>} column size. For char or date * types this is the maximum number of characters; for numeric or * decimal types this is precision. - *
                                15. DECIMAL_DIGITS int => the number of fractional digits. Null is returned for data types where + *
                                16. DECIMAL_DIGITS int {@code =>} the number of fractional digits. Null is returned for data types where * DECIMAL_DIGITS is not applicable. - *
                                17. NUM_PREC_RADIX int => Radix (typically either 10 or 2) - *
                                18. NULLABLE int => whether NULL is allowed + *
                                19. NUM_PREC_RADIX int {@code =>} Radix (typically either 10 or 2) + *
                                20. NULLABLE int {@code =>} whether NULL is allowed *
                                    *
                                  • attributeNoNulls - might not allow NULL values *
                                  • attributeNullable - definitely allows NULL values *
                                  • attributeNullableUnknown - nullability unknown *
                                  - *
                                21. REMARKS String => comment describing column (may be null) - *
                                22. ATTR_DEF String => default value (may be null) - *
                                23. SQL_DATA_TYPE int => unused - *
                                24. SQL_DATETIME_SUB int => unused - *
                                25. CHAR_OCTET_LENGTH int => for char types the + *
                                26. REMARKS String {@code =>} comment describing column (may be null) + *
                                27. ATTR_DEF String {@code =>} default value (may be null) + *
                                28. SQL_DATA_TYPE int {@code =>} unused + *
                                29. SQL_DATETIME_SUB int {@code =>} unused + *
                                30. CHAR_OCTET_LENGTH int {@code =>} for char types the * maximum number of bytes in the column - *
                                31. ORDINAL_POSITION int => index of the attribute in the UDT + *
                                32. ORDINAL_POSITION int {@code =>} index of the attribute in the UDT * (starting at 1) - *
                                33. IS_NULLABLE String => ISO rules are used to determine + *
                                34. IS_NULLABLE String {@code =>} ISO rules are used to determine * the nullability for a attribute. *
                                    *
                                  • YES --- if the attribute can include NULLs @@ -3037,13 +3037,13 @@ public interface DatabaseMetaData extends Wrapper { *
                                  • empty string --- if the nullability for the * attribute is unknown *
                                  - *
                                35. SCOPE_CATALOG String => catalog of table that is the + *
                                36. SCOPE_CATALOG String {@code =>} catalog of table that is the * scope of a reference attribute (null if DATA_TYPE isn't REF) - *
                                37. SCOPE_SCHEMA String => schema of table that is the + *
                                38. SCOPE_SCHEMA String {@code =>} schema of table that is the * scope of a reference attribute (null if DATA_TYPE isn't REF) - *
                                39. SCOPE_TABLE String => table name that is the scope of a + *
                                40. SCOPE_TABLE String {@code =>} table name that is the scope of a * reference attribute (null if the DATA_TYPE isn't REF) - *
                                41. SOURCE_DATA_TYPE short => source type of a distinct type or user-generated + *
                                42. SOURCE_DATA_TYPE short {@code =>} source type of a distinct type or user-generated * Ref type,SQL type from java.sql.Types (null if DATA_TYPE * isn't DISTINCT or user-generated REF) *
                                @@ -3203,14 +3203,14 @@ public interface DatabaseMetaData extends Wrapper { * and if so the lifetime for which a RowId object remains valid. *

                                * The returned int values have the following relationship: - *

                                +     * 
                                {@code
                                      *     ROWID_UNSUPPORTED < ROWID_VALID_OTHER < ROWID_VALID_TRANSACTION
                                      *         < ROWID_VALID_SESSION < ROWID_VALID_FOREVER
                                -     * 
                                + * }
                                * so conditional logic such as - *
                                +     * 
                                {@code
                                      *     if (metadata.getRowIdLifetime() > DatabaseMetaData.ROWID_VALID_TRANSACTION)
                                -     * 
                                + * }
                                * can be used. Valid Forever means valid across all Sessions, and valid for * a Session means valid across all its contained Transactions. * @@ -3227,8 +3227,8 @@ public interface DatabaseMetaData extends Wrapper { * *

                                The schema columns are: *

                                  - *
                                1. TABLE_SCHEM String => schema name - *
                                2. TABLE_CATALOG String => catalog name (may be null) + *
                                3. TABLE_SCHEM String {@code =>} schema name + *
                                4. TABLE_CATALOG String {@code =>} catalog name (may be null) *
                                * * @@ -3273,10 +3273,10 @@ public interface DatabaseMetaData extends Wrapper { * that the driver supports. The result set contains the following columns *

                                *

                                  - *
                                1. NAME String=> The name of the client info property
                                  - *
                                2. MAX_LEN int=> The maximum length of the value for the property
                                  - *
                                3. DEFAULT_VALUE String=> The default value of the property
                                  - *
                                4. DESCRIPTION String=> A description of the property. This will typically + *
                                5. NAME String{@code =>} The name of the client info property
                                  + *
                                6. MAX_LEN int{@code =>} The maximum length of the value for the property
                                  + *
                                7. DEFAULT_VALUE String{@code =>} The default value of the property
                                  + *
                                8. DESCRIPTION String{@code =>} A description of the property. This will typically * contain information as to where this property is * stored in the database. *
                                @@ -3305,19 +3305,19 @@ public interface DatabaseMetaData extends Wrapper { * *

                                Each function description has the the following columns: *

                                  - *
                                1. FUNCTION_CAT String => function catalog (may be null) - *
                                2. FUNCTION_SCHEM String => function schema (may be null) - *
                                3. FUNCTION_NAME String => function name. This is the name + *
                                4. FUNCTION_CAT String {@code =>} function catalog (may be null) + *
                                5. FUNCTION_SCHEM String {@code =>} function schema (may be null) + *
                                6. FUNCTION_NAME String {@code =>} function name. This is the name * used to invoke the function - *
                                7. REMARKS String => explanatory comment on the function - *
                                8. FUNCTION_TYPE short => kind of function: + *
                                9. REMARKS String {@code =>} explanatory comment on the function + *
                                10. FUNCTION_TYPE short {@code =>} kind of function: *
                                    *
                                  • functionResultUnknown - Cannot determine if a return value * or table will be returned *
                                  • functionNoTable- Does not return a table *
                                  • functionReturnsTable - Returns a table *
                                  - *
                                11. SPECIFIC_NAME String => the name which uniquely identifies + *
                                12. SPECIFIC_NAME String {@code =>} the name which uniquely identifies * this function within its schema. This is a user specified, or DBMS * generated, name that may be different then the FUNCTION_NAME * for example with overload functions @@ -3359,12 +3359,12 @@ public interface DatabaseMetaData extends Wrapper { * is a parameter description, column description or * return type description with the following fields: *
                                    - *
                                  1. FUNCTION_CAT String => function catalog (may be null) - *
                                  2. FUNCTION_SCHEM String => function schema (may be null) - *
                                  3. FUNCTION_NAME String => function name. This is the name + *
                                  4. FUNCTION_CAT String {@code =>} function catalog (may be null) + *
                                  5. FUNCTION_SCHEM String {@code =>} function schema (may be null) + *
                                  6. FUNCTION_NAME String {@code =>} function name. This is the name * used to invoke the function - *
                                  7. COLUMN_NAME String => column/parameter name - *
                                  8. COLUMN_TYPE Short => kind of column/parameter: + *
                                  9. COLUMN_NAME String {@code =>} column/parameter name + *
                                  10. COLUMN_TYPE Short {@code =>} kind of column/parameter: *
                                      *
                                    • functionColumnUnknown - nobody knows *
                                    • functionColumnIn - IN parameter @@ -3374,30 +3374,30 @@ public interface DatabaseMetaData extends Wrapper { *
                                    • functionColumnResult - Indicates that the parameter or column * is a column in the ResultSet *
                                    - *
                                  11. DATA_TYPE int => SQL type from java.sql.Types - *
                                  12. TYPE_NAME String => SQL type name, for a UDT type the + *
                                  13. DATA_TYPE int {@code =>} SQL type from java.sql.Types + *
                                  14. TYPE_NAME String {@code =>} SQL type name, for a UDT type the * type name is fully qualified - *
                                  15. PRECISION int => precision - *
                                  16. LENGTH int => length in bytes of data - *
                                  17. SCALE short => scale - null is returned for data types where + *
                                  18. PRECISION int {@code =>} precision + *
                                  19. LENGTH int {@code =>} length in bytes of data + *
                                  20. SCALE short {@code =>} scale - null is returned for data types where * SCALE is not applicable. - *
                                  21. RADIX short => radix - *
                                  22. NULLABLE short => can it contain NULL. + *
                                  23. RADIX short {@code =>} radix + *
                                  24. NULLABLE short {@code =>} can it contain NULL. *
                                      *
                                    • functionNoNulls - does not allow NULL values *
                                    • functionNullable - allows NULL values *
                                    • functionNullableUnknown - nullability unknown *
                                    - *
                                  25. REMARKS String => comment describing column/parameter - *
                                  26. CHAR_OCTET_LENGTH int => the maximum length of binary + *
                                  27. REMARKS String {@code =>} comment describing column/parameter + *
                                  28. CHAR_OCTET_LENGTH int {@code =>} the maximum length of binary * and character based parameters or columns. For any other datatype the returned value * is a NULL - *
                                  29. ORDINAL_POSITION int => the ordinal position, starting + *
                                  30. ORDINAL_POSITION int {@code =>} the ordinal position, starting * from 1, for the input and output parameters. A value of 0 * is returned if this row describes the function's return value. * For result set columns, it is the * ordinal position of the column in the result set starting from 1. - *
                                  31. IS_NULLABLE String => ISO rules are used to determine + *
                                  32. IS_NULLABLE String {@code =>} ISO rules are used to determine * the nullability for a parameter or column. *
                                      *
                                    • YES --- if the parameter or column can include NULLs @@ -3405,7 +3405,7 @@ public interface DatabaseMetaData extends Wrapper { *
                                    • empty string --- if the nullability for the * parameter or column is unknown *
                                    - *
                                  33. SPECIFIC_NAME String => the name which uniquely identifies + *
                                  34. SPECIFIC_NAME String {@code =>} the name which uniquely identifies * this function within its schema. This is a user specified, or DBMS * generated, name that may be different then the FUNCTION_NAME * for example with overload functions @@ -3591,21 +3591,21 @@ public interface DatabaseMetaData extends Wrapper { * *

                                    Each column description has the following columns: *

                                      - *
                                    1. TABLE_CAT String => table catalog (may be null) - *
                                    2. TABLE_SCHEM String => table schema (may be null) - *
                                    3. TABLE_NAME String => table name - *
                                    4. COLUMN_NAME String => column name - *
                                    5. DATA_TYPE int => SQL type from java.sql.Types - *
                                    6. COLUMN_SIZE int => column size. - *
                                    7. DECIMAL_DIGITS int => the number of fractional digits. Null is returned for data types where + *
                                    8. TABLE_CAT String {@code =>} table catalog (may be null) + *
                                    9. TABLE_SCHEM String {@code =>} table schema (may be null) + *
                                    10. TABLE_NAME String {@code =>} table name + *
                                    11. COLUMN_NAME String {@code =>} column name + *
                                    12. DATA_TYPE int {@code =>} SQL type from java.sql.Types + *
                                    13. COLUMN_SIZE int {@code =>} column size. + *
                                    14. DECIMAL_DIGITS int {@code =>} the number of fractional digits. Null is returned for data types where * DECIMAL_DIGITS is not applicable. - *
                                    15. NUM_PREC_RADIX int => Radix (typically either 10 or 2) - *
                                    16. COLUMN_USAGE String => The allowed usage for the column. The + *
                                    17. NUM_PREC_RADIX int {@code =>} Radix (typically either 10 or 2) + *
                                    18. COLUMN_USAGE String {@code =>} The allowed usage for the column. The * value returned will correspond to the enum name returned by {@link PseudoColumnUsage#name PseudoColumnUsage.name()} - *
                                    19. REMARKS String => comment describing column (may be null) - *
                                    20. CHAR_OCTET_LENGTH int => for char types the + *
                                    21. REMARKS String {@code =>} comment describing column (may be null) + *
                                    22. CHAR_OCTET_LENGTH int {@code =>} for char types the * maximum number of bytes in the column - *
                                    23. IS_NULLABLE String => ISO rules are used to determine the nullability for a column. + *
                                    24. IS_NULLABLE String {@code =>} ISO rules are used to determine the nullability for a column. *
                                        *
                                      • YES --- if the column can include NULLs *
                                      • NO --- if the column cannot include NULLs diff --git a/jdk/src/share/classes/java/sql/DriverManager.java b/jdk/src/share/classes/java/sql/DriverManager.java index fbe16363529..797a920d230 100644 --- a/jdk/src/share/classes/java/sql/DriverManager.java +++ b/jdk/src/share/classes/java/sql/DriverManager.java @@ -36,7 +36,7 @@ import sun.reflect.Reflection; /** *

                                        The basic service for managing a set of JDBC drivers.
                                        - * NOTE: The {@link DataSource} interface, new in the + * NOTE: The {@link javax.sql.DataSource} interface, new in the * JDBC 2.0 API, provides another way to connect to a data source. * The use of a DataSource object is the preferred means of * connecting to a data source. diff --git a/jdk/src/share/classes/java/sql/ResultSet.java b/jdk/src/share/classes/java/sql/ResultSet.java index ab547733128..7029c935906 100644 --- a/jdk/src/share/classes/java/sql/ResultSet.java +++ b/jdk/src/share/classes/java/sql/ResultSet.java @@ -1350,7 +1350,7 @@ public interface ResultSet extends Wrapper, AutoCloseable { * @param rows the number of rows to fetch * @exception SQLException if a database access error occurs; this method * is called on a closed result set or the - * condition rows >= 0 is not satisfied + * condition {@code rows >= 0} is not satisfied * @since 1.2 * @see #getFetchSize */ diff --git a/jdk/src/share/classes/java/sql/Statement.java b/jdk/src/share/classes/java/sql/Statement.java index 34859c52c44..29b372f522e 100644 --- a/jdk/src/share/classes/java/sql/Statement.java +++ b/jdk/src/share/classes/java/sql/Statement.java @@ -144,7 +144,7 @@ public interface Statement extends Wrapper, AutoCloseable { * @param max the new column size limit in bytes; zero means there is no limit * @exception SQLException if a database access error occurs, * this method is called on a closed Statement - * or the condition max >= 0 is not satisfied + * or the condition {@code max >= 0} is not satisfied * @see #getMaxFieldSize */ void setMaxFieldSize(int max) throws SQLException; @@ -174,7 +174,7 @@ public interface Statement extends Wrapper, AutoCloseable { * @param max the new max rows limit; zero means there is no limit * @exception SQLException if a database access error occurs, * this method is called on a closed Statement - * or the condition max >= 0 is not satisfied + * or the condition {@code max >= 0} is not satisfied * @see #getMaxRows */ void setMaxRows(int max) throws SQLException; @@ -240,7 +240,7 @@ public interface Statement extends Wrapper, AutoCloseable { * there is no limit * @exception SQLException if a database access error occurs, * this method is called on a closed Statement - * or the condition seconds >= 0 is not satisfied + * or the condition {@code seconds >= 0} is not satisfied * @see #getQueryTimeout */ void setQueryTimeout(int seconds) throws SQLException; @@ -385,10 +385,10 @@ public interface Statement extends Wrapper, AutoCloseable { * object(s) obtained with the method getResultSet. * *

                                        There are no more results when the following is true: - *

                                        +     * 
                                        {@code
                                              *     // stmt is a Statement object
                                              *     ((stmt.getMoreResults() == false) && (stmt.getUpdateCount() == -1))
                                        -     * 
                                        + * }
                                        * * @return true if the next result is a ResultSet * object; false if it is an update count or there are @@ -452,7 +452,7 @@ public interface Statement extends Wrapper, AutoCloseable { * @param rows the number of rows to fetch * @exception SQLException if a database access error occurs, * this method is called on a closed Statement or the - * condition rows >= 0 is not satisfied. + * condition {@code rows >= 0} is not satisfied. * @since 1.2 * @see #getFetchSize */ @@ -665,10 +665,10 @@ public interface Statement extends Wrapper, AutoCloseable { * true if the next result is a ResultSet object. * *

                                        There are no more results when the following is true: - *

                                        +     * 
                                        {@code
                                              *     // stmt is a Statement object
                                              *     ((stmt.getMoreResults(current) == false) && (stmt.getUpdateCount() == -1))
                                        -     * 
                                        + * }
                                        * * @param current one of the following Statement * constants indicating what should happen to current @@ -1107,7 +1107,7 @@ public interface Statement extends Wrapper, AutoCloseable { * @param max the new max rows limit; zero means there is no limit * @exception SQLException if a database access error occurs, * this method is called on a closed Statement - * or the condition max >= 0 is not satisfied + * or the condition {@code max >= 0} is not satisfied * @see #getMaxRows * @since 1.8 */ diff --git a/jdk/src/share/classes/java/text/CharacterIterator.java b/jdk/src/share/classes/java/text/CharacterIterator.java index 2b21e14e5ed..7674268db16 100644 --- a/jdk/src/share/classes/java/text/CharacterIterator.java +++ b/jdk/src/share/classes/java/text/CharacterIterator.java @@ -62,27 +62,27 @@ package java.text; *

                                        Examples:

                                        * * Traverse the text from start to finish - *

                                        + * 
                                        {@code
                                          * public void traverseForward(CharacterIterator iter) {
                                          *     for(char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
                                          *         processChar(c);
                                          *     }
                                          * }
                                        - * 
                                        + * }
                                        * * Traverse the text backwards, from end to start - *
                                        + * 
                                        {@code
                                          * public void traverseBackward(CharacterIterator iter) {
                                          *     for(char c = iter.last(); c != CharacterIterator.DONE; c = iter.previous()) {
                                          *         processChar(c);
                                          *     }
                                          * }
                                        - * 
                                        + * }
                                        * * Traverse both forward and backward from a given position in the text. * Calls to notBoundary() in this example represents some * additional stopping criteria. - *
                                        + * 
                                        {@code
                                          * public void traverseOut(CharacterIterator iter, int pos) {
                                          *     for (char c = iter.setIndex(pos);
                                          *              c != CharacterIterator.DONE && notBoundary(c);
                                        @@ -96,7 +96,7 @@ package java.text;
                                          *     int start = iter.getIndex();
                                          *     processSection(start, end);
                                          * }
                                        - * 
                                        + * }
                                        * * @see StringCharacterIterator * @see AttributedCharacterIterator diff --git a/jdk/src/share/classes/java/text/ChoiceFormat.java b/jdk/src/share/classes/java/text/ChoiceFormat.java index 1e318848300..7814f0ef2c5 100644 --- a/jdk/src/share/classes/java/text/ChoiceFormat.java +++ b/jdk/src/share/classes/java/text/ChoiceFormat.java @@ -376,7 +376,7 @@ public class ChoiceFormat extends NumberFormat { /** * Returns pattern with formatted double. - * @param number number to be formatted & substituted. + * @param number number to be formatted and substituted. * @param toAppendTo where text is appended. * @param status ignore no useful status is returned. */ diff --git a/jdk/src/share/classes/java/text/Collator.java b/jdk/src/share/classes/java/text/Collator.java index aaa5276d6f7..d105a810439 100644 --- a/jdk/src/share/classes/java/text/Collator.java +++ b/jdk/src/share/classes/java/text/Collator.java @@ -72,14 +72,14 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * The following example shows how to compare two strings using * the Collator for the default locale. *
                                        - *
                                        + * 
                                        {@code
                                          * // Compare two strings in the default locale
                                          * Collator myCollator = Collator.getInstance();
                                          * if( myCollator.compare("abc", "ABC") < 0 )
                                          *     System.out.println("abc is less than ABC");
                                          * else
                                          *     System.out.println("abc is greater than or equal to ABC");
                                        - * 
                                        + * }
                                        *
                                        * *

                                        diff --git a/jdk/src/share/classes/java/util/Calendar.java b/jdk/src/share/classes/java/util/Calendar.java index 19c3c8540a7..566b8b090be 100644 --- a/jdk/src/share/classes/java/util/Calendar.java +++ b/jdk/src/share/classes/java/util/Calendar.java @@ -2681,9 +2681,9 @@ public abstract class Calendar implements Serializable, Cloneable, ComparableCalendar represents a time * before the time represented by the specified * Object. This method is equivalent to: - *

                                        + *
                                        {@code
                                              *         compareTo(when) < 0
                                        -     * 
                                        + * } * if and only if when is a Calendar * instance. Otherwise, the method returns false. * @@ -2702,9 +2702,9 @@ public abstract class Calendar implements Serializable, Cloneable, ComparableCalendar represents a time * after the time represented by the specified * Object. This method is equivalent to: - *
                                        + *
                                        {@code
                                              *         compareTo(when) > 0
                                        -     * 
                                        + * } * if and only if when is a Calendar * instance. Otherwise, the method returns false. * diff --git a/jdk/src/share/classes/java/util/Collections.java b/jdk/src/share/classes/java/util/Collections.java index 30d589cdc7d..da258793ba6 100644 --- a/jdk/src/share/classes/java/util/Collections.java +++ b/jdk/src/share/classes/java/util/Collections.java @@ -924,9 +924,9 @@ public class Collections { * Returns the starting position of the first occurrence of the specified * target list within the specified source list, or -1 if there is no * such occurrence. More formally, returns the lowest index i - * such that source.subList(i, i+target.size()).equals(target), + * such that {@code source.subList(i, i+target.size()).equals(target)}, * or -1 if there is no such index. (Returns -1 if - * target.size() > source.size().) + * {@code target.size() > source.size()}) * *

                                        This implementation uses the "brute force" technique of scanning * over the source list, looking for a match with the target at each @@ -977,9 +977,9 @@ public class Collections { * Returns the starting position of the last occurrence of the specified * target list within the specified source list, or -1 if there is no such * occurrence. More formally, returns the highest index i - * such that source.subList(i, i+target.size()).equals(target), + * such that {@code source.subList(i, i+target.size()).equals(target)}, * or -1 if there is no such index. (Returns -1 if - * target.size() > source.size().) + * {@code target.size() > source.size()}) * *

                                        This implementation uses the "brute force" technique of iterating * over the source list, looking for a match with the target at each diff --git a/jdk/src/share/classes/java/util/Date.java b/jdk/src/share/classes/java/util/Date.java index 61dac350389..502daaefdbb 100644 --- a/jdk/src/share/classes/java/util/Date.java +++ b/jdk/src/share/classes/java/util/Date.java @@ -984,8 +984,9 @@ public class Date * exclusive OR of the two halves of the primitive long * value returned by the {@link Date#getTime} * method. That is, the hash code is the value of the expression: - *

                                        -     * (int)(this.getTime()^(this.getTime() >>> 32))
                                        + *
                                        {@code
                                        +     * (int)(this.getTime()^(this.getTime() >>> 32))
                                        +     * }
                                        * * @return a hash code value for this object. */ @@ -1085,7 +1086,7 @@ public class Date /** * Creates a string representation of this Date object of * the form: - * + *
                                              * d mon yyyy hh:mm:ss GMT
                                        * where:
                                          *
                                        • d is the day of the month (1 through 31), diff --git a/jdk/src/share/classes/java/util/LinkedHashMap.java b/jdk/src/share/classes/java/util/LinkedHashMap.java index 100710b1bdd..59a8d8f1a5d 100644 --- a/jdk/src/share/classes/java/util/LinkedHashMap.java +++ b/jdk/src/share/classes/java/util/LinkedHashMap.java @@ -437,13 +437,13 @@ public class LinkedHashMap *

                                          Sample use: this override will allow the map to grow up to 100 * entries and then delete the eldest entry each time a new entry is * added, maintaining a steady state of 100 entries. - *

                                          +     * 
                                          {@code
                                                *     private static final int MAX_ENTRIES = 100;
                                                *
                                                *     protected boolean removeEldestEntry(Map.Entry eldest) {
                                                *        return size() > MAX_ENTRIES;
                                                *     }
                                          -     * 
                                          + * }
                                          * *

                                          This method typically does not modify the map in any way, * instead allowing the map to modify itself as directed by its diff --git a/jdk/src/share/classes/java/util/Random.java b/jdk/src/share/classes/java/util/Random.java index c169e053dfd..ca430bae26f 100644 --- a/jdk/src/share/classes/java/util/Random.java +++ b/jdk/src/share/classes/java/util/Random.java @@ -372,7 +372,7 @@ class Random implements java.io.Serializable { * range {@code 0.0f} (inclusive) to {@code 1.0f} (exclusive), is * pseudorandomly generated and returned. All 224 possible {@code float} values - * of the form m x 2m x 2-24, where m is a positive * integer less than 224 , are * produced with (approximately) equal probability. diff --git a/jdk/src/share/classes/java/util/ResourceBundle.java b/jdk/src/share/classes/java/util/ResourceBundle.java index 0d52daa9c48..1d9d80b90a4 100644 --- a/jdk/src/share/classes/java/util/ResourceBundle.java +++ b/jdk/src/share/classes/java/util/ResourceBundle.java @@ -2323,9 +2323,9 @@ public abstract class ResourceBundle { * is returned. And if the resource bundles for the "ja" and * "" Locales are found, then the runtime resource * lookup path (parent chain) is: - *

                                          +         * 
                                          {@code
                                                    *     Messages_ja -> Messages
                                          -         * 
                                          + * }
                                          * * @param baseName * the base name of the resource bundle, a fully diff --git a/jdk/src/share/classes/java/util/Scanner.java b/jdk/src/share/classes/java/util/Scanner.java index cc19b0d1257..f6967f3a75c 100644 --- a/jdk/src/share/classes/java/util/Scanner.java +++ b/jdk/src/share/classes/java/util/Scanner.java @@ -49,47 +49,51 @@ import sun.misc.LRUCache; * *

                                          For example, this code allows a user to read a number from * System.in: - *

                                          + * 
                                          {@code
                                            *     Scanner sc = new Scanner(System.in);
                                            *     int i = sc.nextInt();
                                          - * 
                                          + * }
                                          * *

                                          As another example, this code allows long types to be * assigned from entries in a file myNumbers: - *

                                          + * 
                                          {@code
                                            *      Scanner sc = new Scanner(new File("myNumbers"));
                                            *      while (sc.hasNextLong()) {
                                            *          long aLong = sc.nextLong();
                                          - *      }
                                          + * } + * }
                                          * *

                                          The scanner can also use delimiters other than whitespace. This * example reads several items in from a string: - *

                                          + * 
                                          {@code
                                            *     String input = "1 fish 2 fish red fish blue fish";
                                            *     Scanner s = new Scanner(input).useDelimiter("\\s*fish\\s*");
                                            *     System.out.println(s.nextInt());
                                            *     System.out.println(s.nextInt());
                                            *     System.out.println(s.next());
                                            *     System.out.println(s.next());
                                          - *     s.close(); 
                                          + * s.close(); + * }
                                          *

                                          * prints the following output: - *

                                          + * 
                                          {@code
                                            *     1
                                            *     2
                                            *     red
                                          - *     blue 
                                          + * blue + * }
    * *

    The same output can be generated with this code, which uses a regular * expression to parse all four tokens at once: - *

    + * 
    {@code
      *     String input = "1 fish 2 fish red fish blue fish";
      *     Scanner s = new Scanner(input);
      *     s.findInLine("(\\d+) fish (\\d+) fish (\\w+) fish (\\w+)");
      *     MatchResult result = s.match();
      *     for (int i=1; i<=result.groupCount(); i++)
      *         System.out.println(result.group(i));
    - *     s.close(); 
    + * s.close(); + * }
    * *

    The default whitespace delimiter used * by a scanner is as recognized by {@link java.lang.Character}.{@link @@ -2640,11 +2644,11 @@ public final class Scanner implements Iterator, Closeable { * scanner.reset() behaves in exactly the same way as the * invocation * - *

    +     * 
    {@code
          *   scanner.useDelimiter("\\p{javaWhitespace}+")
          *          .useLocale(Locale.getDefault(Locale.Category.FORMAT))
          *          .useRadix(10);
    -     * 
    + * }
    * * @return this scanner * diff --git a/jdk/src/share/classes/java/util/TimerTask.java b/jdk/src/share/classes/java/util/TimerTask.java index b8c83408680..691c9a03dae 100644 --- a/jdk/src/share/classes/java/util/TimerTask.java +++ b/jdk/src/share/classes/java/util/TimerTask.java @@ -130,14 +130,14 @@ public abstract class TimerTask implements Runnable { *

    This method is typically invoked from within a task's run method, to * determine whether the current execution of the task is sufficiently * timely to warrant performing the scheduled activity: - *

    +     * 
    {@code
          *   public void run() {
          *       if (System.currentTimeMillis() - scheduledExecutionTime() >=
          *           MAX_TARDINESS)
          *               return;  // Too late; skip this execution.
          *       // Perform the task
          *   }
    -     * 
    + * }
    * This method is typically not used in conjunction with * fixed-delay execution repeating tasks, as their scheduled * execution times are allowed to drift over time, and so are not terribly diff --git a/jdk/src/share/classes/java/util/jar/Pack200.java b/jdk/src/share/classes/java/util/jar/Pack200.java index c3ea39587a4..dbefe59305d 100644 --- a/jdk/src/share/classes/java/util/jar/Pack200.java +++ b/jdk/src/share/classes/java/util/jar/Pack200.java @@ -45,7 +45,7 @@ import java.beans.PropertyChangeListener; * transform the byte-stream back to JAR format. *

    * Here is an example using packer and unpacker:

    - *

    + * 
    {@code
      *    import java.util.jar.Pack200;
      *    import java.util.jar.Pack200.*;
      *    ...
    @@ -90,7 +90,7 @@ import java.beans.PropertyChangeListener;
      *    } catch (IOException ioe) {
      *        ioe.printStackTrace();
      *    }
    - * 
    + * } *

    * A Pack200 file compressed with gzip can be hosted on HTTP/1.1 web servers. * The deployment applications can use "Accept-Encoding=pack200-gzip". This diff --git a/jdk/src/share/classes/java/util/logging/ConsoleHandler.java b/jdk/src/share/classes/java/util/logging/ConsoleHandler.java index e0e70a5e689..a8b4bc4f0cd 100644 --- a/jdk/src/share/classes/java/util/logging/ConsoleHandler.java +++ b/jdk/src/share/classes/java/util/logging/ConsoleHandler.java @@ -35,7 +35,7 @@ import java.net.*; *

    * Configuration: * By default each ConsoleHandler is initialized using the following - * LogManager configuration properties where + * LogManager configuration properties where {@code } * refers to the fully-qualified class name of the handler. * If properties are not defined * (or have invalid values) then the specified default values are used. diff --git a/jdk/src/share/classes/java/util/logging/FileHandler.java b/jdk/src/share/classes/java/util/logging/FileHandler.java index 8d3b28d8d52..52360c206ee 100644 --- a/jdk/src/share/classes/java/util/logging/FileHandler.java +++ b/jdk/src/share/classes/java/util/logging/FileHandler.java @@ -333,7 +333,7 @@ public class FileHandler extends StreamHandler { * @exception IOException if there are IO problems opening the files. * @exception SecurityException if a security manager exists and if * the caller does not have LoggingPermission("control"). - * @exception IllegalArgumentException if limit < 0, or count < 1. + * @exception IllegalArgumentException if {@code limit < 0}, or {@code count < 1}. * @exception IllegalArgumentException if pattern is an empty string */ public FileHandler(String pattern, int limit, int count) @@ -371,7 +371,7 @@ public class FileHandler extends StreamHandler { * @exception IOException if there are IO problems opening the files. * @exception SecurityException if a security manager exists and if * the caller does not have LoggingPermission("control"). - * @exception IllegalArgumentException if limit < 0, or count < 1. + * @exception IllegalArgumentException if {@code limit < 0}, or {@code count < 1}. * @exception IllegalArgumentException if pattern is an empty string * */ diff --git a/jdk/src/share/classes/java/util/logging/MemoryHandler.java b/jdk/src/share/classes/java/util/logging/MemoryHandler.java index 5c545cc2912..ddf72c2a1e1 100644 --- a/jdk/src/share/classes/java/util/logging/MemoryHandler.java +++ b/jdk/src/share/classes/java/util/logging/MemoryHandler.java @@ -64,7 +64,7 @@ package java.util.logging; * (defaults to no Filter). *

  • <handler-name>.size * defines the buffer size (defaults to 1000).
  • - *
  • <handler-name>.push + *
  • <handler-name>.push * defines the pushLevel (defaults to level.SEVERE).
  • *
  • <handler-name>.target * specifies the name of the target Handler class. @@ -155,7 +155,7 @@ public class MemoryHandler extends Handler { * @param size the number of log records to buffer (must be greater than zero) * @param pushLevel message level to push on * - * @throws IllegalArgumentException if size is <= 0 + * @throws IllegalArgumentException if {@code size is <= 0} */ public MemoryHandler(Handler target, int size, Level pushLevel) { if (target == null || pushLevel == null) { diff --git a/jdk/src/share/classes/java/util/prefs/Preferences.java b/jdk/src/share/classes/java/util/prefs/Preferences.java index 1867fca9186..e3f459290b2 100644 --- a/jdk/src/share/classes/java/util/prefs/Preferences.java +++ b/jdk/src/share/classes/java/util/prefs/Preferences.java @@ -134,52 +134,52 @@ import java.lang.Double; * subsequently restore from the backup. * *

    The XML document has the following DOCTYPE declaration: - *

    - * <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
    - * 
    + *
    {@code
    + * 
    + * }
    * Note that the system URI (http://java.sun.com/dtd/preferences.dtd) is * not accessed when exporting or importing preferences; it merely * serves as a string to uniquely identify the DTD, which is: - *
    - *    <?xml version="1.0" encoding="UTF-8"?>
    + * 
    {@code
    + *    
      *
    - *    <!-- DTD for a Preferences tree. -->
    + *    
      *
    - *    <!-- The preferences element is at the root of an XML document
    - *         representing a Preferences tree. -->
    - *    <!ELEMENT preferences (root)>
    + *    
    + *    
      *
    - *    <!-- The preferences element contains an optional version attribute,
    - *          which specifies version of DTD. -->
    - *    <!ATTLIST preferences EXTERNAL_XML_VERSION CDATA "0.0" >
    + *    
    + *    
      *
    - *    <!-- The root element has a map representing the root's preferences
    - *         (if any), and one node for each child of the root (if any). -->
    - *    <!ELEMENT root (map, node*) >
    + *    
    + *    
      *
    - *    <!-- Additionally, the root contains a type attribute, which
    - *         specifies whether it's the system or user root. -->
    - *    <!ATTLIST root
    - *              type (system|user) #REQUIRED >
    + *    
    + *    
      *
    - *    <!-- Each node has a map representing its preferences (if any),
    - *         and one node for each child (if any). -->
    - *    <!ELEMENT node (map, node*) >
    + *    
    + *    
      *
    - *    <!-- Additionally, each node has a name attribute -->
    - *    <!ATTLIST node
    - *              name CDATA #REQUIRED >
    + *    
    + *    
      *
    - *    <!-- A map represents the preferences stored at a node (if any). -->
    - *    <!ELEMENT map (entry*) >
    + *    
    + *    
      *
    - *    <!-- An entry represents a single preference, which is simply
    - *          a key-value pair. -->
    - *    <!ELEMENT entry EMPTY >
    - *    <!ATTLIST entry
    + *    
    + *    
    + *    
    + *              value CDATA #REQUIRED >
    + * }
    * * Every Preferences implementation must have an associated {@link * PreferencesFactory} implementation. Every Java(TM) SE implementation must provide @@ -1161,9 +1161,9 @@ public abstract class Preferences { * This XML document is, in effect, an offline backup of the node. * *

    The XML document will have the following DOCTYPE declaration: - *

    -     * <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
    -     * 
    + *
    {@code
    +     * 
    +     * }
    * The UTF-8 character encoding will be used. * *

    This method is an exception to the general rule that the results of @@ -1192,9 +1192,9 @@ public abstract class Preferences { * effect, an offline backup of the subtree rooted at the node. * *

    The XML document will have the following DOCTYPE declaration: - *

    -     * <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
    -     * 
    + *
    {@code
    +     * 
    +     * }
    * The UTF-8 character encoding will be used. * *

    This method is an exception to the general rule that the results of @@ -1228,9 +1228,9 @@ public abstract class Preferences { * do not exist, the nodes will be created. * *

    The XML document must have the following DOCTYPE declaration: - *

    -     * <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
    -     * 
    + *
    {@code
    +     * 
    +     * }
    * (This method is designed for use in conjunction with * {@link #exportNode(OutputStream)} and * {@link #exportSubtree(OutputStream)}. diff --git a/jdk/src/share/classes/java/util/regex/MatchResult.java b/jdk/src/share/classes/java/util/regex/MatchResult.java index 9b52331808f..9767d286377 100644 --- a/jdk/src/share/classes/java/util/regex/MatchResult.java +++ b/jdk/src/share/classes/java/util/regex/MatchResult.java @@ -79,7 +79,7 @@ public interface MatchResult { /** * Returns the offset after the last character matched.

    * - * @return @return The offset after the last character matched + * @return The offset after the last character matched * * @throws IllegalStateException * If no match has yet been attempted, diff --git a/jdk/src/share/classes/java/util/regex/Pattern.java b/jdk/src/share/classes/java/util/regex/Pattern.java index 14cde68c552..ae7468758c8 100644 --- a/jdk/src/share/classes/java/util/regex/Pattern.java +++ b/jdk/src/share/classes/java/util/regex/Pattern.java @@ -108,7 +108,7 @@ import java.util.stream.StreamSupport; * \x{h...h} * The character with hexadecimal value 0xh...h * ({@link java.lang.Character#MIN_CODE_POINT Character.MIN_CODE_POINT} - *  <= 0xh...h <=  + *  <= 0xh...h <=  * {@link java.lang.Character#MAX_CODE_POINT Character.MAX_CODE_POINT}) * \t * The tab character ('\u0009') diff --git a/jdk/src/share/classes/java/util/stream/package-info.java b/jdk/src/share/classes/java/util/stream/package-info.java index 4dfb1e998d2..39509ffffc6 100644 --- a/jdk/src/share/classes/java/util/stream/package-info.java +++ b/jdk/src/share/classes/java/util/stream/package-info.java @@ -141,7 +141,7 @@ * parallelism is explicitly requested. For example, {@code Collection} has methods * {@link java.util.Collection#stream} and {@link java.util.Collection#parallelStream}, * which produce sequential and parallel streams respectively; other stream-bearing methods - * such as {@link java.util.stream.Streams#intRange(int, int)} produce sequential + * such as {@link java.util.stream.IntStream#range(int, int)} produce sequential * streams but these can be efficiently parallelized by calling {@code parallel()} on the * result. The set of operations on serial and parallel streams is identical. To execute the * "sum of weights of blocks" query in parallel, we would do: diff --git a/jdk/src/share/classes/java/util/zip/DeflaterInputStream.java b/jdk/src/share/classes/java/util/zip/DeflaterInputStream.java index a996b14e0eb..cdca7f63bfc 100644 --- a/jdk/src/share/classes/java/util/zip/DeflaterInputStream.java +++ b/jdk/src/share/classes/java/util/zip/DeflaterInputStream.java @@ -97,7 +97,7 @@ public class DeflaterInputStream extends FilterInputStream { * @param in input stream to read the uncompressed data to * @param defl compressor ("deflater") for this stream * @param bufLen compression buffer size - * @throws IllegalArgumentException if {@code bufLen} is <= 0 + * @throws IllegalArgumentException if {@code bufLen <= 0} * @throws NullPointerException if {@code in} or {@code defl} is null */ public DeflaterInputStream(InputStream in, Deflater defl, int bufLen) { @@ -163,8 +163,7 @@ public class DeflaterInputStream extends FilterInputStream { * @param len maximum number of compressed bytes to read into {@code b} * @return the actual number of bytes read, or -1 if the end of the * uncompressed input stream is reached - * @throws IndexOutOfBoundsException if {@code len} > {@code b.length - - * off} + * @throws IndexOutOfBoundsException if {@code len > b.length - off} * @throws IOException if an I/O error occurs or if this input stream is * already closed */ diff --git a/jdk/src/share/classes/java/util/zip/DeflaterOutputStream.java b/jdk/src/share/classes/java/util/zip/DeflaterOutputStream.java index c19a222e5dc..7cb0f8388c4 100644 --- a/jdk/src/share/classes/java/util/zip/DeflaterOutputStream.java +++ b/jdk/src/share/classes/java/util/zip/DeflaterOutputStream.java @@ -71,7 +71,7 @@ class DeflaterOutputStream extends FilterOutputStream { * {@link Deflater#SYNC_FLUSH} before flushing the output * stream, otherwise only flushes the output stream * - * @throws IllegalArgumentException if size is <= 0 + * @throws IllegalArgumentException if {@code size <= 0} * * @since 1.7 */ @@ -101,7 +101,7 @@ class DeflaterOutputStream extends FilterOutputStream { * @param out the output stream * @param def the compressor ("deflater") * @param size the output buffer size - * @exception IllegalArgumentException if size is <= 0 + * @exception IllegalArgumentException if {@code size <= 0} */ public DeflaterOutputStream(OutputStream out, Deflater def, int size) { this(out, def, size, false); diff --git a/jdk/src/share/classes/java/util/zip/GZIPInputStream.java b/jdk/src/share/classes/java/util/zip/GZIPInputStream.java index 74a5c60f1a8..b3d9240ba01 100644 --- a/jdk/src/share/classes/java/util/zip/GZIPInputStream.java +++ b/jdk/src/share/classes/java/util/zip/GZIPInputStream.java @@ -71,7 +71,7 @@ class GZIPInputStream extends InflaterInputStream { * @exception ZipException if a GZIP format error has occurred or the * compression method used is unsupported * @exception IOException if an I/O error has occurred - * @exception IllegalArgumentException if size is <= 0 + * @exception IllegalArgumentException if {@code size <= 0} */ public GZIPInputStream(InputStream in, int size) throws IOException { super(in, new Inflater(true), size); diff --git a/jdk/src/share/classes/java/util/zip/GZIPOutputStream.java b/jdk/src/share/classes/java/util/zip/GZIPOutputStream.java index d5edcf1226a..e454956a127 100644 --- a/jdk/src/share/classes/java/util/zip/GZIPOutputStream.java +++ b/jdk/src/share/classes/java/util/zip/GZIPOutputStream.java @@ -61,8 +61,7 @@ class GZIPOutputStream extends DeflaterOutputStream { * @param out the output stream * @param size the output buffer size * @exception IOException If an I/O error has occurred. - * @exception IllegalArgumentException if size is <= 0 - + * @exception IllegalArgumentException if {@code size <= 0} */ public GZIPOutputStream(OutputStream out, int size) throws IOException { this(out, size, false); @@ -81,7 +80,7 @@ class GZIPOutputStream extends DeflaterOutputStream { * {@link Deflater#SYNC_FLUSH} before flushing the output * stream, otherwise only flushes the output stream * @exception IOException If an I/O error has occurred. - * @exception IllegalArgumentException if size is <= 0 + * @exception IllegalArgumentException if {@code size <= 0} * * @since 1.7 */ diff --git a/jdk/src/share/classes/java/util/zip/InflaterInputStream.java b/jdk/src/share/classes/java/util/zip/InflaterInputStream.java index b948905d0e8..23cb9d943d2 100644 --- a/jdk/src/share/classes/java/util/zip/InflaterInputStream.java +++ b/jdk/src/share/classes/java/util/zip/InflaterInputStream.java @@ -75,7 +75,7 @@ class InflaterInputStream extends FilterInputStream { * @param in the input stream * @param inf the decompressor ("inflater") * @param size the input buffer size - * @exception IllegalArgumentException if size is <= 0 + * @exception IllegalArgumentException if {@code size <= 0} */ public InflaterInputStream(InputStream in, Inflater inf, int size) { super(in); @@ -191,7 +191,7 @@ class InflaterInputStream extends FilterInputStream { * @param n the number of bytes to skip * @return the actual number of bytes skipped. * @exception IOException if an I/O error has occurred - * @exception IllegalArgumentException if n < 0 + * @exception IllegalArgumentException if {@code n < 0} */ public long skip(long n) throws IOException { if (n < 0) { diff --git a/jdk/src/share/classes/java/util/zip/InflaterOutputStream.java b/jdk/src/share/classes/java/util/zip/InflaterOutputStream.java index ab90ccb0300..53f8b5dedee 100644 --- a/jdk/src/share/classes/java/util/zip/InflaterOutputStream.java +++ b/jdk/src/share/classes/java/util/zip/InflaterOutputStream.java @@ -97,7 +97,7 @@ public class InflaterOutputStream extends FilterOutputStream { * @param out output stream to write the uncompressed data to * @param infl decompressor ("inflater") for this stream * @param bufLen decompression buffer size - * @throws IllegalArgumentException if {@code bufLen} is <= 0 + * @throws IllegalArgumentException if {@code bufLen <= 0} * @throws NullPointerException if {@code out} or {@code infl} is null */ public InflaterOutputStream(OutputStream out, Inflater infl, int bufLen) { @@ -211,8 +211,8 @@ public class InflaterOutputStream extends FilterOutputStream { * the output stream * @param off starting offset of the compressed data within {@code b} * @param len number of bytes to decompress from {@code b} - * @throws IndexOutOfBoundsException if {@code off} < 0, or if - * {@code len} < 0, or if {@code len} > {@code b.length - off} + * @throws IndexOutOfBoundsException if {@code off < 0}, or if + * {@code len < 0}, or if {@code len > b.length - off} * @throws IOException if an I/O error occurs or this stream is already * closed * @throws NullPointerException if {@code b} is null diff --git a/jdk/src/share/classes/java/util/zip/ZipInputStream.java b/jdk/src/share/classes/java/util/zip/ZipInputStream.java index 5c315d452c0..fee9f5108d3 100644 --- a/jdk/src/share/classes/java/util/zip/ZipInputStream.java +++ b/jdk/src/share/classes/java/util/zip/ZipInputStream.java @@ -232,7 +232,7 @@ class ZipInputStream extends InflaterInputStream implements ZipConstants { * @return the actual number of bytes skipped * @exception ZipException if a ZIP file error has occurred * @exception IOException if an I/O error has occurred - * @exception IllegalArgumentException if n < 0 + * @exception IllegalArgumentException if {@code n < 0} */ public long skip(long n) throws IOException { if (n < 0) { diff --git a/jdk/src/share/classes/javax/crypto/spec/IvParameterSpec.java b/jdk/src/share/classes/javax/crypto/spec/IvParameterSpec.java index e396c5b45f2..fa1eaedd2f2 100644 --- a/jdk/src/share/classes/javax/crypto/spec/IvParameterSpec.java +++ b/jdk/src/share/classes/javax/crypto/spec/IvParameterSpec.java @@ -68,7 +68,7 @@ public class IvParameterSpec implements AlgorithmParameterSpec { * starts. * @param len the number of IV bytes. * @throws IllegalArgumentException if iv is null - * or (iv.length - offset < len) + * or {@code (iv.length - offset < len)} * @throws ArrayIndexOutOfBoundsException is thrown if offset * or len index bytes outside the iv. */ diff --git a/jdk/src/share/classes/javax/crypto/spec/RC5ParameterSpec.java b/jdk/src/share/classes/javax/crypto/spec/RC5ParameterSpec.java index 7248eefa804..499480c2c5f 100644 --- a/jdk/src/share/classes/javax/crypto/spec/RC5ParameterSpec.java +++ b/jdk/src/share/classes/javax/crypto/spec/RC5ParameterSpec.java @@ -80,7 +80,7 @@ public class RC5ParameterSpec implements AlgorithmParameterSpec { * bytes of the buffer are copied to protect against subsequent * modification. * @exception IllegalArgumentException if iv is - * null or (iv.length < 2 * (wordSize / 8)) + * null or {@code (iv.length < 2 * (wordSize / 8))} */ public RC5ParameterSpec(int version, int rounds, int wordSize, byte[] iv) { this(version, rounds, wordSize, iv, 0); @@ -107,7 +107,7 @@ public class RC5ParameterSpec implements AlgorithmParameterSpec { * @param offset the offset in iv where the IV starts. * @exception IllegalArgumentException if iv is * null or - * (iv.length - offset < 2 * (wordSize / 8)) + * {@code (iv.length - offset < 2 * (wordSize / 8))} */ public RC5ParameterSpec(int version, int rounds, int wordSize, byte[] iv, int offset) { diff --git a/jdk/src/share/classes/javax/crypto/spec/SecretKeySpec.java b/jdk/src/share/classes/javax/crypto/spec/SecretKeySpec.java index 827be0f5274..586399dea4f 100644 --- a/jdk/src/share/classes/javax/crypto/spec/SecretKeySpec.java +++ b/jdk/src/share/classes/javax/crypto/spec/SecretKeySpec.java @@ -130,7 +130,7 @@ public class SecretKeySpec implements KeySpec, SecretKey { * for information about standard algorithm names. * @exception IllegalArgumentException if algorithm * is null or key is null, empty, or too short, - * i.e. key.length-offset. + * i.e. {@code key.length-offsetoffset or len index bytes outside the * key. diff --git a/jdk/src/share/classes/javax/naming/BinaryRefAddr.java b/jdk/src/share/classes/javax/naming/BinaryRefAddr.java index 541c0342094..711a834087b 100644 --- a/jdk/src/share/classes/javax/naming/BinaryRefAddr.java +++ b/jdk/src/share/classes/javax/naming/BinaryRefAddr.java @@ -89,9 +89,9 @@ public class BinaryRefAddr extends RefAddr { * @param src The non-null contents of the address as a byte array. * The contents of src is copied into the new BinaryRefAddr. * @param offset The starting index in src to get the bytes. - * 0 <= offset <= src.length. + * {@code 0 <= offset <= src.length}. * @param count The number of bytes to extract from src. - * 0 <= count <= src.length-offset. + * {@code 0 <= count <= src.length-offset}. */ public BinaryRefAddr(String addrType, byte[] src, int offset, int count) { super(addrType); diff --git a/jdk/src/share/classes/javax/naming/directory/Attribute.java b/jdk/src/share/classes/javax/naming/directory/Attribute.java index fda9e3de264..6ed0d9ad530 100644 --- a/jdk/src/share/classes/javax/naming/directory/Attribute.java +++ b/jdk/src/share/classes/javax/naming/directory/Attribute.java @@ -265,7 +265,7 @@ public interface Attribute extends Cloneable, java.io.Serializable { * If the attribute values are unordered, * this method returns the value that happens to be at that index. * @param ix The index of the value in the ordered list of attribute values. - * 0 <= ix < size(). + * {@code 0 <= ix < size()}. * @return The possibly null attribute value at index ix; * null if the attribute value is null. * @exception NamingException If a naming exception was encountered while @@ -284,7 +284,7 @@ public interface Attribute extends Cloneable, java.io.Serializable { * the front of the list (and their indices decremented by one). * * @param ix The index of the value to remove. - * 0 <= ix < size(). + * {@code 0 <= ix < size()}. * @return The possibly null attribute value at index ix that was removed; * null if the attribute value is null. * @exception IndexOutOfBoundsException If ix is outside the specified range. @@ -302,7 +302,7 @@ public interface Attribute extends Cloneable, java.io.Serializable { * IllegalStateException is thrown. * * @param ix The index in the ordered list of attribute values to add the new value. - * 0 <= ix <= size(). + * {@code 0 <= ix <= size()}. * @param attrVal The possibly null attribute value to add; if null, null is * the value added. * @exception IndexOutOfBoundsException If ix is outside the specified range. @@ -322,7 +322,7 @@ public interface Attribute extends Cloneable, java.io.Serializable { * In that case, IllegalStateException is thrown. * * @param ix The index of the value in the ordered list of attribute values. - * 0 <= ix < size(). + * {@code 0 <= ix < size()}. * @param attrVal The possibly null attribute value to use. * If null, 'null' replaces the old value. * @return The possibly null attribute value at index ix that was replaced. diff --git a/jdk/src/share/classes/javax/naming/ldap/LdapName.java b/jdk/src/share/classes/javax/naming/ldap/LdapName.java index 256f7530cdc..ce94537062d 100644 --- a/jdk/src/share/classes/javax/naming/ldap/LdapName.java +++ b/jdk/src/share/classes/javax/naming/ldap/LdapName.java @@ -443,7 +443,7 @@ public class LdapName implements Name { * @throws InvalidNameException if suffix is not a valid LDAP * name, or if the addition of the components would violate the * syntax rules of this LDAP name. - * @throws IndexOutOfBoundsException. + * @throws IndexOutOfBoundsException * If posn is outside the specified range. */ public Name addAll(int posn, Name suffix) @@ -474,7 +474,7 @@ public class LdapName implements Name { * Must be in the range [0,size()]. * * @return The updated name (not a new instance). - * @throws IndexOutOfBoundsException. + * @throws IndexOutOfBoundsException * If posn is outside the specified range. */ public Name addAll(int posn, List suffixRdns) { @@ -527,7 +527,7 @@ public class LdapName implements Name { * Must be in the range [0,size()]. * @return The updated LdapName, not a new instance. * Cannot be null. - * @exception IndexOutOfBoundsException. + * @exception IndexOutOfBoundsException * If posn is outside the specified range. * @exception InvalidNameException If adding comp at the * specified position would violate the name's syntax. diff --git a/jdk/src/share/classes/javax/naming/ldap/PagedResultsControl.java b/jdk/src/share/classes/javax/naming/ldap/PagedResultsControl.java index 07e29b7a36f..18c08e59933 100644 --- a/jdk/src/share/classes/javax/naming/ldap/PagedResultsControl.java +++ b/jdk/src/share/classes/javax/naming/ldap/PagedResultsControl.java @@ -36,7 +36,7 @@ import com.sun.jndi.ldap.BerEncoder; * at which it invokes search operations. *

    * The following code sample shows how the class may be used: - *

    + * 
    {@code
      *
      *     // Open an LDAP association
      *     LdapContext ctx = new InitialLdapContext();
    @@ -89,13 +89,13 @@ import com.sun.jndi.ldap.BerEncoder;
      *     ctx.close();
      *     ...
      *
    - * 
    + * }
    *

    * This class implements the LDAPv3 Control for paged-results as defined in * RFC 2696. * * The control's value has the following ASN.1 definition: - *

    + * 
    {@code
      *
      *     realSearchControlValue ::= SEQUENCE {
      *         size      INTEGER (0..maxInt),
    @@ -104,7 +104,7 @@ import com.sun.jndi.ldap.BerEncoder;
      *         cookie    OCTET STRING
      *     }
      *
    - * 
    + * }
    * * @since 1.5 * @see PagedResultsResponseControl diff --git a/jdk/src/share/classes/javax/naming/ldap/SortControl.java b/jdk/src/share/classes/javax/naming/ldap/SortControl.java index 486600f72fd..3aef9fdd9ec 100644 --- a/jdk/src/share/classes/javax/naming/ldap/SortControl.java +++ b/jdk/src/share/classes/javax/naming/ldap/SortControl.java @@ -40,7 +40,7 @@ import com.sun.jndi.ldap.BerEncoder; * then the search operation is not performed and an error is returned. *

    * The following code sample shows how the class may be used: - *

    + * 
    {@code
      *
      *     // Open an LDAP association
      *     LdapContext ctx = new InitialLdapContext();
    @@ -85,7 +85,7 @@ import com.sun.jndi.ldap.BerEncoder;
      *     ctx.close();
      *     ...
      *
    - * 
    + * }
    *

    * This class implements the LDAPv3 Request Control for server-side sorting * as defined in diff --git a/jdk/src/share/classes/javax/net/ssl/SNIHostName.java b/jdk/src/share/classes/javax/net/ssl/SNIHostName.java index 1d02104e172..588a8547e11 100644 --- a/jdk/src/share/classes/javax/net/ssl/SNIHostName.java +++ b/jdk/src/share/classes/javax/net/ssl/SNIHostName.java @@ -295,8 +295,8 @@ public final class SNIHostName extends SNIServerName { * representing the hostname(s) to match * @throws NullPointerException if {@code regex} is * {@code null} - * @throws PatternSyntaxException if the regular expression's syntax - * is invalid + * @throws java.util.regex.PatternSyntaxException if the regular expression's + * syntax is invalid */ public static SNIMatcher createSNIMatcher(String regex) { if (regex == null) { diff --git a/jdk/src/share/classes/javax/net/ssl/SSLEngine.java b/jdk/src/share/classes/javax/net/ssl/SSLEngine.java index 433361c6a6b..92e838623f4 100644 --- a/jdk/src/share/classes/javax/net/ssl/SSLEngine.java +++ b/jdk/src/share/classes/javax/net/ssl/SSLEngine.java @@ -211,7 +211,7 @@ import java.nio.ReadOnlyBufferException; * that the source buffer has enough room to hold a record (enlarging if * necessary), and then obtain more inbound data. * - *

    + * 
    {@code
      *   SSLEngineResult r = engine.unwrap(src, dst);
      *   switch (r.getStatus()) {
      *   BUFFER_OVERFLOW:
    @@ -238,7 +238,7 @@ import java.nio.ReadOnlyBufferException;
      *       break;
      *   // other cases: CLOSED, OK.
      *   }
    - * 
    + * }
    * *

    * Unlike SSLSocket, all methods of SSLEngine are @@ -442,7 +442,7 @@ public abstract class SSLEngine { *

          * {@link #wrap(ByteBuffer [], int, int, ByteBuffer)
          *     engine.wrap(new ByteBuffer [] { src }, 0, 1, dst);}
    -     * 
    +     * 
    * * @param src * a ByteBuffer containing outbound application data @@ -478,7 +478,7 @@ public abstract class SSLEngine { *
          * {@link #wrap(ByteBuffer [], int, int, ByteBuffer)
          *     engine.wrap(srcs, 0, srcs.length, dst);}
    -     * 
    +     * 
    * * @param srcs * an array of ByteBuffers containing the @@ -597,7 +597,7 @@ public abstract class SSLEngine { *
          * {@link #unwrap(ByteBuffer, ByteBuffer [], int, int)
          *     engine.unwrap(src, new ByteBuffer [] { dst }, 0, 1);}
    -     * 
    +     * 
    * * @param src * a ByteBuffer containing inbound network data. @@ -633,7 +633,7 @@ public abstract class SSLEngine { *
          * {@link #unwrap(ByteBuffer, ByteBuffer [], int, int)
          *     engine.unwrap(src, dsts, 0, dsts.length);}
    -     * 
    +     * 
    * * @param src * a ByteBuffer containing inbound network data. diff --git a/jdk/src/share/classes/javax/net/ssl/SSLEngineResult.java b/jdk/src/share/classes/javax/net/ssl/SSLEngineResult.java index 45dcddbdeca..93ad6a7b383 100644 --- a/jdk/src/share/classes/javax/net/ssl/SSLEngineResult.java +++ b/jdk/src/share/classes/javax/net/ssl/SSLEngineResult.java @@ -173,7 +173,7 @@ public class SSLEngineResult { * * @throws IllegalArgumentException * if the status or handshakeStatus - * arguments are null, or if <bytesConsumed or + * arguments are null, or if bytesConsumed or * bytesProduced is negative. */ public SSLEngineResult(Status status, HandshakeStatus handshakeStatus, diff --git a/jdk/src/share/classes/javax/net/ssl/SSLSessionContext.java b/jdk/src/share/classes/javax/net/ssl/SSLSessionContext.java index 61f1ddcccce..3459545e96d 100644 --- a/jdk/src/share/classes/javax/net/ssl/SSLSessionContext.java +++ b/jdk/src/share/classes/javax/net/ssl/SSLSessionContext.java @@ -90,7 +90,7 @@ public interface SSLSessionContext { * @param seconds the new session timeout limit in seconds; zero means * there is no limit. * - * @exception IllegalArgumentException if the timeout specified is < 0. + * @exception IllegalArgumentException if the timeout specified is {@code < 0}. * @see #getSessionTimeout */ public void setSessionTimeout(int seconds) @@ -122,7 +122,7 @@ public interface SSLSessionContext { * * @param size the new session cache size limit; zero means there is no * limit. - * @exception IllegalArgumentException if the specified size is < 0. + * @exception IllegalArgumentException if the specified size is {@code < 0}. * @see #getSessionCacheSize */ public void setSessionCacheSize(int size) diff --git a/jdk/src/share/classes/javax/script/ScriptEngineFactory.java b/jdk/src/share/classes/javax/script/ScriptEngineFactory.java index ae064acf9b7..ca22d163590 100644 --- a/jdk/src/share/classes/javax/script/ScriptEngineFactory.java +++ b/jdk/src/share/classes/javax/script/ScriptEngineFactory.java @@ -144,8 +144,7 @@ public interface ScriptEngineFactory { * of the supported scripting language. For instance, an implementaton for a Javascript * engine might be; *

    - *

    -     * 
    +     * 
    {@code
          * public String getMethodCallSyntax(String obj,
          *                                   String m, String... args) {
          *      String ret = obj;
    @@ -159,8 +158,7 @@ public interface ScriptEngineFactory {
          *      ret += ")";
          *      return ret;
          * }
    -     *
    -     *
    + * }
    *

    * * @param obj The name representing the object whose method is to be invoked. The @@ -200,17 +198,17 @@ public interface ScriptEngineFactory { * Returns A valid scripting language executable progam with given statements. * For instance an implementation for a PHP engine might be: *

    - *

    
    +     * 
    {@code
          * public String getProgram(String... statements) {
    -     *      $retval = "<?\n";
    +     *      $retval = "";
          *
          * }
    -     * 
    + * }
    * * @param statements The statements to be executed. May be return values of * calls to the getMethodCallSyntax and getOutputStatement methods. diff --git a/jdk/src/share/classes/javax/security/auth/callback/CallbackHandler.java b/jdk/src/share/classes/javax/security/auth/callback/CallbackHandler.java index 4c6e9a271fa..843accac99b 100644 --- a/jdk/src/share/classes/javax/security/auth/callback/CallbackHandler.java +++ b/jdk/src/share/classes/javax/security/auth/callback/CallbackHandler.java @@ -79,7 +79,7 @@ public interface CallbackHandler { * This example code is for guidance only. Many details, * including proper error handling, are left out for simplicity. * - *
    +     * 
    {@code
          * public void handle(Callback[] callbacks)
          * throws IOException, UnsupportedCallbackException {
          *
    @@ -133,7 +133,7 @@ public interface CallbackHandler {
          * private char[] readPassword(InputStream in) throws IOException {
          *    // insert code to read a user password from the input stream
          * }
    -     * 
    + * }
    * * @param callbacks an array of Callback objects provided * by an underlying security service which contains diff --git a/jdk/src/share/classes/javax/security/sasl/Sasl.java b/jdk/src/share/classes/javax/security/sasl/Sasl.java index 6bdc104b98a..bb9fb2eec04 100644 --- a/jdk/src/share/classes/javax/security/sasl/Sasl.java +++ b/jdk/src/share/classes/javax/security/sasl/Sasl.java @@ -278,7 +278,7 @@ public class Sasl { * * This method uses the JCA Security Provider Framework, described in the - * "Java Cryptography Architecture API Specification & Reference", for + * "Java Cryptography Architecture API Specification & Reference", for * locating and selecting a SaslClient implementation. * * First, it @@ -303,7 +303,7 @@ public class Sasl { * SaslClientFactory.DIGEST-MD5 com.wiz.sasl.digest.ClientFactory *

    * See the - * "Java Cryptography Architecture API Specification & Reference" + * "Java Cryptography Architecture API Specification & Reference" * for information about how to install and configure security service * providers. * @@ -428,7 +428,7 @@ public class Sasl { * This method uses the JCA Security Provider Framework, * described in the - * "Java Cryptography Architecture API Specification & Reference", for + * "Java Cryptography Architecture API Specification & Reference", for * locating and selecting a SaslServer implementation. * * First, it @@ -453,7 +453,7 @@ public class Sasl { * SaslServerFactory.DIGEST-MD5 com.wiz.sasl.digest.ServerFactory *

    * See the - * "Java Cryptography Architecture API Specification & Reference" + * "Java Cryptography Architecture API Specification & Reference" * for information about how to install and configure security * service providers. * diff --git a/jdk/src/share/classes/javax/security/sasl/SaslClient.java b/jdk/src/share/classes/javax/security/sasl/SaslClient.java index 010246c4b13..10f8d3dc3c2 100644 --- a/jdk/src/share/classes/javax/security/sasl/SaslClient.java +++ b/jdk/src/share/classes/javax/security/sasl/SaslClient.java @@ -38,13 +38,13 @@ package javax.security.sasl; *

    * Here's an example of how an LDAP library might use a SaslClient. * It first gets an instance of a SaslClient: - *

    + *
    {@code
      * SaslClient sc = Sasl.createSaslClient(mechanisms,
      *     authorizationId, protocol, serverName, props, callbackHandler);
    - *
    + *}
    * It can then proceed to use the client for authentication. * For example, an LDAP library might use the client as follows: - *
    + *
    {@code
      * // Get initial response and send to server
      * byte[] response = (sc.hasInitialResponse() ? sc.evaluateChallenge(new byte[0]) :
      *     null);
    @@ -74,7 +74,7 @@ package javax.security.sasl;
      *      ldap.out = new SecureOutputStream(sc, ldap.out);
      *    }
      * }
    - *
    + *}
    * * If the mechanism has an initial response, the library invokes * evaluateChallenge() with an empty diff --git a/jdk/src/share/classes/javax/security/sasl/SaslServer.java b/jdk/src/share/classes/javax/security/sasl/SaslServer.java index 54ba6843411..ec5d20a230d 100644 --- a/jdk/src/share/classes/javax/security/sasl/SaslServer.java +++ b/jdk/src/share/classes/javax/security/sasl/SaslServer.java @@ -47,7 +47,7 @@ package javax.security.sasl; * For example, suppose the LDAP server received an LDAP BIND request * containing the name of the SASL mechanism and an (optional) initial * response. It then might use the server as follows: - *
    + *
    {@code
      * while (!ss.isComplete()) {
      *     try {
      *         byte[] challenge = ss.evaluateResponse(response);
    @@ -75,7 +75,7 @@ package javax.security.sasl;
      *      ldap.out = new SecureOutputStream(ss, ldap.out);
      *    }
      * }
    - *
    + *}
    * * @since 1.5 * diff --git a/jdk/src/share/classes/javax/smartcardio/ResponseAPDU.java b/jdk/src/share/classes/javax/smartcardio/ResponseAPDU.java index 94859e83098..7caa52eb5d6 100644 --- a/jdk/src/share/classes/javax/smartcardio/ResponseAPDU.java +++ b/jdk/src/share/classes/javax/smartcardio/ResponseAPDU.java @@ -121,7 +121,7 @@ public final class ResponseAPDU implements java.io.Serializable { * Returns the value of the status bytes SW1 and SW2 as a single * status word SW. * It is defined as - * (getSW1() << 8) | getSW2(). + * {@code (getSW1() << 8) | getSW2()} * * @return the value of the status word SW. */ diff --git a/jdk/src/share/classes/javax/sql/DataSource.java b/jdk/src/share/classes/javax/sql/DataSource.java index d4d9d70ddd4..8235d2a2779 100644 --- a/jdk/src/share/classes/javax/sql/DataSource.java +++ b/jdk/src/share/classes/javax/sql/DataSource.java @@ -82,7 +82,7 @@ public interface DataSource extends CommonDataSource, Wrapper { * * @return a connection to the data source * @exception SQLException if a database access error occurs - * @throws SQLTimeoutException when the driver has determined that the + * @throws java.sql.SQLTimeoutException when the driver has determined that the * timeout value specified by the {@code setLoginTimeout} method * has been exceeded and has at least tried to cancel the * current database connection attempt @@ -98,7 +98,7 @@ public interface DataSource extends CommonDataSource, Wrapper { * @param password the user's password * @return a connection to the data source * @exception SQLException if a database access error occurs - * @throws SQLTimeoutException when the driver has determined that the + * @throws java.sql.SQLTimeoutException when the driver has determined that the * timeout value specified by the {@code setLoginTimeout} method * has been exceeded and has at least tried to cancel the * current database connection attempt diff --git a/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java b/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java index 1019b8de19f..a3b13fa0f5c 100644 --- a/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java +++ b/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java @@ -109,10 +109,10 @@ import javax.sql.rowset.serial.*; * CachedRowSetTM * object crs might have its command property set. Note that if a * tool is used to set properties, this is the code that the tool would use. - *
    + * 
    {@code
      *    crs.setCommand("SELECT FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS" +
      *                   "WHERE CREDIT_LIMIT > ? AND REGION = ?");
    - * 
    + * }
    *

    * In this example, the values for CREDIT_LIMIT and * REGION are placeholder parameters, which are indicated with a @@ -129,16 +129,16 @@ import javax.sql.rowset.serial.*; *

    * The following code fragment demonstrates * setting the two parameters in the query from the previous example. - *

    + * 
    {@code
      *    crs.setInt(1, 5000);
      *    crs.setString(2, "West");
    - * 
    + * }
    * If the execute method is called at this point, the query * sent to the DBMS will be: - *
    + * 
    {@code
      *    "SELECT FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS" +
      *                   "WHERE CREDIT_LIMIT > 5000 AND REGION = 'West'"
    - * 
    + * }
    * NOTE: Setting Array, Clob, Blob and * Ref objects as a command parameter, stores these values as * SerialArray, SerialClob, SerialBlob @@ -158,7 +158,7 @@ import javax.sql.rowset.serial.*; * When the method execute is called, the values in the * Hashtable object are substituted for the appropriate placeholder * parameters in the command. - * + *

    * A call to the method getParams returns the values stored in the * Hashtable object as an array of Object instances. * An element in this array may be a simple Object instance or an @@ -2535,7 +2535,7 @@ public abstract class BaseRowSet implements Serializable, Cloneable { * specific abstract data types. *

    * The parameter value set by this method is stored internally and - * will be supplied as the appropriate parameter in this RowSetRowSet * object's command when the method execute is called. * Methods such as execute and populate must be * provided in any class that extends this class and implements one or diff --git a/jdk/src/share/classes/javax/sql/rowset/CachedRowSet.java b/jdk/src/share/classes/javax/sql/rowset/CachedRowSet.java index 7861223911b..1a8517520a2 100644 --- a/jdk/src/share/classes/javax/sql/rowset/CachedRowSet.java +++ b/jdk/src/share/classes/javax/sql/rowset/CachedRowSet.java @@ -118,7 +118,7 @@ import javax.sql.rowset.spi.*; *

    * There are two ways for a CachedRowSet object to specify which * SyncProvider object it will use. - * *

  • Supplying the name of the implementation to the constructor
    * The following line of code creates the CachedRowSet * object crs2 that is initialized with default values except that its @@ -135,7 +135,7 @@ import javax.sql.rowset.spi.*; *
      *           crs.setSyncProvider("com.fred.providers.HighAvailabilityProvider");
      *      
    - * * See the comments for SyncFactory and SyncProvider for * more details. * @@ -426,10 +426,10 @@ import javax.sql.rowset.spi.*; * The following code fragment illustrates how the CachedRowSet * object crs might have its command property set. Note that if a * tool is used to set properties, this is the code that the tool would use. - *
    + * 
    {@code
      *    crs.setCommand("SELECT FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS " +
      *                   "WHERE CREDIT_LIMIT > ? AND REGION = ?");
    - * 
    + * }
    *

    * The values that will be used to set the command's placeholder parameters are * contained in the RowSet object's params field, which is a @@ -457,7 +457,7 @@ import javax.sql.rowset.spi.*; * The following code fragment gives an idea of how the reader * does this, after obtaining the Connection object * con. - *

    + * 
    {@code
      *    PreparedStatement pstmt = con.prepareStatement(crs.getCommand());
      *    reader.decodeParams();
      *    // decodeParams figures out which setter methods to use and does something
    @@ -465,16 +465,16 @@ import javax.sql.rowset.spi.*;
      *    //    for (i = 0; i < params.length; i++) {
      *    //        pstmt.setObject(i + 1, params[i]);
      *    //    }
    - * 
    + * }
    *

    - * At this point, the command for crs is the query "SELECT + * At this point, the command for crs is the query {@code "SELECT * FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS WHERE CREDIT_LIMIT > 5000 - * AND REGION = "West". After the readData method executes + * AND REGION = "West"}. After the readData method executes * this command with the following line of code, it will have the data from * rs with which to populate crs. - *

    + * 
    {@code
      *     ResultSet rs = pstmt.executeQuery();
    - * 
    + * }
    *

    * The preceding code fragments give an idea of what goes on behind the * scenes; they would not appear in an application, which would not invoke @@ -484,13 +484,13 @@ import javax.sql.rowset.spi.*; * the command. Simply by calling the execute method, * crs populates itself with the requested data from the * table CUSTOMERS. - *

    + * 
    {@code
      *    crs.setCommand("SELECT FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS" +
      *                   "WHERE CREDIT_LIMIT > ? AND REGION = ?");
      *    crs.setInt(1, 5000);
      *    crs.setString(2, "West");
      *    crs.execute();
    - * 
    + * }
    * *

    10.0 Paging Data

    * Because a CachedRowSet object stores data in memory, diff --git a/jdk/src/share/classes/javax/sql/rowset/Predicate.java b/jdk/src/share/classes/javax/sql/rowset/Predicate.java index a9672c98e10..eb747602eb0 100644 --- a/jdk/src/share/classes/javax/sql/rowset/Predicate.java +++ b/jdk/src/share/classes/javax/sql/rowset/Predicate.java @@ -53,8 +53,7 @@ import java.sql.*; * and application motivated implementations of Predicate to emerge. *

    * A sample implementation would look something like this: - *

    - * 
    + * 
    {@code
      *    public class Range implements Predicate {
      *
      *       private Object lo[];
    @@ -79,19 +78,19 @@ import java.sql.*;
      *              if ((rs.getObject(idx[i]) >= lo[i]) &&
      *                  (rs.getObject(idx[i]) >= hi[i]) {
      *                  bool1 = true; // within filter constraints
    + *              } else {
    + *                  bool2 = true; // outside of filter constraints
    + *              }
    + *          }
    + *
    + *          if (bool2) {
    + *             return false;
      *          } else {
    - *            bool2 = true; // outside of filter constraints
    + *             return true;
      *          }
      *      }
    - *
    - *      if (bool2) {
    - *         return false;
    - *      } else {
    - *         return true;
    - *      }
      *  }
    - * 
    - * 
    + * }
    *

    * The example above implements a simple range predicate. Note, that * implementations should but are not required to provider String diff --git a/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java b/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java index e1b78a9202c..a5c998170c3 100644 --- a/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java +++ b/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java @@ -159,7 +159,7 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable { * @param property true if the given column is * automatically incremented; false * otherwise - * @throws SQLException if a database access error occurs or + * @throws SQLException if a database access error occurs or * the given index is out of bounds */ public void setAutoIncrement(int columnIndex, boolean property) throws SQLException { @@ -195,7 +195,7 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable { * value can be used in a WHERE clause; * false otherwise * - * @throws SQLException if a database access error occurs or + * @throws SQLException if a database access error occurs or * the given column number is out of bounds */ public void setSearchable(int columnIndex, boolean property) @@ -212,7 +212,7 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable { * must be between 1 and the number of columns, * inclusive between 1 and the number of columns, inclusive * @param property true if the value is a cash value; false otherwise. - * @throws SQLException if a database access error occurs + * @throws SQLException if a database access error occurs * or the given column number is out of bounds */ public void setCurrency(int columnIndex, boolean property) @@ -233,7 +233,7 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable { * columnNullable, or * columnNullableUnknown * - * @throws SQLException if a database access error occurs, + * @throws SQLException if a database access error occurs, * the given column number is out of bounds, or the value supplied * for the property parameter is not one of the following * constants: diff --git a/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java b/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java index 10e6158e77b..e9b10bdcbfb 100644 --- a/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java +++ b/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java @@ -627,8 +627,6 @@ public class SyncFactory { * required * @throws java.lang.SecurityException if a security manager exists and its * {@code checkPermission} method denies calling {@code setLogger} - * @throws java.util.logging.LoggingPermission if a security manager exists and its - * {@code checkPermission} method denies calling {@code setLevel} * @throws NullPointerException if the logger is null * @see SecurityManager#checkPermission * @see LoggingPermission diff --git a/jdk/src/share/classes/javax/sql/rowset/spi/SyncResolver.java b/jdk/src/share/classes/javax/sql/rowset/spi/SyncResolver.java index 87b5393a725..c1180cf9251 100644 --- a/jdk/src/share/classes/javax/sql/rowset/spi/SyncResolver.java +++ b/jdk/src/share/classes/javax/sql/rowset/spi/SyncResolver.java @@ -193,7 +193,7 @@ import java.sql.SQLException; * code fragment, the value in crs is the one set as the resolved value, which means * that it will be used to overwrite the conflict value in the data source. * - *

    + * 
    {@code
      *     try {
      *
      *         crs.acceptChanges(con);
    @@ -202,8 +202,8 @@ import java.sql.SQLException;
      *
      *         SyncResolver resolver = spe.getSyncResolver();
      *
    - *         Object crsValue;  // value in the RowSet object
    - *         Object resolverValue:  // value in the SyncResolver object
    + *         Object crsValue;  // value in the RowSet object
    + *         Object resolverValue:  // value in the SyncResolver object
      *         Object resolvedValue:  // value to be persisted
      *
      *         while(resolver.nextConflict())  {
    @@ -227,7 +227,7 @@ import java.sql.SQLException;
      *              }
      *          }
      *      }
    - * 
    + * }
    * @author Jonathan Bruce */ diff --git a/jdk/src/share/classes/javax/xml/crypto/dsig/Manifest.java b/jdk/src/share/classes/javax/xml/crypto/dsig/Manifest.java index 7df2c230681..8c7662640be 100644 --- a/jdk/src/share/classes/javax/xml/crypto/dsig/Manifest.java +++ b/jdk/src/share/classes/javax/xml/crypto/dsig/Manifest.java @@ -35,15 +35,15 @@ import java.util.List; * the * W3C Recommendation for XML-Signature Syntax and Processing. * The XML Schema Definition is defined as: - *
    
    - * <element name="Manifest" type="ds:ManifestType"/>
    - *   <complexType name="ManifestType">
    - *     <sequence>
    - *       <element ref="ds:Reference" maxOccurs="unbounded"/>
    - *     </sequence>
    - *     <attribute name="Id" type="ID" use="optional"/>
    - *   </complexType>
    - * 
    + *
    {@code
    + * 
    + *   
    + *     
    + *       
    + *     
    + *     
    + *   
    + * }
    * * A Manifest instance may be created by invoking * one of the {@link XMLSignatureFactory#newManifest newManifest} From 41f703dac218eb926d0fe13b7301434030ece1f3 Mon Sep 17 00:00:00 2001 From: Dan Xu Date: Mon, 10 Jun 2013 11:06:26 -0700 Subject: [PATCH 182/206] 8013827: File.createTempFile hangs with temp file starting with 'com1.4' 8011950: java.io.File.createTempFile enters infinite loop when passed invalid data Reviewed-by: alanb --- jdk/src/share/classes/java/io/File.java | 40 +++++----- .../native/java/io/WinNTFileSystem_md.c | 4 + jdk/test/java/io/File/CreateNewFile.java | 19 ++++- jdk/test/java/io/File/NulFile.java | 2 +- .../File/createTempFile/SpecialTempFile.java | 80 +++++++++++++++++++ 5 files changed, 123 insertions(+), 22 deletions(-) create mode 100644 jdk/test/java/io/File/createTempFile/SpecialTempFile.java diff --git a/jdk/src/share/classes/java/io/File.java b/jdk/src/share/classes/java/io/File.java index 1f1d044b1ab..4bc75fe5099 100644 --- a/jdk/src/share/classes/java/io/File.java +++ b/jdk/src/share/classes/java/io/File.java @@ -1899,14 +1899,20 @@ public class File // file name generation private static final SecureRandom random = new SecureRandom(); - static File generateFile(String prefix, String suffix, File dir) { + static File generateFile(String prefix, String suffix, File dir) + throws IOException + { long n = random.nextLong(); if (n == Long.MIN_VALUE) { n = 0; // corner case } else { n = Math.abs(n); } - return new File(dir, prefix + Long.toString(n) + suffix); + String name = prefix + Long.toString(n) + suffix; + File f = new File(dir, name); + if (!name.equals(f.getName())) + throw new IOException("Unable to create temporary file"); + return f; } } @@ -1988,25 +1994,21 @@ public class File if (suffix == null) suffix = ".tmp"; - File tmpdir = (directory != null) ? directory : TempDirectory.location(); - SecurityManager sm = System.getSecurityManager(); + File tmpdir = (directory != null) ? directory + : TempDirectory.location(); File f; - do { - f = TempDirectory.generateFile(prefix, suffix, tmpdir); - if (sm != null) { - try { - sm.checkWrite(f.getPath()); - } catch (SecurityException se) { - // don't reveal temporary directory location - if (directory == null) - throw new SecurityException("Unable to create temporary file"); - throw se; - } - } - if (f.isInvalid()) { + try { + do { + f = TempDirectory.generateFile(prefix, suffix, tmpdir); + } while (f.exists()); + if (!f.createNewFile()) throw new IOException("Unable to create temporary file"); - } - } while (!fs.createFileExclusively(f.getPath())); + } catch (SecurityException se) { + // don't reveal temporary directory location + if (directory == null) + throw new SecurityException("Unable to create temporary file"); + throw se; + } return f; } diff --git a/jdk/src/windows/native/java/io/WinNTFileSystem_md.c b/jdk/src/windows/native/java/io/WinNTFileSystem_md.c index b28c41b6182..3c8b821e027 100644 --- a/jdk/src/windows/native/java/io/WinNTFileSystem_md.c +++ b/jdk/src/windows/native/java/io/WinNTFileSystem_md.c @@ -541,6 +541,10 @@ Java_java_io_WinNTFileSystem_createFileExclusively(JNIEnv *env, jclass cls, WCHAR *pathbuf = pathToNTPath(env, path, JNI_FALSE); if (pathbuf == NULL) return JNI_FALSE; + if (isReservedDeviceNameW(pathbuf)) { + free(pathbuf); + return JNI_FALSE; + } h = CreateFileW( pathbuf, /* Wide char path name */ GENERIC_READ | GENERIC_WRITE, /* Read and write permission */ diff --git a/jdk/test/java/io/File/CreateNewFile.java b/jdk/test/java/io/File/CreateNewFile.java index fb4f88a7a35..57cd7d1c2a9 100644 --- a/jdk/test/java/io/File/CreateNewFile.java +++ b/jdk/test/java/io/File/CreateNewFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -22,7 +22,7 @@ */ /* @test - @bug 4130498 4391178 + @bug 4130498 4391178 6198547 @summary Basic test for createNewFile method */ @@ -51,5 +51,20 @@ public class CreateNewFile { } catch (IOException e) { // Exception expected } + + testCreateExistingDir(); + } + + // Test JDK-6198547 + private static void testCreateExistingDir() throws IOException { + File tmpFile = new File("hugo"); + if (tmpFile.exists() && !tmpFile.delete()) + throw new RuntimeException("Cannot delete " + tmpFile); + if (!tmpFile.mkdir()) + throw new RuntimeException("Cannot create dir " + tmpFile); + if (!tmpFile.exists()) + throw new RuntimeException("Cannot see created dir " + tmpFile); + if (tmpFile.createNewFile()) + throw new RuntimeException("Should fail to create file " + tmpFile); } } diff --git a/jdk/test/java/io/File/NulFile.java b/jdk/test/java/io/File/NulFile.java index 491f7e024a9..c7cff6aa81d 100644 --- a/jdk/test/java/io/File/NulFile.java +++ b/jdk/test/java/io/File/NulFile.java @@ -612,7 +612,7 @@ public class NulFile { try { File.createTempFile(prefix, suffix, directory); } catch (IOException ex) { - if ("Unable to create temporary file".equals(ex.getMessage())) + if (ExceptionMsg.equals(ex.getMessage())) exceptionThrown = true; } } diff --git a/jdk/test/java/io/File/createTempFile/SpecialTempFile.java b/jdk/test/java/io/File/createTempFile/SpecialTempFile.java new file mode 100644 index 00000000000..20d6ed8cd82 --- /dev/null +++ b/jdk/test/java/io/File/createTempFile/SpecialTempFile.java @@ -0,0 +1,80 @@ +/* + * 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 8013827 8011950 + * @summary Check whether File.createTempFile can handle special parameters + * on Windows platforms + * @author Dan Xu + */ + +import java.io.File; +import java.io.IOException; + +public class SpecialTempFile { + + private static void test(String name, String[] prefix, String[] suffix) { + if (prefix == null || suffix == null + || prefix.length != suffix.length) + { + return; + } + + final String exceptionMsg = "Unable to create temporary file"; + final String errMsg = "IOException is expected"; + + for (int i = 0; i < prefix.length; i++) { + boolean exceptionThrown = false; + File f = null; + System.out.println("In test " + name + + ", creating temp file with prefix, " + + prefix[i] + ", suffix, " + suffix[i]); + try { + f = File.createTempFile(prefix[i], suffix[i]); + } catch (IOException e) { + if (exceptionMsg.equals(e.getMessage())) + exceptionThrown = true; + else + System.out.println("Wrong error message:" + e.getMessage()); + } + if (!exceptionThrown || f != null) + throw new RuntimeException(errMsg); + } + } + + public static void main(String[] args) throws Exception { + if (!System.getProperty("os.name").startsWith("Windows")) + return; + + // Test JDK-8013827 + String[] resvPre = { "LPT1.package.zip", "com7.4.package.zip" }; + String[] resvSuf = { ".temp", ".temp" }; + test("ReservedName", resvPre, resvSuf); + + // Test JDK-8011950 + String[] slashPre = { "///..///", "temp", "///..///" }; + String[] slashSuf = { ".temp", "///..///..", "///..///.." }; + test("SlashedName", slashPre, slashSuf); + } +} From ee6710759195b9d1fa4669456c3406bca887e1c1 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Tue, 11 Jun 2013 12:13:26 +0200 Subject: [PATCH 183/206] 8015895: Int/LongStream.range/rangeClosed 8012986: Right-bias range spliterators for large ranges Reviewed-by: mduigou --- .../classes/java/util/stream/IntStream.java | 38 +- .../classes/java/util/stream/LongStream.java | 57 ++- .../classes/java/util/stream/Streams.java | 188 +++++++--- .../stream/IntStreamTestDataProvider.java | 16 +- .../stream/LongStreamTestDataProvider.java | 16 +- .../tests/java/util/stream/RangeTest.java | 343 ++++++++++-------- 6 files changed, 407 insertions(+), 251 deletions(-) diff --git a/jdk/src/share/classes/java/util/stream/IntStream.java b/jdk/src/share/classes/java/util/stream/IntStream.java index 35cbe29cc18..3545c9b83ab 100644 --- a/jdk/src/share/classes/java/util/stream/IntStream.java +++ b/jdk/src/share/classes/java/util/stream/IntStream.java @@ -759,12 +759,13 @@ public interface IntStream extends BaseStream { /** * Returns a sequential {@code IntStream} from {@code startInclusive} * (inclusive) to {@code endExclusive} (exclusive) by an incremental step of - * 1. + * {@code 1}. * - * @implSpec - * The implementation behaves as if: + * @apiNote + *

    An equivalent sequence of increasing values can be produced + * sequentially using a {@code for} loop as follows: *

    {@code
    -     *     intRange(startInclusive, endExclusive, 1);
    +     *     for (int i = startInclusive; i < endExclusive ; i++) { ... }
          * }
    * * @param startInclusive the (inclusive) initial value @@ -773,36 +774,37 @@ public interface IntStream extends BaseStream { * elements */ public static IntStream range(int startInclusive, int endExclusive) { - return range(startInclusive, endExclusive, 1); + if (startInclusive >= endExclusive) { + return empty(); + } else { + return StreamSupport.intStream( + new Streams.RangeIntSpliterator(startInclusive, endExclusive, false)); + } } /** * Returns a sequential {@code IntStream} from {@code startInclusive} - * (inclusive) to {@code endExclusive} (exclusive) by a positive {@code - * step}. If {@code startInclusive} is greater than or equal to {@code - * endExclusive}, an empty stream is returned. + * (inclusive) to {@code endInclusive} (inclusive) by an incremental step of + * {@code 1}. * + * @apiNote *

    An equivalent sequence of increasing values can be produced * sequentially using a {@code for} loop as follows: *

    {@code
    -     *     for (int i = startInclusive; i < endExclusive ; i += step) { ... }
    +     *     for (int i = startInclusive; i <= endInclusive ; i++) { ... }
          * }
    * * @param startInclusive the (inclusive) initial value - * @param endExclusive the exclusive upper bound - * @param step the positive difference between consecutive values + * @param endInclusive the inclusive upper bound * @return a sequential {@code IntStream} for the range of {@code int} * elements - * @throws IllegalArgumentException if {@code step} is less than or equal to - * 0 */ - public static IntStream range(int startInclusive, int endExclusive, int step) { - if (step <= 0) { - throw new IllegalArgumentException(String.format("Illegal step: %d", step)); - } else if (startInclusive >= endExclusive) { + public static IntStream rangeClosed(int startInclusive, int endInclusive) { + if (startInclusive > endInclusive) { return empty(); } else { - return StreamSupport.intStream(new Streams.RangeIntSpliterator(startInclusive, endExclusive, step)); + return StreamSupport.intStream( + new Streams.RangeIntSpliterator(startInclusive, endInclusive, true)); } } } diff --git a/jdk/src/share/classes/java/util/stream/LongStream.java b/jdk/src/share/classes/java/util/stream/LongStream.java index cbdae128f98..1a1b2414338 100644 --- a/jdk/src/share/classes/java/util/stream/LongStream.java +++ b/jdk/src/share/classes/java/util/stream/LongStream.java @@ -750,12 +750,13 @@ public interface LongStream extends BaseStream { /** * Returns a sequential {@code LongStream} from {@code startInclusive} * (inclusive) to {@code endExclusive} (exclusive) by an incremental step of - * 1. + * {@code 1}. * - * @implSpec - * The implementation behaves as if: + * @apiNote + *

    An equivalent sequence of increasing values can be produced + * sequentially using a {@code for} loop as follows: *

    {@code
    -     *     longRange(startInclusive, endExclusive, 1);
    +     *     for (long i = startInclusive; i < endExclusive ; i++) { ... }
          * }
    * * @param startInclusive the (inclusive) initial value @@ -764,36 +765,56 @@ public interface LongStream extends BaseStream { * elements */ public static LongStream range(long startInclusive, final long endExclusive) { - return range(startInclusive, endExclusive, 1); + if (startInclusive >= endExclusive) { + return empty(); + } else if (endExclusive - startInclusive < 0) { + // Size of range > Long.MAX_VALUE + // Split the range in two and concatenate + // Note: if the range is [Long.MIN_VALUE, Long.MAX_VALUE) then + // the lower range, [Long.MIN_VALUE, 0) will be further split in two +// long m = startInclusive + Long.divideUnsigned(endExclusive - startInclusive, 2) + 1; +// return Streams.concat(range(startInclusive, m), range(m, endExclusive)); + // This is temporary until Streams.concat is supported + throw new UnsupportedOperationException(); + } else { + return StreamSupport.longStream( + new Streams.RangeLongSpliterator(startInclusive, endExclusive, false)); + } } /** * Returns a sequential {@code LongStream} from {@code startInclusive} - * (inclusive) to {@code endExclusive} (exclusive) by {@code step}. If - * {@code startInclusive} is greater than or equal to {@code - * endExclusive}, an empty stream is returned. + * (inclusive) to {@code endInclusive} (inclusive) by an incremental step of + * {@code 1}. * + * @apiNote *

    An equivalent sequence of increasing values can be produced * sequentially using a {@code for} loop as follows: *

    {@code
    -     *     for (long i = startInclusive; i < endExclusive ; i += step) { ... }
    +     *     for (long i = startInclusive; i <= endInclusive ; i++) { ... }
          * }
    * * @param startInclusive the (inclusive) initial value - * @param endExclusive the exclusive upper bound - * @param step the difference between consecutive values + * @param endInclusive the inclusive upper bound * @return a sequential {@code LongStream} for the range of {@code long} * elements - * @throws IllegalArgumentException if {@code step} is less than or equal to - * 0 */ - public static LongStream range(long startInclusive, final long endExclusive, final long step) { - if (step <= 0) { - throw new IllegalArgumentException(String.format("Illegal step: %d", step)); - } else if (startInclusive >= endExclusive) { + public static LongStream rangeClosed(long startInclusive, final long endInclusive) { + if (startInclusive > endInclusive) { return empty(); + } else if (endInclusive - startInclusive + 1 <= 0) { + // Size of range > Long.MAX_VALUE + // Split the range in two and concatenate + // Note: if the range is [Long.MIN_VALUE, Long.MAX_VALUE] then + // the lower range, [Long.MIN_VALUE, 0), and upper range, + // [0, Long.MAX_VALUE], will both be further split in two +// long m = startInclusive + Long.divideUnsigned(endInclusive - startInclusive, 2) + 1; +// return Streams.concat(range(startInclusive, m), rangeClosed(m, endInclusive)); + // This is temporary until Streams.concat is supported + throw new UnsupportedOperationException(); } else { - return StreamSupport.longStream(new Streams.RangeLongSpliterator(startInclusive, endExclusive, step)); + return StreamSupport.longStream( + new Streams.RangeLongSpliterator(startInclusive, endInclusive, true)); } } } diff --git a/jdk/src/share/classes/java/util/stream/Streams.java b/jdk/src/share/classes/java/util/stream/Streams.java index 22b973f742f..11dbbe3d7ca 100644 --- a/jdk/src/share/classes/java/util/stream/Streams.java +++ b/jdk/src/share/classes/java/util/stream/Streams.java @@ -25,7 +25,6 @@ package java.util.stream; import java.util.Comparator; -import java.util.Iterator; import java.util.Objects; import java.util.Spliterator; import java.util.Spliterators; @@ -62,39 +61,62 @@ class Streams { * An {@code int} range spliterator. */ static final class RangeIntSpliterator implements Spliterator.OfInt { + // Can never be greater that upTo, this avoids overflow if upper bound + // is Integer.MAX_VALUE + // All elements are traversed if from == upTo & last == 0 private int from; private final int upTo; - private final int step; + // 1 if the range is closed and the last element has not been traversed + // Otherwise, 0 if the range is open, or is a closed range and all + // elements have been traversed + private int last; - RangeIntSpliterator(int from, int upTo, int step) { + RangeIntSpliterator(int from, int upTo, boolean closed) { + this(from, upTo, closed ? 1 : 0); + } + + private RangeIntSpliterator(int from, int upTo, int last) { this.from = from; this.upTo = upTo; - this.step = step; + this.last = last; } @Override public boolean tryAdvance(IntConsumer consumer) { - boolean hasNext = from < upTo; - if (hasNext) { - consumer.accept(from); - from += step; + final int i = from; + if (i < upTo) { + from++; + consumer.accept(i); + return true; } - return hasNext; + else if (last > 0) { + last = 0; + consumer.accept(i); + return true; + } + return false; } @Override public void forEachRemaining(IntConsumer consumer) { - int hUpTo = upTo; - int hStep = step; // hoist accesses and checks from loop - for (int i = from; i < hUpTo; i += hStep) - consumer.accept(i); + int i = from; + final int hUpTo = upTo; + int hLast = last; from = upTo; + last = 0; + while (i < hUpTo) { + consumer.accept(i++); + } + if (hLast > 0) { + // Last element of closed range + consumer.accept(i); + } } @Override public long estimateSize() { - int d = upTo - from; - return (d / step) + ((d % step == 0) ? 0 : 1); + // Ensure ranges of size > Integer.MAX_VALUE report the correct size + return ((long) upTo) - from + last; } @Override @@ -111,57 +133,108 @@ class Streams { @Override public Spliterator.OfInt trySplit() { - return estimateSize() <= 1 + long size = estimateSize(); + return size <= 1 ? null - : new RangeIntSpliterator(from, from = from + midPoint(), step); + // Left split always has a half-open range + : new RangeIntSpliterator(from, from = from + splitPoint(size), 0); } - private int midPoint() { - // Size is known to be >= 2 - int bisection = (upTo - from) / 2; - // If bisection > step then round down to nearest multiple of step - // otherwise round up to step - return bisection > step ? bisection - bisection % step : step; + /** + * The spliterator size below which the spliterator will be split + * at the mid-point to produce balanced splits. Above this size the + * spliterator will be split at a ratio of + * 1:(RIGHT_BALANCED_SPLIT_RATIO - 1) + * to produce right-balanced splits. + * + *

    Such splitting ensures that for very large ranges that the left + * side of the range will more likely be processed at a lower-depth + * than a balanced tree at the expense of a higher-depth for the right + * side of the range. + * + *

    This is optimized for cases such as IntStream.ints() that is + * implemented as range of 0 to Integer.MAX_VALUE but is likely to be + * augmented with a limit operation that limits the number of elements + * to a count lower than this threshold. + */ + private static final int BALANCED_SPLIT_THRESHOLD = 1 << 24; + + /** + * The split ratio of the left and right split when the spliterator + * size is above BALANCED_SPLIT_THRESHOLD. + */ + private static final int RIGHT_BALANCED_SPLIT_RATIO = 1 << 3; + + private int splitPoint(long size) { + int d = (size < BALANCED_SPLIT_THRESHOLD) ? 2 : RIGHT_BALANCED_SPLIT_RATIO; + // 2 <= size <= 2^32 + return (int) (size / d); } } /** * A {@code long} range spliterator. + * + * This implementation cannot be used for ranges whose size is greater + * than Long.MAX_VALUE */ static final class RangeLongSpliterator implements Spliterator.OfLong { + // Can never be greater that upTo, this avoids overflow if upper bound + // is Long.MAX_VALUE + // All elements are traversed if from == upTo & last == 0 private long from; private final long upTo; - private final long step; + // 1 if the range is closed and the last element has not been traversed + // Otherwise, 0 if the range is open, or is a closed range and all + // elements have been traversed + private int last; - RangeLongSpliterator(long from, long upTo, long step) { + RangeLongSpliterator(long from, long upTo, boolean closed) { + this(from, upTo, closed ? 1 : 0); + } + + private RangeLongSpliterator(long from, long upTo, int last) { + assert upTo - from + last > 0; this.from = from; this.upTo = upTo; - this.step = step; + this.last = last; } @Override public boolean tryAdvance(LongConsumer consumer) { - boolean hasNext = from < upTo; - if (hasNext) { - consumer.accept(from); - from += step; + final long i = from; + if (i < upTo) { + from++; + consumer.accept(i); + return true; } - return hasNext; + else if (last > 0) { + last = 0; + consumer.accept(i); + return true; + } + return false; } @Override public void forEachRemaining(LongConsumer consumer) { - long hUpTo = upTo; - long hStep = step; // hoist accesses and checks from loop - for (long i = from; i < hUpTo; i += hStep) - consumer.accept(i); + long i = from; + final long hUpTo = upTo; + int hLast = last; from = upTo; + last = 0; + while (i < hUpTo) { + consumer.accept(i++); + } + if (hLast > 0) { + // Last element of closed range + consumer.accept(i); + } } @Override public long estimateSize() { - long d = upTo - from; - return (d / step) + ((d % step == 0) ? 0 : 1); + return upTo - from + last; } @Override @@ -178,17 +251,42 @@ class Streams { @Override public Spliterator.OfLong trySplit() { - return estimateSize() <= 1 + long size = estimateSize(); + return size <= 1 ? null - : new RangeLongSpliterator(from, from = from + midPoint(), step); + // Left split always has a half-open range + : new RangeLongSpliterator(from, from = from + splitPoint(size), 0); } - private long midPoint() { - // Size is known to be >= 2 - long bisection = (upTo - from) / 2; - // If bisection > step then round down to nearest multiple of step - // otherwise round up to step - return bisection > step ? bisection - bisection % step : step; + /** + * The spliterator size below which the spliterator will be split + * at the mid-point to produce balanced splits. Above this size the + * spliterator will be split at a ratio of + * 1:(RIGHT_BALANCED_SPLIT_RATIO - 1) + * to produce right-balanced splits. + * + *

    Such splitting ensures that for very large ranges that the left + * side of the range will more likely be processed at a lower-depth + * than a balanced tree at the expense of a higher-depth for the right + * side of the range. + * + *

    This is optimized for cases such as LongStream.longs() that is + * implemented as range of 0 to Long.MAX_VALUE but is likely to be + * augmented with a limit operation that limits the number of elements + * to a count lower than this threshold. + */ + private static final long BALANCED_SPLIT_THRESHOLD = 1 << 24; + + /** + * The split ratio of the left and right split when the spliterator + * size is above BALANCED_SPLIT_THRESHOLD. + */ + private static final long RIGHT_BALANCED_SPLIT_RATIO = 1 << 3; + + private long splitPoint(long size) { + long d = (size < BALANCED_SPLIT_THRESHOLD) ? 2 : RIGHT_BALANCED_SPLIT_RATIO; + // 2 <= size <= Long.MAX_VALUE + return size / d; } } diff --git a/jdk/test/java/util/stream/bootlib/java/util/stream/IntStreamTestDataProvider.java b/jdk/test/java/util/stream/bootlib/java/util/stream/IntStreamTestDataProvider.java index 3ef2acfbe34..2ddad65f539 100644 --- a/jdk/test/java/util/stream/bootlib/java/util/stream/IntStreamTestDataProvider.java +++ b/jdk/test/java/util/stream/bootlib/java/util/stream/IntStreamTestDataProvider.java @@ -95,12 +95,8 @@ public class IntStreamTestDataProvider { list.add(streamDataDescr("IntStream.intRange(0,l): " + ints.length, () -> IntStream.range(0, ints.length))); - list.add(streamDataDescr("IntStream.intRange(0,l,2): " + ints.length, - () -> IntStream.range(0, ints.length, 2))); - list.add(streamDataDescr("IntStream.intRange(0,l,3): " + ints.length, - () -> IntStream.range(0, ints.length, 3))); - list.add(streamDataDescr("IntStream.intRange(0,l,7): " + ints.length, - () -> IntStream.range(0, ints.length, 7))); + list.add(streamDataDescr("IntStream.rangeClosed(0,l): " + ints.length, + () -> IntStream.rangeClosed(0, ints.length))); } testData = list.toArray(new Object[0][]); } @@ -131,12 +127,8 @@ public class IntStreamTestDataProvider { spliterators.add(splitDescr("IntStream.intRange(0,l):" + name, () -> IntStream.range(0, ints.length).spliterator())); - spliterators.add(splitDescr("IntStream.intRange(0,l,2):" + name, - () -> IntStream.range(0, ints.length, 2).spliterator())); - spliterators.add(splitDescr("IntStream.intRange(0,l,3):" + name, - () -> IntStream.range(0, ints.length, 3).spliterator())); - spliterators.add(splitDescr("IntStream.intRange(0,l,7):" + name, - () -> IntStream.range(0, ints.length, 7).spliterator())); + spliterators.add(splitDescr("IntStream.intRangeClosed(0,l):" + name, + () -> IntStream.rangeClosed(0, ints.length).spliterator())); // Need more! } diff --git a/jdk/test/java/util/stream/bootlib/java/util/stream/LongStreamTestDataProvider.java b/jdk/test/java/util/stream/bootlib/java/util/stream/LongStreamTestDataProvider.java index f37a1108c50..4ce7ae6d217 100644 --- a/jdk/test/java/util/stream/bootlib/java/util/stream/LongStreamTestDataProvider.java +++ b/jdk/test/java/util/stream/bootlib/java/util/stream/LongStreamTestDataProvider.java @@ -95,12 +95,8 @@ public class LongStreamTestDataProvider { list.add(streamDataDescr("LongStream.longRange(0,l): " + longs.length, () -> LongStream.range(0, longs.length))); - list.add(streamDataDescr("LongStream.longRange(0,l,2): " + longs.length, - () -> LongStream.range(0, longs.length, 2))); - list.add(streamDataDescr("LongStream.longRange(0,l,3): " + longs.length, - () -> LongStream.range(0, longs.length, 3))); - list.add(streamDataDescr("LongStream.longRange(0,l,7): " + longs.length, - () -> LongStream.range(0, longs.length, 7))); + list.add(streamDataDescr("LongStream.longRangeClosed(0,l): " + longs.length, + () -> LongStream.rangeClosed(0, longs.length))); } testData = list.toArray(new Object[0][]); } @@ -131,12 +127,8 @@ public class LongStreamTestDataProvider { spliterators.add(splitDescr("LongStream.longRange(0,l):" + name, () -> LongStream.range(0, longs.length).spliterator())); - spliterators.add(splitDescr("LongStream.longRange(0,l,2):" + name, - () -> LongStream.range(0, longs.length, 2).spliterator())); - spliterators.add(splitDescr("LongStream.longRange(0,l,3):" + name, - () -> LongStream.range(0, longs.length, 3).spliterator())); - spliterators.add(splitDescr("LongStream.longRange(0,l,7):" + name, - () -> LongStream.range(0, longs.length, 7).spliterator())); + spliterators.add(splitDescr("LongStream.longRangeClosed(0,l):" + name, + () -> LongStream.rangeClosed(0, longs.length).spliterator())); // Need more! } spliteratorTestData = spliterators.toArray(new Object[0][]); diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/RangeTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/RangeTest.java index 1a23f550fec..9109e036f74 100644 --- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/RangeTest.java +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/RangeTest.java @@ -24,10 +24,11 @@ package org.openjdk.tests.java.util.stream; import java.util.Arrays; import java.util.Optional; -import java.util.stream.DoubleStream; +import java.util.Spliterator; import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.OpTestCase; +import java.util.stream.SpliteratorTestHelper; import java.util.stream.Stream; import java.util.stream.TestData; @@ -54,73 +55,76 @@ public class RangeTest extends OpTestCase { // - public void testIntRangeErrors() { - for (int start : Arrays.asList(1, 10, -1, -10)) { - for (int end : Arrays.asList(1, 10, -1, -10)) { - for (int step : Arrays.asList(0, 1, -1, Integer.MAX_VALUE, Integer.MIN_VALUE)) { - if (step > 0) - executeAndNoCatch(() -> IntStream.range(start, end, step)); - else - executeAndCatch(() -> IntStream.range(start, end, step)); - } - } - } - } - public void testIntRange() { - // Without step + // Half-open for (int start : Arrays.asList(1, 10, -1, -10)) { for (int end : Arrays.asList(1, 10, -1, -10)) { - int step = 1; int size = (start < end) ? end - start : 0; int[] exp = new int[size]; - if (start < end) { - for (int i = start, p = 0; i < end; i++, p++) { - exp[p] = i; - } + for (int i = start, p = 0; i < end; i++, p++) { + exp[p] = i; } int[] inc = IntStream.range(start, end).toArray(); assertEquals(inc.length, size); assertTrue(Arrays.equals(exp, inc)); - withData(intRangeData(start, end, step)).stream(s -> s). + withData(intRangeData(start, end)).stream(s -> s). expectedResult(exp).exercise(); } } - // With step + // Closed for (int start : Arrays.asList(1, 10, -1, -10)) { for (int end : Arrays.asList(1, 10, -1, -10)) { - for (int step : Arrays.asList(1, -1, -2, 2)) { - if (step > 0) { - int d = end - start; - int size = (start < end) ? (d / step) + ((d % step == 0) ? 0 : 1) : 0; - int[] exp = new int[size]; - if (start < end) { - for (int i = start, p = 0; i < end; i += step, p++) { - exp[p] = i; - } - } - - int[] inc = IntStream.range(start, end, step).toArray(); - assertEquals(inc.length, size); - assertTrue(Arrays.equals(exp, inc)); - - withData(intRangeData(start, end, step)).stream(s -> s). - expectedResult(exp).exercise(); - } + int size = (start <= end) ? end - start + 1 : 0; + int[] exp = new int[size]; + for (int i = start, p = 0; i <= end; i++, p++) { + exp[p] = i; } + + int[] inc = IntStream.rangeClosed(start, end).toArray(); + assertEquals(inc.length, size); + assertTrue(Arrays.equals(exp, inc)); + + withData(intRangeClosedData(start, end)).stream(s -> s). + expectedResult(exp).exercise(); } } + + // Closed, maximum upper bound of Integer.MAX_VALUE + { + int[] inc = IntStream.rangeClosed(Integer.MAX_VALUE - 1, Integer.MAX_VALUE).toArray(); + assertEquals(2, inc.length); + assertEquals(Integer.MAX_VALUE - 1, inc[0]); + assertEquals(Integer.MAX_VALUE, inc[1]); + + inc = IntStream.rangeClosed(Integer.MAX_VALUE, Integer.MAX_VALUE).toArray(); + assertEquals(1, inc.length); + assertEquals(Integer.MAX_VALUE, inc[0]); + + SpliteratorTestHelper.testIntSpliterator( + () -> IntStream.rangeClosed(Integer.MAX_VALUE - 8, Integer.MAX_VALUE).spliterator()); + } + + // Range wider than Integer.MAX_VALUE + { + Spliterator.OfInt s = IntStream.rangeClosed(Integer.MIN_VALUE, Integer.MAX_VALUE). + spliterator(); + assertEquals(s.estimateSize(), 1L << 32); + } } - TestData.OfInt intRangeData(int start, int end, int step) { - return TestData.Factory.ofIntSupplier("int range", () -> IntStream.range(start, end, step)); + TestData.OfInt intRangeData(int start, int end) { + return TestData.Factory.ofIntSupplier("int range", () -> IntStream.range(start, end)); + } + + TestData.OfInt intRangeClosedData(int start, int end) { + return TestData.Factory.ofIntSupplier("int rangeClosed", () -> IntStream.rangeClosed(start, end)); } public void tesIntRangeReduce() { - withData(intRangeData(0, 10000, 1)). + withData(intRangeData(0, 10000)). terminal(s -> s.reduce(0, Integer::sum)).exercise(); } @@ -137,74 +141,69 @@ public class RangeTest extends OpTestCase { // - public void testLongRangeErrors() { - for (long start : Arrays.asList(1, 10, -1, -10)) { - for (long end : Arrays.asList(1, 10, -1, -10)) { - for (long step : Arrays.asList(0L, 1L, -1L, Long.MAX_VALUE, Long.MIN_VALUE)) { - if (step > 0) - executeAndNoCatch(() -> LongStream.range(start, end, step)); - else - executeAndCatch(() -> LongStream.range(start, end, step)); - } - } - } - } - public void testLongRange() { - // Without step + // Half-open for (long start : Arrays.asList(1, 1000, -1, -1000)) { for (long end : Arrays.asList(1, 1000, -1, -1000)) { - long step = 1; long size = start < end ? end - start : 0; long[] exp = new long[(int) size]; - if (start < end) { - for (long i = start, p = 0; i < end; i++, p++) { - exp[(int) p] = i; - } + for (long i = start, p = 0; i < end; i++, p++) { + exp[(int) p] = i; } long[] inc = LongStream.range(start, end).toArray(); assertEquals(inc.length, size); assertTrue(Arrays.equals(exp, inc)); - withData(longRangeData(start, end, step)).stream(s -> s). + withData(longRangeData(start, end)).stream(s -> s). expectedResult(exp).exercise(); } } - // With step + // Closed for (long start : Arrays.asList(1, 1000, -1, -1000)) { for (long end : Arrays.asList(1, 1000, -1, -1000)) { - for (long step : Arrays.asList(1, -1, -2, 2)) { - if (step > 0) { - - long d = end - start; - long size = start < end ? (d / step) + ((d % step == 0) ? 0 : 1) : 0; - long[] exp = new long[(int) size]; - if (start < end) { - for (long i = start, p = 0; i < end; i += step, p++) { - exp[(int) p] = i; - } - } - - long[] inc = LongStream.range(start, end, step).toArray(); - assertEquals(inc.length, size); - assertTrue(Arrays.equals(exp, inc)); - - withData(longRangeData(start, end, step)).stream(s -> s). - expectedResult(exp).exercise(); - } + long size = start <= end ? end - start + 1: 0; + long[] exp = new long[(int) size]; + for (long i = start, p = 0; i <= end; i++, p++) { + exp[(int) p] = i; } + + long[] inc = LongStream.rangeClosed(start, end).toArray(); + assertEquals(inc.length, size); + assertTrue(Arrays.equals(exp, inc)); + + withData(longRangeClosedData(start, end)).stream(s -> s). + expectedResult(exp).exercise(); } } + + // Closed, maximum upper bound of Long.MAX_VALUE + { + long[] inc = LongStream.rangeClosed(Long.MAX_VALUE - 1, Long.MAX_VALUE).toArray(); + assertEquals(2, inc.length); + assertEquals(Long.MAX_VALUE - 1, inc[0]); + assertEquals(Long.MAX_VALUE, inc[1]); + + inc = LongStream.rangeClosed(Long.MAX_VALUE, Long.MAX_VALUE).toArray(); + assertEquals(1, inc.length); + assertEquals(Long.MAX_VALUE, inc[0]); + + SpliteratorTestHelper.testLongSpliterator( + () -> LongStream.rangeClosed(Long.MAX_VALUE - 8, Long.MAX_VALUE).spliterator()); + } } - TestData.OfLong longRangeData(long start, long end, long step) { - return TestData.Factory.ofLongSupplier("long range", () -> LongStream.range(start, end, step)); + TestData.OfLong longRangeData(long start, long end) { + return TestData.Factory.ofLongSupplier("long range", () -> LongStream.range(start, end)); + } + + TestData.OfLong longRangeClosedData(long start, long end) { + return TestData.Factory.ofLongSupplier("long rangeClosed", () -> LongStream.rangeClosed(start, end)); } public void testLongRangeReduce() { - withData(longRangeData(0, 10000, 1)). + withData(longRangeData(0, 10000)). terminal(s -> s.reduce(0, Long::sum)).exercise(); } @@ -219,64 +218,116 @@ public class RangeTest extends OpTestCase { assertEquals(first, LongStream.iterate(0, i -> i + 1).parallel().filter(i -> i > 10000).findFirst().getAsLong()); } - // - - private static int[] reverse(int[] a) { - int[] b = new int[a.length]; - for (int i = 0; i < a.length; i++) { - b[b.length - i - 1] = a[i]; - } - return b; - } - - private static long[] reverse(long[] a) { - long[] b = new long[a.length]; - for (int i = 0; i < a.length; i++) { - b[b.length - i - 1] = a[i]; - } - return b; - } - - private static double[] reverse(double[] a) { - double[] b = new double[a.length]; - for (int i = 0; i < a.length; i++) { - b[b.length - i - 1] = a[i]; - } - return b; - } - - private void executeAndCatch(Runnable r) { - executeAndCatch(IllegalArgumentException.class, r); - } - - private void executeAndNoCatch(Runnable r) { - executeAndCatch(null, r); - } - - private void executeAndCatch(Class expected, Runnable r) { - Exception caught = null; - try { - r.run(); - } - catch (Exception e) { - caught = e; - } - - if (expected != null) { - assertNotNull(caught, - String.format("No Exception was thrown, expected an Exception of %s to be thrown", - expected.getName())); - assertTrue(expected.isInstance(caught), - String.format("Exception thrown %s not an instance of %s", - caught.getClass().getName(), expected.getName())); - } - else { - if (caught != null) { - assertNull(caught, - String.format("Unexpected exception of %s was thrown", - caught.getClass().getName())); - } - } - } - + // Enable when Stream.concat is present and range implementations are + // updated to use that +// private static void assertSizedAndSubSized(Spliterator s) { +// assertTrue(s.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); +// } +// +// private static void assertNotSizedAndSubSized(Spliterator s) { +// assertFalse(s.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); +// } +// +// public void testLongLongRange() { +// // Test [Long.MIN_VALUE, Long.MAX_VALUE) +// // This will concatenate streams of three ranges +// // [Long.MIN_VALUE, x) [x, 0) [0, Long.MAX_VALUE) +// // where x = Long.divideUnsigned(0 - Long.MIN_VALUE, 2) + 1 +// { +// Spliterator.OfLong s = LongStream.range(Long.MIN_VALUE, Long.MAX_VALUE).spliterator(); +// +// assertEquals(s.estimateSize(), Long.MAX_VALUE); +// assertNotSizedAndSubSized(s); +// +// Spliterator.OfLong s1 = s.trySplit(); +// assertNotSizedAndSubSized(s1); +// assertSizedAndSubSized(s); +// +// Spliterator.OfLong s2 = s1.trySplit(); +// assertSizedAndSubSized(s1); +// assertSizedAndSubSized(s2); +// +// assertTrue(s.estimateSize() == Long.MAX_VALUE); +// assertTrue(s1.estimateSize() < Long.MAX_VALUE); +// assertTrue(s2.estimateSize() < Long.MAX_VALUE); +// +// assertEquals(s.estimateSize() + s1.estimateSize() + s2.estimateSize(), +// Long.MAX_VALUE - Long.MIN_VALUE); +// } +// +// long[][] ranges = { {Long.MIN_VALUE, 0}, {-1, Long.MAX_VALUE} }; +// for (int i = 0; i < ranges.length; i++) { +// long start = ranges[i][0]; +// long end = ranges[i][1]; +// +// Spliterator.OfLong s = LongStream.range(start, end).spliterator(); +// +// assertEquals(s.estimateSize(), Long.MAX_VALUE); +// assertNotSizedAndSubSized(s); +// +// Spliterator.OfLong s1 = s.trySplit(); +// assertSizedAndSubSized(s1); +// assertSizedAndSubSized(s); +// +// assertTrue(s.estimateSize() < Long.MAX_VALUE); +// assertTrue(s1.estimateSize() < Long.MAX_VALUE); +// +// assertEquals(s.estimateSize() + s1.estimateSize(), end - start); +// } +// } +// +// public void testLongLongRangeClosed() { +// // Test [Long.MIN_VALUE, Long.MAX_VALUE] +// // This will concatenate streams of four ranges +// // [Long.MIN_VALUE, x) [x, 0) [0, y) [y, Long.MAX_VALUE] +// // where x = Long.divideUnsigned(0 - Long.MIN_VALUE, 2) + 1 +// // y = Long.divideUnsigned(Long.MAX_VALUE, 2) + 1 +// +// { +// Spliterator.OfLong s = LongStream.rangeClosed(Long.MIN_VALUE, Long.MAX_VALUE).spliterator(); +// +// assertEquals(s.estimateSize(), Long.MAX_VALUE); +// assertNotSizedAndSubSized(s); +// +// Spliterator.OfLong s1 = s.trySplit(); +// assertNotSizedAndSubSized(s1); +// assertNotSizedAndSubSized(s); +// +// Spliterator.OfLong s2 = s1.trySplit(); +// assertSizedAndSubSized(s1); +// assertSizedAndSubSized(s2); +// +// Spliterator.OfLong s3 = s.trySplit(); +// assertSizedAndSubSized(s3); +// assertSizedAndSubSized(s); +// +// assertTrue(s.estimateSize() < Long.MAX_VALUE); +// assertTrue(s3.estimateSize() < Long.MAX_VALUE); +// assertTrue(s1.estimateSize() < Long.MAX_VALUE); +// assertTrue(s2.estimateSize() < Long.MAX_VALUE); +// +// assertEquals(s.estimateSize() + s3.estimateSize() + s1.estimateSize() + s2.estimateSize(), +// Long.MAX_VALUE - Long.MIN_VALUE + 1); +// } +// +// long[][] ranges = { {Long.MIN_VALUE, 0}, {-1, Long.MAX_VALUE} }; +// for (int i = 0; i < ranges.length; i++) { +// long start = ranges[i][0]; +// long end = ranges[i][1]; +// +// Spliterator.OfLong s = LongStream.rangeClosed(start, end).spliterator(); +// +// assertEquals(s.estimateSize(), Long.MAX_VALUE); +// assertNotSizedAndSubSized(s); +// +// Spliterator.OfLong s1 = s.trySplit(); +// assertSizedAndSubSized(s1); +// assertSizedAndSubSized(s); +// +// assertTrue(s.estimateSize() < Long.MAX_VALUE); +// assertTrue(s1.estimateSize() < Long.MAX_VALUE); +// +// assertEquals(s.estimateSize() + s1.estimateSize(), end - start + 1); +// } +// } } From 096a439d068d805be48c2756ab781b9a0e73c158 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Tue, 11 Jun 2013 11:22:28 +0100 Subject: [PATCH 184/206] 7059085: Retire Thread.stop(Throwable) so that it throws UOE Reviewed-by: dholmes, chegar, forax, darcy, mduigou --- jdk/src/share/classes/java/lang/Thread.java | 81 +++++--------------- jdk/test/java/lang/Thread/StopThrowable.java | 69 +++++++++++++++++ 2 files changed, 90 insertions(+), 60 deletions(-) create mode 100644 jdk/test/java/lang/Thread/StopThrowable.java diff --git a/jdk/src/share/classes/java/lang/Thread.java b/jdk/src/share/classes/java/lang/Thread.java index 81bebc58b21..bb175ff89ad 100644 --- a/jdk/src/share/classes/java/lang/Thread.java +++ b/jdk/src/share/classes/java/lang/Thread.java @@ -812,68 +812,10 @@ class Thread implements Runnable { */ @Deprecated public final void stop() { - stop(new ThreadDeath()); - } - - /** - * Forces the thread to stop executing. - *

    - * If there is a security manager installed, the checkAccess - * method of this thread is called, which may result in a - * SecurityException being raised (in the current thread). - *

    - * If this thread is different from the current thread (that is, the current - * thread is trying to stop a thread other than itself) or - * obj is not an instance of ThreadDeath, the - * security manager's checkPermission method (with the - * RuntimePermission("stopThread") argument) is called in - * addition. - * Again, this may result in throwing a - * SecurityException (in the current thread). - *

    - * If the argument obj is null, a - * NullPointerException is thrown (in the current thread). - *

    - * The thread represented by this thread is forced to stop - * whatever it is doing abnormally and to throw the - * Throwable object obj as an exception. This - * is an unusual action to take; normally, the stop method - * that takes no arguments should be used. - *

    - * It is permitted to stop a thread that has not yet been started. - * If the thread is eventually started, it immediately terminates. - * - * @param obj the Throwable object to be thrown. - * @exception SecurityException if the current thread cannot modify - * this thread. - * @throws NullPointerException if obj is null. - * @see #interrupt() - * @see #checkAccess() - * @see #run() - * @see #start() - * @see #stop() - * @see SecurityManager#checkAccess(Thread) - * @see SecurityManager#checkPermission - * @deprecated This method is inherently unsafe. See {@link #stop()} - * for details. An additional danger of this - * method is that it may be used to generate exceptions that the - * target thread is unprepared to handle (including checked - * exceptions that the thread could not possibly throw, were it - * not for this method). - * For more information, see - * Why - * are Thread.stop, Thread.suspend and Thread.resume Deprecated?. - */ - @Deprecated - public final synchronized void stop(Throwable obj) { - if (obj == null) - throw new NullPointerException(); - SecurityManager security = System.getSecurityManager(); if (security != null) { checkAccess(); - if ((this != Thread.currentThread()) || - (!(obj instanceof ThreadDeath))) { + if (this != Thread.currentThread()) { security.checkPermission(SecurityConstants.STOP_THREAD_PERMISSION); } } @@ -884,7 +826,26 @@ class Thread implements Runnable { } // The VM can handle all thread states - stop0(obj); + stop0(new ThreadDeath()); + } + + /** + * Throws {@code UnsupportedOperationException}. + * + * @param obj ignored + * + * @deprecated This method was originally designed to force a thread to stop + * and throw a given {@code Throwable} as an exception. It was + * inherently unsafe (see {@link #stop()} for details), and furthermore + * could be used to generate exceptions that the target thread was + * not prepared to handle. + * For more information, see + * Why + * are Thread.stop, Thread.suspend and Thread.resume Deprecated?. + */ + @Deprecated + public final synchronized void stop(Throwable obj) { + throw new UnsupportedOperationException(); } /** diff --git a/jdk/test/java/lang/Thread/StopThrowable.java b/jdk/test/java/lang/Thread/StopThrowable.java new file mode 100644 index 00000000000..edc3a8d50a8 --- /dev/null +++ b/jdk/test/java/lang/Thread/StopThrowable.java @@ -0,0 +1,69 @@ +/* + * 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 7059085 + * @summary Check that Thread.stop(Throwable) throws UOE + * @run testng StopThrowable + */ + +import org.testng.annotations.Test; + +import java.util.concurrent.CountDownLatch; + +public class StopThrowable { + + @Test(expectedExceptions=UnsupportedOperationException.class) + public void testStopSelf() { + Thread.currentThread().stop(new ThreadDeath()); + } + + private static void awaitUnchecked(CountDownLatch latch) { + try { + latch.await(); + } catch (InterruptedException e) { + // should not happen + throw new RuntimeException(e); + } + } + + @Test(expectedExceptions=UnsupportedOperationException.class) + public void testStopOther() throws Throwable { + CountDownLatch ready = new CountDownLatch(1); + CountDownLatch done = new CountDownLatch(1); + Thread t = new Thread( () -> { ready.countDown(); awaitUnchecked(done); } ); + t.start(); + try { + ready.await(); + t.stop(new ThreadDeath()); + } finally { + done.countDown(); + } + } + + @Test(expectedExceptions=UnsupportedOperationException.class) + public void testNull() { + Thread.currentThread().stop(null); + } +} From fadbd2146998aba256f7064180005dfdec496648 Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Tue, 11 Jun 2013 11:25:59 +0100 Subject: [PATCH 185/206] 8016311: Update j.u.c. tests to avoid using Thread.stop(Throwable) Reviewed-by: alanb --- .../concurrent/Executors/PrivilegedCallables.java | 11 ++++++++--- jdk/test/java/util/concurrent/FutureTask/Throw.java | 7 +++++-- .../concurrent/ThreadPoolExecutor/ThrowingTasks.java | 10 ++++++++-- .../java/util/concurrent/locks/Lock/FlakyMutex.java | 8 ++++++-- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/jdk/test/java/util/concurrent/Executors/PrivilegedCallables.java b/jdk/test/java/util/concurrent/Executors/PrivilegedCallables.java index a69041232f5..a77511e440d 100644 --- a/jdk/test/java/util/concurrent/Executors/PrivilegedCallables.java +++ b/jdk/test/java/util/concurrent/Executors/PrivilegedCallables.java @@ -43,7 +43,8 @@ public class PrivilegedCallables { final Random rnd = new Random(); - @SuppressWarnings("serial") Throwable[] throwables = { + @SuppressWarnings("serial") + Throwable[] throwables = { new Exception() {}, new RuntimeException() {}, new Error() {} @@ -51,6 +52,11 @@ public class PrivilegedCallables { Throwable randomThrowable() { return throwables[rnd.nextInt(throwables.length)]; } + void throwThrowable(Throwable t) throws Exception { + if (t instanceof Error) throw (Error) t; + if (t instanceof RuntimeException) throw (RuntimeException) t; + throw (Exception) t; + } //---------------------------------------------------------------- // A Policy class designed to make permissions fiddling very easy. @@ -119,9 +125,8 @@ public class PrivilegedCallables { if (rnd.nextBoolean()) { final Throwable t = randomThrowable(); real = new Callable() { - @SuppressWarnings("deprecation") public Integer call() throws Exception { - Thread.currentThread().stop(t); + throwThrowable(t); return null; }}; try { c.call(); diff --git a/jdk/test/java/util/concurrent/FutureTask/Throw.java b/jdk/test/java/util/concurrent/FutureTask/Throw.java index 4182cdf1a0c..7bc442728ad 100644 --- a/jdk/test/java/util/concurrent/FutureTask/Throw.java +++ b/jdk/test/java/util/concurrent/FutureTask/Throw.java @@ -31,10 +31,9 @@ import java.util.concurrent.*; public class Throw { - @SuppressWarnings("deprecation") static void THROW(final Throwable t) { if (t != null) - Thread.currentThread().stop(t); + Throw.uncheckedThrow(t); } Callable thrower(final Throwable t) { @@ -138,4 +137,8 @@ public class Throw { catch (Throwable t) { if (k.isAssignableFrom(t.getClass())) pass(); else unexpected(t);}} + @SuppressWarnings("unchecked") static + void uncheckedThrow(Throwable t) throws T { + throw (T)t; // rely on vacuous cast + } } diff --git a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java index 7699d180005..1394a4c38ed 100644 --- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java +++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java @@ -101,8 +101,10 @@ public class ThrowingTasks { static class Thrower implements Runnable { Throwable t; Thrower(Throwable t) { this.t = t; } - @SuppressWarnings("deprecation") - public void run() { if (t != null) Thread.currentThread().stop(t); } + public void run() { + if (t != null) + ThrowingTasks.uncheckedThrow(t); + } } static final Thrower noThrower = new Thrower(null); @@ -265,4 +267,8 @@ public class ThrowingTasks { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} + @SuppressWarnings("unchecked") static + void uncheckedThrow(Throwable t) throws T { + throw (T)t; // rely on vacuous cast + } } diff --git a/jdk/test/java/util/concurrent/locks/Lock/FlakyMutex.java b/jdk/test/java/util/concurrent/locks/Lock/FlakyMutex.java index e00cf4c612a..390f01d0f15 100644 --- a/jdk/test/java/util/concurrent/locks/Lock/FlakyMutex.java +++ b/jdk/test/java/util/concurrent/locks/Lock/FlakyMutex.java @@ -37,7 +37,7 @@ import java.util.concurrent.locks.*; * tryAcquire method that randomly throws various Throwable * subclasses. */ -@SuppressWarnings({"deprecation", "serial"}) +@SuppressWarnings("serial") public class FlakyMutex implements Lock { static class MyError extends Error {} static class MyException extends Exception {} @@ -49,7 +49,7 @@ public class FlakyMutex implements Lock { switch (rnd.nextInt(10)) { case 0: throw new MyError(); case 1: throw new MyRuntimeException(); - case 2: Thread.currentThread().stop(new MyException()); break; + case 2: FlakyMutex.uncheckedThrow(new MyException()); default: /* Do nothing */ break; } } @@ -146,4 +146,8 @@ public class FlakyMutex implements Lock { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} + @SuppressWarnings("unchecked") static + void uncheckedThrow(Throwable t) throws T { + throw (T)t; // rely on vacuous cast + } } From c6a5dcd8bfa946f279508f02ab2a48c3057753a4 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 11 Jun 2013 13:08:02 +0200 Subject: [PATCH 186/206] 8008707: build-infra: Closed (deploy) can't be built using environment from SDK SetEnv.cmd Reviewed-by: tbell --- common/autoconf/generated-configure.sh | 743 ++++++++++++------------- common/autoconf/toolchain_windows.m4 | 37 +- 2 files changed, 392 insertions(+), 388 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index b5e26db434a..e1198a5e4e3 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for OpenJDK jdk8. +# Generated by GNU Autoconf 2.67 for OpenJDK jdk8. # # Report bugs to . # @@ -91,7 +91,6 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -217,18 +216,11 @@ IFS=$as_save_IFS # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -1468,7 +1460,7 @@ Try \`$0 --help' for more information" $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac @@ -1904,7 +1896,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF OpenJDK configure jdk8 -generated by GNU Autoconf 2.68 +generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation @@ -1950,7 +1942,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1988,7 +1980,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile @@ -2026,7 +2018,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_objc_try_compile @@ -2063,7 +2055,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -2100,7 +2092,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp @@ -2113,10 +2105,10 @@ fi ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : + if eval "test \"\${$3+set}\"" = set; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 @@ -2183,7 +2175,7 @@ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" @@ -2192,7 +2184,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_header_mongrel @@ -2233,7 +2225,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_run @@ -2247,7 +2239,7 @@ ac_fn_cxx_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2265,7 +2257,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_header_compile @@ -2442,7 +2434,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ rm -f conftest.val fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_compute_int @@ -2488,7 +2480,7 @@ fi # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_link @@ -2501,7 +2493,7 @@ ac_fn_cxx_check_func () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2556,7 +2548,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_func @@ -2569,7 +2561,7 @@ ac_fn_c_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2587,7 +2579,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_compile cat >config.log <<_ACEOF @@ -2595,7 +2587,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -2853,7 +2845,7 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;} || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi done @@ -3790,7 +3782,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1370470729 +DATE_WHEN_GENERATED=1370948811 ############################################################################### # @@ -3828,7 +3820,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BASENAME+:} false; then : +if test "${ac_cv_path_BASENAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BASENAME in @@ -3887,7 +3879,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BASH+:} false; then : +if test "${ac_cv_path_BASH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BASH in @@ -3946,7 +3938,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CAT+:} false; then : +if test "${ac_cv_path_CAT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CAT in @@ -4005,7 +3997,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHMOD+:} false; then : +if test "${ac_cv_path_CHMOD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHMOD in @@ -4064,7 +4056,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CMP+:} false; then : +if test "${ac_cv_path_CMP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CMP in @@ -4123,7 +4115,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_COMM+:} false; then : +if test "${ac_cv_path_COMM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $COMM in @@ -4182,7 +4174,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CP+:} false; then : +if test "${ac_cv_path_CP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CP in @@ -4241,7 +4233,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CPIO+:} false; then : +if test "${ac_cv_path_CPIO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CPIO in @@ -4300,7 +4292,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CUT+:} false; then : +if test "${ac_cv_path_CUT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CUT in @@ -4359,7 +4351,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DATE+:} false; then : +if test "${ac_cv_path_DATE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DATE in @@ -4418,7 +4410,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DIFF+:} false; then : +if test "${ac_cv_path_DIFF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DIFF in @@ -4477,7 +4469,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DIRNAME+:} false; then : +if test "${ac_cv_path_DIRNAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DIRNAME in @@ -4536,7 +4528,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ECHO+:} false; then : +if test "${ac_cv_path_ECHO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ECHO in @@ -4595,7 +4587,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_EXPR+:} false; then : +if test "${ac_cv_path_EXPR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $EXPR in @@ -4654,7 +4646,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_FILE+:} false; then : +if test "${ac_cv_path_FILE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $FILE in @@ -4713,7 +4705,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_FIND+:} false; then : +if test "${ac_cv_path_FIND+set}" = set; then : $as_echo_n "(cached) " >&6 else case $FIND in @@ -4772,7 +4764,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_HEAD+:} false; then : +if test "${ac_cv_path_HEAD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $HEAD in @@ -4831,7 +4823,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LN+:} false; then : +if test "${ac_cv_path_LN+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LN in @@ -4890,7 +4882,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LS+:} false; then : +if test "${ac_cv_path_LS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LS in @@ -4949,7 +4941,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MKDIR+:} false; then : +if test "${ac_cv_path_MKDIR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MKDIR in @@ -5008,7 +5000,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MKTEMP+:} false; then : +if test "${ac_cv_path_MKTEMP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MKTEMP in @@ -5067,7 +5059,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MV+:} false; then : +if test "${ac_cv_path_MV+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MV in @@ -5126,7 +5118,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PRINTF+:} false; then : +if test "${ac_cv_path_PRINTF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PRINTF in @@ -5185,7 +5177,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_RM+:} false; then : +if test "${ac_cv_path_RM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $RM in @@ -5244,7 +5236,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SH+:} false; then : +if test "${ac_cv_path_SH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SH in @@ -5303,7 +5295,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SORT+:} false; then : +if test "${ac_cv_path_SORT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SORT in @@ -5362,7 +5354,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TAIL+:} false; then : +if test "${ac_cv_path_TAIL+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TAIL in @@ -5421,7 +5413,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TAR+:} false; then : +if test "${ac_cv_path_TAR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TAR in @@ -5480,7 +5472,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TEE+:} false; then : +if test "${ac_cv_path_TEE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TEE in @@ -5539,7 +5531,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TOUCH+:} false; then : +if test "${ac_cv_path_TOUCH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TOUCH in @@ -5598,7 +5590,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TR+:} false; then : +if test "${ac_cv_path_TR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TR in @@ -5657,7 +5649,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_UNAME+:} false; then : +if test "${ac_cv_path_UNAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNAME in @@ -5716,7 +5708,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_UNIQ+:} false; then : +if test "${ac_cv_path_UNIQ+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNIQ in @@ -5775,7 +5767,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_WC+:} false; then : +if test "${ac_cv_path_WC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $WC in @@ -5834,7 +5826,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_WHICH+:} false; then : +if test "${ac_cv_path_WHICH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $WHICH in @@ -5893,7 +5885,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_XARGS+:} false; then : +if test "${ac_cv_path_XARGS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $XARGS in @@ -5953,7 +5945,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AWK+:} false; then : +if test "${ac_cv_prog_AWK+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -6003,7 +5995,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : +if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -6078,7 +6070,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : +if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -6157,7 +6149,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } -if ${ac_cv_path_FGREP+:} false; then : +if test "${ac_cv_path_FGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 @@ -6236,7 +6228,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } -if ${ac_cv_path_SED+:} false; then : +if test "${ac_cv_path_SED+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ @@ -6322,7 +6314,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_NAWK+:} false; then : +if test "${ac_cv_path_NAWK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $NAWK in @@ -6386,7 +6378,7 @@ THEPWDCMD=pwd set dummy cygpath; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CYGPATH+:} false; then : +if test "${ac_cv_path_CYGPATH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CYGPATH in @@ -6426,7 +6418,7 @@ fi set dummy readlink; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_READLINK+:} false; then : +if test "${ac_cv_path_READLINK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $READLINK in @@ -6466,7 +6458,7 @@ fi set dummy df; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DF+:} false; then : +if test "${ac_cv_path_DF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DF in @@ -6506,7 +6498,7 @@ fi set dummy SetFile; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SETFILE+:} false; then : +if test "${ac_cv_path_SETFILE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SETFILE in @@ -6552,7 +6544,7 @@ $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : +if test "${ac_cv_build+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias @@ -6568,7 +6560,7 @@ fi $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -6586,7 +6578,7 @@ case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : +if test "${ac_cv_host+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then @@ -6601,7 +6593,7 @@ fi $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -6619,7 +6611,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } -if ${ac_cv_target+:} false; then : +if test "${ac_cv_target+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then @@ -6634,7 +6626,7 @@ fi $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5 ;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' @@ -8031,7 +8023,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PKGHANDLER+:} false; then : +if test "${ac_cv_prog_PKGHANDLER+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PKGHANDLER"; then @@ -8396,7 +8388,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_GMAKE+:} false; then : +if test "${ac_cv_path_CHECK_GMAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_GMAKE in @@ -8750,7 +8742,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_MAKE+:} false; then : +if test "${ac_cv_path_CHECK_MAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_MAKE in @@ -9109,7 +9101,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_TOOLSDIR_GMAKE+:} false; then : +if test "${ac_cv_path_CHECK_TOOLSDIR_GMAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_GMAKE in @@ -9462,7 +9454,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_TOOLSDIR_MAKE+:} false; then : +if test "${ac_cv_path_CHECK_TOOLSDIR_MAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_MAKE in @@ -9858,7 +9850,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_UNZIP+:} false; then : +if test "${ac_cv_path_UNZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNZIP in @@ -9917,7 +9909,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ZIP+:} false; then : +if test "${ac_cv_path_ZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ZIP in @@ -9976,7 +9968,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} set dummy ldd; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LDD+:} false; then : +if test "${ac_cv_path_LDD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LDD in @@ -10022,7 +10014,7 @@ fi set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_OTOOL+:} false; then : +if test "${ac_cv_path_OTOOL+set}" = set; then : $as_echo_n "(cached) " >&6 else case $OTOOL in @@ -10067,7 +10059,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_READELF+:} false; then : +if test "${ac_cv_path_READELF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $READELF in @@ -10110,7 +10102,7 @@ done set dummy hg; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_HG+:} false; then : +if test "${ac_cv_path_HG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $HG in @@ -10150,7 +10142,7 @@ fi set dummy stat; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_STAT+:} false; then : +if test "${ac_cv_path_STAT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $STAT in @@ -10190,7 +10182,7 @@ fi set dummy time; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TIME+:} false; then : +if test "${ac_cv_path_TIME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TIME in @@ -10235,7 +10227,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_COMM+:} false; then : +if test "${ac_cv_path_COMM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $COMM in @@ -10297,7 +10289,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_XATTR+:} false; then : +if test "${ac_cv_path_XATTR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $XATTR in @@ -10353,7 +10345,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} set dummy codesign; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CODESIGN+:} false; then : +if test "${ac_cv_path_CODESIGN+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CODESIGN in @@ -10417,7 +10409,7 @@ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PKG_CONFIG+:} false; then : +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -10460,7 +10452,7 @@ if test -z "$ac_cv_path_PKG_CONFIG"; then set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : +if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in @@ -10633,7 +10625,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_BDEPS_UNZIP+:} false; then : +if test "${ac_cv_prog_BDEPS_UNZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_UNZIP"; then @@ -10679,7 +10671,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_BDEPS_FTP+:} false; then : +if test "${ac_cv_prog_BDEPS_FTP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_FTP"; then @@ -11979,7 +11971,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } set dummy javac; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_JAVAC_CHECK+:} false; then : +if test "${ac_cv_path_JAVAC_CHECK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $JAVAC_CHECK in @@ -12019,7 +12011,7 @@ fi set dummy java; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_JAVA_CHECK+:} false; then : +if test "${ac_cv_path_JAVA_CHECK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $JAVA_CHECK in @@ -16348,7 +16340,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_JTREGEXE+:} false; then : +if test "${ac_cv_path_JTREGEXE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $JTREGEXE in @@ -16416,7 +16408,7 @@ if test "x$OPENJDK_TARGET_OS" = "xwindows"; then set dummy link; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CYGWIN_LINK+:} false; then : +if test "${ac_cv_path_CYGWIN_LINK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CYGWIN_LINK in @@ -16518,6 +16510,123 @@ $as_echo "$as_me: Please point to the VC/bin directory within the Visual Studio as_fn_error $? "Cannot locate a valid Visual Studio installation" "$LINENO" 5 fi + if test "x$VS100COMNTOOLS" != x; then + + if test "x$VS_ENV_CMD" = x; then + VS100BASE="$VS100COMNTOOLS/../.." + METHOD="VS100COMNTOOLS variable" + + windows_path="$VS100BASE" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + VS100BASE="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + VS100BASE="$unix_path" + fi + + if test -d "$VS100BASE"; then + if test -f "$VS100BASE/$VCVARSFILE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 +$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} + VS_ENV_CMD="$VS100BASE/$VCVARSFILE" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 +$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 +$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} + fi + fi + fi + + fi + if test "x$PROGRAMFILES" != x; then + + if test "x$VS_ENV_CMD" = x; then + VS100BASE="$PROGRAMFILES/Microsoft Visual Studio 10.0" + METHOD="well-known name" + + windows_path="$VS100BASE" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + VS100BASE="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + VS100BASE="$unix_path" + fi + + if test -d "$VS100BASE"; then + if test -f "$VS100BASE/$VCVARSFILE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 +$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} + VS_ENV_CMD="$VS100BASE/$VCVARSFILE" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 +$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 +$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} + fi + fi + fi + + fi + + if test "x$VS_ENV_CMD" = x; then + VS100BASE="C:/Program Files/Microsoft Visual Studio 10.0" + METHOD="well-known name" + + windows_path="$VS100BASE" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + VS100BASE="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + VS100BASE="$unix_path" + fi + + if test -d "$VS100BASE"; then + if test -f "$VS100BASE/$VCVARSFILE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 +$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} + VS_ENV_CMD="$VS100BASE/$VCVARSFILE" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 +$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 +$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} + fi + fi + fi + + + if test "x$VS_ENV_CMD" = x; then + VS100BASE="C:/Program Files (x86)/Microsoft Visual Studio 10.0" + METHOD="well-known name" + + windows_path="$VS100BASE" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + VS100BASE="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + VS100BASE="$unix_path" + fi + + if test -d "$VS100BASE"; then + if test -f "$VS100BASE/$VCVARSFILE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 +$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} + VS_ENV_CMD="$VS100BASE/$VCVARSFILE" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 +$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 +$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} + fi + fi + fi + + if test "x$ProgramW6432" != x; then if test "x$VS_ENV_CMD" = x; then @@ -16725,123 +16834,6 @@ $as_echo "$as_me: Warning: Installation is broken, SetEnv.Cmd is missing. Ignori fi - if test "x$VS100COMNTOOLS" != x; then - - if test "x$VS_ENV_CMD" = x; then - VS100BASE="$VS100COMNTOOLS/../.." - METHOD="VS100COMNTOOLS variable" - - windows_path="$VS100BASE" - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - unix_path=`$CYGPATH -u "$windows_path"` - VS100BASE="$unix_path" - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` - VS100BASE="$unix_path" - fi - - if test -d "$VS100BASE"; then - if test -f "$VS100BASE/$VCVARSFILE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} - VS_ENV_CMD="$VS100BASE/$VCVARSFILE" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 -$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} - fi - fi - fi - - fi - if test "x$PROGRAMFILES" != x; then - - if test "x$VS_ENV_CMD" = x; then - VS100BASE="$PROGRAMFILES/Microsoft Visual Studio 10.0" - METHOD="well-known name" - - windows_path="$VS100BASE" - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - unix_path=`$CYGPATH -u "$windows_path"` - VS100BASE="$unix_path" - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` - VS100BASE="$unix_path" - fi - - if test -d "$VS100BASE"; then - if test -f "$VS100BASE/$VCVARSFILE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} - VS_ENV_CMD="$VS100BASE/$VCVARSFILE" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 -$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} - fi - fi - fi - - fi - - if test "x$VS_ENV_CMD" = x; then - VS100BASE="C:/Program Files/Microsoft Visual Studio 10.0" - METHOD="well-known name" - - windows_path="$VS100BASE" - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - unix_path=`$CYGPATH -u "$windows_path"` - VS100BASE="$unix_path" - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` - VS100BASE="$unix_path" - fi - - if test -d "$VS100BASE"; then - if test -f "$VS100BASE/$VCVARSFILE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} - VS_ENV_CMD="$VS100BASE/$VCVARSFILE" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 -$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} - fi - fi - fi - - - if test "x$VS_ENV_CMD" = x; then - VS100BASE="C:/Program Files (x86)/Microsoft Visual Studio 10.0" - METHOD="well-known name" - - windows_path="$VS100BASE" - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - unix_path=`$CYGPATH -u "$windows_path"` - VS100BASE="$unix_path" - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` - VS100BASE="$unix_path" - fi - - if test -d "$VS100BASE"; then - if test -f "$VS100BASE/$VCVARSFILE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} - VS_ENV_CMD="$VS100BASE/$VCVARSFILE" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 -$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} - fi - fi - fi - - if test "x$VS_ENV_CMD" != x; then # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file. @@ -17243,11 +17235,25 @@ $as_echo "$as_me: msvcr100.dll found in VCINSTALLDIR: $VCINSTALLDIR" >&6;} $as_echo "$as_me: Warning: msvcr100.dll not found in VCINSTALLDIR: $VCINSTALLDIR" >&6;} fi fi + # Try some fallback alternatives if test "x$MSVCR_DLL" = x; then - if test -f "$SYSTEMROOT/system32/msvcr100.dll"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: msvcr100.dll found in $SYSTEMROOT/system32" >&5 + # If visual studio express is installed, there is usually one with the debugger + if test "x$VS100COMNTOOLS" != x; then + if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then + MSVCR_DLL=`find "$VS100COMNTOOLS/.." -name msvcr100.dll | grep -i x64 | head --lines 1` + { $as_echo "$as_me:${as_lineno-$LINENO}: msvcr100.dll found in $VS100COMNTOOLS..: $VS100COMNTOOLS.." >&5 +$as_echo "$as_me: msvcr100.dll found in $VS100COMNTOOLS..: $VS100COMNTOOLS.." >&6;} + fi + fi + fi + if test "x$MSVCR_DLL" = x; then + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + # Fallback for 32bit builds, look in the windows directory. + if test -f "$SYSTEMROOT/system32/msvcr100.dll"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: msvcr100.dll found in $SYSTEMROOT/system32" >&5 $as_echo "$as_me: msvcr100.dll found in $SYSTEMROOT/system32" >&6;} - MSVCR_DLL="$SYSTEMROOT/system32/msvcr100.dll" + MSVCR_DLL="$SYSTEMROOT/system32/msvcr100.dll" + fi fi fi fi @@ -17843,7 +17849,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BUILD_CC+:} false; then : +if test "${ac_cv_path_BUILD_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_CC in @@ -18154,7 +18160,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BUILD_CXX+:} false; then : +if test "${ac_cv_path_BUILD_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_CXX in @@ -18463,7 +18469,7 @@ $as_echo "$as_me: Rewriting BUILD_CXX to \"$new_complete\"" >&6;} set dummy ld; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BUILD_LD+:} false; then : +if test "${ac_cv_path_BUILD_LD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_LD in @@ -18979,7 +18985,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TOOLS_DIR_CC+:} false; then : +if test "${ac_cv_path_TOOLS_DIR_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TOOLS_DIR_CC in @@ -19031,7 +19037,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_POTENTIAL_CC+:} false; then : +if test "${ac_cv_path_POTENTIAL_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CC in @@ -19444,7 +19450,7 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PROPER_COMPILER_CC+:} false; then : +if test "${ac_cv_prog_PROPER_COMPILER_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CC"; then @@ -19488,7 +19494,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+:} false; then : +if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CC"; then @@ -19938,7 +19944,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -19982,7 +19988,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -20035,7 +20041,7 @@ fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -20150,7 +20156,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -20193,7 +20199,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -20252,7 +20258,7 @@ $as_echo "$ac_try_echo"; } >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi fi fi @@ -20263,7 +20269,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : +if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -20304,7 +20310,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -20314,7 +20320,7 @@ OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : +if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -20351,7 +20357,7 @@ ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : +if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -20429,7 +20435,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : +if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -20552,7 +20558,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TOOLS_DIR_CXX+:} false; then : +if test "${ac_cv_path_TOOLS_DIR_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TOOLS_DIR_CXX in @@ -20604,7 +20610,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_POTENTIAL_CXX+:} false; then : +if test "${ac_cv_path_POTENTIAL_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CXX in @@ -21017,7 +21023,7 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PROPER_COMPILER_CXX+:} false; then : +if test "${ac_cv_prog_PROPER_COMPILER_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CXX"; then @@ -21061,7 +21067,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+:} false; then : +if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CXX"; then @@ -21515,7 +21521,7 @@ if test -z "$CXX"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CXX+:} false; then : +if test "${ac_cv_prog_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then @@ -21559,7 +21565,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CXX+:} false; then : +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then @@ -21637,7 +21643,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if ${ac_cv_cxx_compiler_gnu+:} false; then : +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21674,7 +21680,7 @@ ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } -if ${ac_cv_prog_cxx_g+:} false; then : +if test "${ac_cv_prog_cxx_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag @@ -21772,7 +21778,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJC+:} false; then : +if test "${ac_cv_prog_OBJC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJC"; then @@ -21816,7 +21822,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJC+:} false; then : +if test "${ac_cv_prog_ac_ct_OBJC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJC"; then @@ -21892,7 +21898,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Objective C compiler" >&5 $as_echo_n "checking whether we are using the GNU Objective C compiler... " >&6; } -if ${ac_cv_objc_compiler_gnu+:} false; then : +if test "${ac_cv_objc_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21929,7 +21935,7 @@ ac_test_OBJCFLAGS=${OBJCFLAGS+set} ac_save_OBJCFLAGS=$OBJCFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $OBJC accepts -g" >&5 $as_echo_n "checking whether $OBJC accepts -g... " >&6; } -if ${ac_cv_prog_objc_g+:} false; then : +if test "${ac_cv_prog_objc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_objc_werror_flag=$ac_objc_werror_flag @@ -22305,7 +22311,7 @@ if test "x$OPENJDK_TARGET_OS" != xwindows; then set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : +if test "${ac_cv_prog_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then @@ -22345,7 +22351,7 @@ if test -z "$ac_cv_prog_AR"; then set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then @@ -22687,7 +22693,7 @@ if test "x$OPENJDK_TARGET_OS" = xwindows; then : set dummy link; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_WINLD+:} false; then : +if test "${ac_cv_prog_WINLD+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$WINLD"; then @@ -23026,7 +23032,7 @@ $as_echo "yes" >&6; } set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_MT+:} false; then : +if test "${ac_cv_prog_MT+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$MT"; then @@ -23347,7 +23353,7 @@ $as_echo "$as_me: Rewriting MT to \"$new_complete\"" >&6;} set dummy rc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RC+:} false; then : +if test "${ac_cv_prog_RC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$RC"; then @@ -23738,7 +23744,7 @@ fi set dummy lib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_WINAR+:} false; then : +if test "${ac_cv_prog_WINAR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$WINAR"; then @@ -24044,7 +24050,7 @@ $as_echo "$as_me: Rewriting WINAR to \"$new_complete\"" >&6;} set dummy dumpbin; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DUMPBIN+:} false; then : +if test "${ac_cv_prog_DUMPBIN+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then @@ -24363,7 +24369,7 @@ if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : + if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -24479,7 +24485,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=cpp @@ -24763,7 +24769,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then - if ${ac_cv_prog_CXXCPP+:} false; then : + if test "${ac_cv_prog_CXXCPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded @@ -24879,7 +24885,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=cpp @@ -25181,7 +25187,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris; then set dummy as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_AS+:} false; then : +if test "${ac_cv_path_AS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $AS in @@ -25493,7 +25499,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris; then set dummy nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_NM+:} false; then : +if test "${ac_cv_path_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $NM in @@ -25799,7 +25805,7 @@ $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} set dummy gnm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_GNM+:} false; then : +if test "${ac_cv_path_GNM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $GNM in @@ -26105,7 +26111,7 @@ $as_echo "$as_me: Rewriting GNM to \"$new_complete\"" >&6;} set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_STRIP+:} false; then : +if test "${ac_cv_path_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $STRIP in @@ -26411,7 +26417,7 @@ $as_echo "$as_me: Rewriting STRIP to \"$new_complete\"" >&6;} set dummy mcs; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MCS+:} false; then : +if test "${ac_cv_path_MCS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MCS in @@ -26719,7 +26725,7 @@ elif test "x$OPENJDK_TARGET_OS" != xwindows; then set dummy ${ac_tool_prefix}nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_NM+:} false; then : +if test "${ac_cv_prog_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then @@ -26759,7 +26765,7 @@ if test -z "$ac_cv_prog_NM"; then set dummy nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_NM+:} false; then : +if test "${ac_cv_prog_ac_ct_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NM"; then @@ -27079,7 +27085,7 @@ $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : +if test "${ac_cv_prog_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -27119,7 +27125,7 @@ if test -z "$ac_cv_prog_STRIP"; then set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -27444,7 +27450,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJCOPY+:} false; then : +if test "${ac_cv_prog_OBJCOPY+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJCOPY"; then @@ -27488,7 +27494,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJCOPY+:} false; then : +if test "${ac_cv_prog_ac_ct_OBJCOPY+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJCOPY"; then @@ -27815,7 +27821,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJDUMP+:} false; then : +if test "${ac_cv_prog_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then @@ -27859,7 +27865,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : +if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then @@ -28183,7 +28189,7 @@ if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LIPO+:} false; then : +if test "${ac_cv_path_LIPO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LIPO in @@ -28500,7 +28506,7 @@ PATH="$OLD_PATH" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : +if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -28677,7 +28683,7 @@ fi for ac_header in stdio.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "stdio.h" "ac_cv_header_stdio_h" "$ac_includes_default" -if test "x$ac_cv_header_stdio_h" = xyes; then : +if test "x$ac_cv_header_stdio_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDIO_H 1 _ACEOF @@ -28706,7 +28712,7 @@ done # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5 $as_echo_n "checking size of int *... " >&6; } -if ${ac_cv_sizeof_int_p+:} false; then : +if test "${ac_cv_sizeof_int_p+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (int *))" "ac_cv_sizeof_int_p" "$ac_includes_default"; then : @@ -28716,7 +28722,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int *) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_int_p=0 fi @@ -28763,7 +28769,7 @@ $as_echo "$OPENJDK_TARGET_CPU_BITS bits" >&6; } # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if ${ac_cv_c_bigendian+:} false; then : +if test "${ac_cv_c_bigendian+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown @@ -29930,8 +29936,8 @@ if test "x$with_x" = xno; then have_x=disabled else case $x_includes,$x_libraries in #( - *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #( - *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then : + *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5 ;; #( + *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then : $as_echo_n "(cached) " >&6 else # One or both of the vars are not set, and there is no cached value. @@ -30208,7 +30214,7 @@ if ac_fn_cxx_try_link "$LINENO"; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet... " >&6; } -if ${ac_cv_lib_dnet_dnet_ntoa+:} false; then : +if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30242,14 +30248,14 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_dnet_ntoa" = xyes; then : +if test "x$ac_cv_lib_dnet_dnet_ntoa" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet_stub" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet_stub... " >&6; } -if ${ac_cv_lib_dnet_stub_dnet_ntoa+:} false; then : +if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30283,7 +30289,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = xyes; then : +if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" fi @@ -30302,14 +30308,14 @@ rm -f core conftest.err conftest.$ac_objext \ # The functions gethostbyname, getservbyname, and inet_addr are # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. ac_fn_cxx_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" -if test "x$ac_cv_func_gethostbyname" = xyes; then : +if test "x$ac_cv_func_gethostbyname" = x""yes; then : fi if test $ac_cv_func_gethostbyname = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 $as_echo_n "checking for gethostbyname in -lnsl... " >&6; } -if ${ac_cv_lib_nsl_gethostbyname+:} false; then : +if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30343,14 +30349,14 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 $as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } -if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : +if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" fi if test $ac_cv_lib_nsl_gethostbyname = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lbsd" >&5 $as_echo_n "checking for gethostbyname in -lbsd... " >&6; } -if ${ac_cv_lib_bsd_gethostbyname+:} false; then : +if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30384,7 +30390,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_gethostbyname" >&5 $as_echo "$ac_cv_lib_bsd_gethostbyname" >&6; } -if test "x$ac_cv_lib_bsd_gethostbyname" = xyes; then : +if test "x$ac_cv_lib_bsd_gethostbyname" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" fi @@ -30399,14 +30405,14 @@ fi # must be given before -lnsl if both are needed. We assume that # if connect needs -lnsl, so does gethostbyname. ac_fn_cxx_check_func "$LINENO" "connect" "ac_cv_func_connect" -if test "x$ac_cv_func_connect" = xyes; then : +if test "x$ac_cv_func_connect" = x""yes; then : fi if test $ac_cv_func_connect = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 $as_echo_n "checking for connect in -lsocket... " >&6; } -if ${ac_cv_lib_socket_connect+:} false; then : +if test "${ac_cv_lib_socket_connect+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30440,7 +30446,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 $as_echo "$ac_cv_lib_socket_connect" >&6; } -if test "x$ac_cv_lib_socket_connect" = xyes; then : +if test "x$ac_cv_lib_socket_connect" = x""yes; then : X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" fi @@ -30448,14 +30454,14 @@ fi # Guillermo Gomez says -lposix is necessary on A/UX. ac_fn_cxx_check_func "$LINENO" "remove" "ac_cv_func_remove" -if test "x$ac_cv_func_remove" = xyes; then : +if test "x$ac_cv_func_remove" = x""yes; then : fi if test $ac_cv_func_remove = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for remove in -lposix" >&5 $as_echo_n "checking for remove in -lposix... " >&6; } -if ${ac_cv_lib_posix_remove+:} false; then : +if test "${ac_cv_lib_posix_remove+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30489,7 +30495,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix_remove" >&5 $as_echo "$ac_cv_lib_posix_remove" >&6; } -if test "x$ac_cv_lib_posix_remove" = xyes; then : +if test "x$ac_cv_lib_posix_remove" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" fi @@ -30497,14 +30503,14 @@ fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. ac_fn_cxx_check_func "$LINENO" "shmat" "ac_cv_func_shmat" -if test "x$ac_cv_func_shmat" = xyes; then : +if test "x$ac_cv_func_shmat" = x""yes; then : fi if test $ac_cv_func_shmat = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shmat in -lipc" >&5 $as_echo_n "checking for shmat in -lipc... " >&6; } -if ${ac_cv_lib_ipc_shmat+:} false; then : +if test "${ac_cv_lib_ipc_shmat+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30538,7 +30544,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ipc_shmat" >&5 $as_echo "$ac_cv_lib_ipc_shmat" >&6; } -if test "x$ac_cv_lib_ipc_shmat" = xyes; then : +if test "x$ac_cv_lib_ipc_shmat" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" fi @@ -30556,7 +30562,7 @@ fi # John Interrante, Karl Berry { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IceConnectionNumber in -lICE" >&5 $as_echo_n "checking for IceConnectionNumber in -lICE... " >&6; } -if ${ac_cv_lib_ICE_IceConnectionNumber+:} false; then : +if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30590,7 +30596,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 $as_echo "$ac_cv_lib_ICE_IceConnectionNumber" >&6; } -if test "x$ac_cv_lib_ICE_IceConnectionNumber" = xyes; then : +if test "x$ac_cv_lib_ICE_IceConnectionNumber" = x""yes; then : X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" fi @@ -31609,7 +31615,7 @@ $as_echo "$FREETYPE2_FOUND" >&6; } LDFLAGS="$FREETYPE2_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FT_Init_FreeType in -lfreetype" >&5 $as_echo_n "checking for FT_Init_FreeType in -lfreetype... " >&6; } -if ${ac_cv_lib_freetype_FT_Init_FreeType+:} false; then : +if test "${ac_cv_lib_freetype_FT_Init_FreeType+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31643,7 +31649,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_freetype_FT_Init_FreeType" >&5 $as_echo "$ac_cv_lib_freetype_FT_Init_FreeType" >&6; } -if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = xyes; then : +if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = x""yes; then : FREETYPE2_FOUND=true else as_fn_error $? "Could not find freetype2! $HELP_MSG " "$LINENO" 5 @@ -31931,7 +31937,7 @@ fi for ac_header in alsa/asoundlib.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "alsa/asoundlib.h" "ac_cv_header_alsa_asoundlib_h" "$ac_includes_default" -if test "x$ac_cv_header_alsa_asoundlib_h" = xyes; then : +if test "x$ac_cv_header_alsa_asoundlib_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ALSA_ASOUNDLIB_H 1 _ACEOF @@ -31990,7 +31996,7 @@ fi USE_EXTERNAL_LIBJPEG=true { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ljpeg" >&5 $as_echo_n "checking for main in -ljpeg... " >&6; } -if ${ac_cv_lib_jpeg_main+:} false; then : +if test "${ac_cv_lib_jpeg_main+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -32018,7 +32024,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_main" >&5 $as_echo "$ac_cv_lib_jpeg_main" >&6; } -if test "x$ac_cv_lib_jpeg_main" = xyes; then : +if test "x$ac_cv_lib_jpeg_main" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBJPEG 1 _ACEOF @@ -32067,7 +32073,7 @@ if test "x${with_giflib}" = "xbundled"; then USE_EXTERNAL_LIBGIF=false elif test "x${with_giflib}" = "xsystem"; then ac_fn_cxx_check_header_mongrel "$LINENO" "gif_lib.h" "ac_cv_header_gif_lib_h" "$ac_includes_default" -if test "x$ac_cv_header_gif_lib_h" = xyes; then : +if test "x$ac_cv_header_gif_lib_h" = x""yes; then : else as_fn_error $? "--with-giflib=system specified, but gif_lib.h not found!" "$LINENO" 5 @@ -32076,7 +32082,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DGifGetCode in -lgif" >&5 $as_echo_n "checking for DGifGetCode in -lgif... " >&6; } -if ${ac_cv_lib_gif_DGifGetCode+:} false; then : +if test "${ac_cv_lib_gif_DGifGetCode+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -32110,7 +32116,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gif_DGifGetCode" >&5 $as_echo "$ac_cv_lib_gif_DGifGetCode" >&6; } -if test "x$ac_cv_lib_gif_DGifGetCode" = xyes; then : +if test "x$ac_cv_lib_gif_DGifGetCode" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBGIF 1 _ACEOF @@ -32142,7 +32148,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compress in -lz" >&5 $as_echo_n "checking for compress in -lz... " >&6; } -if ${ac_cv_lib_z_compress+:} false; then : +if test "${ac_cv_lib_z_compress+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -32176,7 +32182,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5 $as_echo "$ac_cv_lib_z_compress" >&6; } -if test "x$ac_cv_lib_z_compress" = xyes; then : +if test "x$ac_cv_lib_z_compress" = x""yes; then : ZLIB_FOUND=yes else ZLIB_FOUND=no @@ -32269,7 +32275,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 $as_echo_n "checking for cos in -lm... " >&6; } -if ${ac_cv_lib_m_cos+:} false; then : +if test "${ac_cv_lib_m_cos+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -32303,7 +32309,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 $as_echo "$ac_cv_lib_m_cos" >&6; } -if test "x$ac_cv_lib_m_cos" = xyes; then : +if test "x$ac_cv_lib_m_cos" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF @@ -32327,7 +32333,7 @@ save_LIBS="$LIBS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : +if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -32361,7 +32367,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF @@ -32591,7 +32597,7 @@ and LIBFFI_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else LIBFFI_CFLAGS=$pkg_cv_LIBFFI_CFLAGS LIBFFI_LIBS=$pkg_cv_LIBFFI_LIBS @@ -32607,7 +32613,7 @@ if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then set dummy llvm-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_LLVM_CONFIG+:} false; then : +if test "${ac_cv_prog_LLVM_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$LLVM_CONFIG"; then @@ -33219,7 +33225,7 @@ fi set dummy ccache; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CCACHE+:} false; then : +if test "${ac_cv_path_CCACHE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CCACHE in @@ -33480,21 +33486,10 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then + test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi + cat confcache >$cache_file else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -33526,7 +33521,7 @@ LTLIBOBJS=$ac_ltlibobjs -: "${CONFIG_STATUS=./config.status}" +: ${CONFIG_STATUS=./config.status} ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -33627,7 +33622,6 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -33935,7 +33929,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -33998,7 +33992,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ OpenJDK config.status jdk8 -configured by $0, generated by GNU Autoconf 2.68, +configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. @@ -34127,7 +34121,7 @@ do "$OUTPUT_ROOT/spec.sh") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/spec.sh:$AUTOCONF_DIR/spec.sh.in" ;; "$OUTPUT_ROOT/Makefile") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in" ;; - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; esac done @@ -34149,10 +34143,9 @@ fi # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= ac_tmp= + tmp= trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -34160,13 +34153,12 @@ $debug || { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" + test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -34188,7 +34180,7 @@ else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF @@ -34216,7 +34208,7 @@ done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -34264,7 +34256,7 @@ t delim rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && +cat >>"\$tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -34296,7 +34288,7 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF @@ -34330,7 +34322,7 @@ fi # test -n "$CONFIG_FILES" # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || +cat >"$tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -34342,8 +34334,8 @@ _ACEOF # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 @@ -34444,7 +34436,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -34463,7 +34455,7 @@ do for ac_f do case $ac_f in - -) ac_f="$ac_tmp/stdin";; + -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -34472,7 +34464,7 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -34498,8 +34490,8 @@ $as_echo "$as_me: creating $ac_file" >&6;} esac case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + *:-:* | *:-) cat >"$tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -34624,22 +34616,21 @@ s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$ac_tmp/stdin" + rm -f "$tmp/stdin" case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; @@ -34650,20 +34641,20 @@ which seems to be undefined. Please make sure it is defined" >&2;} if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ + mv "$tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; diff --git a/common/autoconf/toolchain_windows.m4 b/common/autoconf/toolchain_windows.m4 index 700339a9e17..966c0133995 100644 --- a/common/autoconf/toolchain_windows.m4 +++ b/common/autoconf/toolchain_windows.m4 @@ -91,6 +91,15 @@ AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE], AC_MSG_ERROR([Cannot locate a valid Visual Studio installation]) fi + if test "x$VS100COMNTOOLS" != x; then + TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$VS100COMNTOOLS/../..], [VS100COMNTOOLS variable]) + fi + if test "x$PROGRAMFILES" != x; then + TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$PROGRAMFILES/Microsoft Visual Studio 10.0], [well-known name]) + fi + TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files/Microsoft Visual Studio 10.0], [well-known name]) + TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files (x86)/Microsoft Visual Studio 10.0], [well-known name]) + if test "x$ProgramW6432" != x; then TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$ProgramW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name]) fi @@ -102,15 +111,6 @@ AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE], fi TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin], [well-known name]) TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1/Bin], [well-known name]) - - if test "x$VS100COMNTOOLS" != x; then - TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$VS100COMNTOOLS/../..], [VS100COMNTOOLS variable]) - fi - if test "x$PROGRAMFILES" != x; then - TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$PROGRAMFILES/Microsoft Visual Studio 10.0], [well-known name]) - fi - TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files/Microsoft Visual Studio 10.0], [well-known name]) - TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files (x86)/Microsoft Visual Studio 10.0], [well-known name]) ]) # Check if the VS env variables were setup prior to running configure. @@ -248,10 +248,23 @@ AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV], AC_MSG_NOTICE([Warning: msvcr100.dll not found in VCINSTALLDIR: $VCINSTALLDIR]) fi fi + # Try some fallback alternatives if test "x$MSVCR_DLL" = x; then - if test -f "$SYSTEMROOT/system32/msvcr100.dll"; then - AC_MSG_NOTICE([msvcr100.dll found in $SYSTEMROOT/system32]) - MSVCR_DLL="$SYSTEMROOT/system32/msvcr100.dll" + # If visual studio express is installed, there is usually one with the debugger + if test "x$VS100COMNTOOLS" != x; then + if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then + MSVCR_DLL=`find "$VS100COMNTOOLS/.." -name msvcr100.dll | grep -i x64 | head --lines 1` + AC_MSG_NOTICE([msvcr100.dll found in $VS100COMNTOOLS..: $VS100COMNTOOLS..]) + fi + fi + fi + if test "x$MSVCR_DLL" = x; then + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + # Fallback for 32bit builds, look in the windows directory. + if test -f "$SYSTEMROOT/system32/msvcr100.dll"; then + AC_MSG_NOTICE([msvcr100.dll found in $SYSTEMROOT/system32]) + MSVCR_DLL="$SYSTEMROOT/system32/msvcr100.dll" + fi fi fi fi From fcb2ec8d6f072a46c6b3bd9ff081f3a659853620 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 11 Jun 2013 13:25:21 +0200 Subject: [PATCH 187/206] 8010785: JDK 8 build on Linux fails with new build mechanism Reviewed-by: dholmes, tbell --- common/autoconf/generated-configure.sh | 8 ++------ common/autoconf/jdk-options.m4 | 6 +----- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index e1198a5e4e3..e1c9229a744 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -3782,7 +3782,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1370948811 +DATE_WHEN_GENERATED=1370949244 ############################################################################### # @@ -10782,11 +10782,7 @@ fi if test "x$with_cacerts_file" != x; then CACERTS_FILE=$with_cacerts_file else - if test "x$OPENJDK" = "xtrue"; then - CACERTS_FILE=${SRC_ROOT}/jdk/src/share/lib/security/cacerts - else - CACERTS_FILE=${SRC_ROOT}/jdk/src/closed/share/lib/security/cacerts.internal - fi + CACERTS_FILE=${SRC_ROOT}/jdk/src/share/lib/security/cacerts fi diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 index 7f7467318f5..ba14373e593 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 @@ -351,11 +351,7 @@ AC_ARG_WITH(cacerts-file, [AS_HELP_STRING([--with-cacerts-file], if test "x$with_cacerts_file" != x; then CACERTS_FILE=$with_cacerts_file else - if test "x$OPENJDK" = "xtrue"; then - CACERTS_FILE=${SRC_ROOT}/jdk/src/share/lib/security/cacerts - else - CACERTS_FILE=${SRC_ROOT}/jdk/src/closed/share/lib/security/cacerts.internal - fi + CACERTS_FILE=${SRC_ROOT}/jdk/src/share/lib/security/cacerts fi AC_SUBST(CACERTS_FILE) From d3187c76c86ccdaff2791c0f91bd4d6155edfdc4 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 11 Jun 2013 13:26:15 +0200 Subject: [PATCH 188/206] 8010785: JDK 8 build on Linux fails with new build mechanism Reviewed-by: dholmes, tbell --- jdk/makefiles/CompileNativeLibraries.gmk | 16 ++-- jdk/makefiles/CreateJars.gmk | 103 +++++++++++++---------- jdk/makefiles/Import.gmk | 42 ++++++++- jdk/makefiles/Setup.gmk | 4 +- 4 files changed, 111 insertions(+), 54 deletions(-) diff --git a/jdk/makefiles/CompileNativeLibraries.gmk b/jdk/makefiles/CompileNativeLibraries.gmk index ffaf5b57213..6197baa916c 100644 --- a/jdk/makefiles/CompileNativeLibraries.gmk +++ b/jdk/makefiles/CompileNativeLibraries.gmk @@ -2609,21 +2609,22 @@ endif ########################################################################################## -BUILD_LIBKRB5_NAME:= -ifeq ($(OPENJDK_TARGET_OS), windows) +ifneq ($(BUILD_CRYPTO),no) + BUILD_LIBKRB5_NAME:= + ifeq ($(OPENJDK_TARGET_OS), windows) BUILD_LIBKRB5_NAME:=w2k_lsa_auth BUILD_LIBKRB5_SRC:=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/krb5 BUILD_LIBKRB5_LIBS:=advapi32.lib Secur32.lib netapi32.lib kernel32.lib user32.lib \ gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib \ ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib -else ifeq ($(OPENJDK_TARGET_OS), macosx) + else ifeq ($(OPENJDK_TARGET_OS), macosx) BUILD_LIBKRB5_NAME:=osxkrb5 BUILD_LIBKRB5_SRC:=$(JDK_TOPDIR)/src/share/native/sun/security/krb5 BUILD_LIBKRB5_LIBS:=-framework Kerberos -endif + endif -ifneq ($(BUILD_LIBKRB5_NAME),) -$(eval $(call SetupNativeCompilation,BUILD_LIBKRB5,\ + ifneq ($(BUILD_LIBKRB5_NAME),) + $(eval $(call SetupNativeCompilation,BUILD_LIBKRB5,\ LIBRARY:=$(BUILD_LIBKRB5_NAME),\ OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\ SRC:=$(BUILD_LIBKRB5_SRC),\ @@ -2643,7 +2644,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBKRB5,\ OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libkrb5,\ DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES))) -BUILD_LIBRARIES += $(BUILD_LIBKRB5) + BUILD_LIBRARIES += $(BUILD_LIBKRB5) + endif endif ########################################################################################## diff --git a/jdk/makefiles/CreateJars.gmk b/jdk/makefiles/CreateJars.gmk index 3225a862653..217781b97c8 100644 --- a/jdk/makefiles/CreateJars.gmk +++ b/jdk/makefiles/CreateJars.gmk @@ -467,10 +467,15 @@ $(JCE_MANIFEST): $(MAINMANIFEST) $(MV) $@.tmp $@ ########################################################################################## -# For all security jars, always build the jar, but for closed, install the prebuilt signed -# version instead of the newly built jar. Unsigned jars are treated as intermediate targets -# and explicitly added to the JARS list. For open, signing is not needed. See SignJars.gmk -# for more information. +# For security and crypto jars, always build the jar, but for closed, install the prebuilt +# signed version instead of the newly built jar. Unsigned jars are treated as intermediate +# targets and explicitly added to the JARS list. For open, signing is not needed. See +# SignJars.gmk for more information. +# +# The source for the crypto jars is not available for all licensees. The BUILD_CRYPTO +# variable is set to no if these jars can't be built to skip that step of the build. +# Note that for OPENJDK, the build will fail if BUILD_CRYPTO=no since then there is no +# other way to get the jars than to build them. SUNPKCS11_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/sunpkcs11.jar SUNPKCS11_JAR_UNSIGNED := $(IMAGES_OUTPUTDIR)/unsigned/sunpkcs11.jar @@ -540,7 +545,8 @@ $(eval $(call SetupArchive,BUILD_SWINGBEANS_JAR,,\ SUNJCE_PROVIDER_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/sunjce_provider.jar SUNJCE_PROVIDER_JAR_UNSIGNED := $(IMAGES_OUTPUTDIR)/unsigned/sunjce_provider.jar -$(eval $(call SetupArchive,BUILD_SUNJCE_PROVIDER_JAR,,\ +ifneq ($(BUILD_CRYPTO),no) + $(eval $(call SetupArchive,BUILD_SUNJCE_PROVIDER_JAR,,\ SRCS:=$(JDK_OUTPUTDIR)/classes, \ SUFFIXES:=.class,\ INCLUDES:= com/sun/crypto/provider,\ @@ -548,7 +554,10 @@ $(eval $(call SetupArchive,BUILD_SUNJCE_PROVIDER_JAR,,\ MANIFEST:=$(JCE_MANIFEST), \ SKIP_METAINF := true)) -$(SUNJCE_PROVIDER_JAR_UNSIGNED): $(JCE_MANIFEST) + $(SUNJCE_PROVIDER_JAR_UNSIGNED): $(JCE_MANIFEST) + + JARS += $(SUNJCE_PROVIDER_JAR_UNSIGNED) +endif ifndef OPENJDK SUNJCE_PROVIDER_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/jce/sunjce_provider.jar @@ -560,14 +569,13 @@ else $(install-file) endif -JARS += $(SUNJCE_PROVIDER_JAR_UNSIGNED) - ########################################################################################## JCE_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/jce.jar JCE_JAR_UNSIGNED := $(IMAGES_OUTPUTDIR)/unsigned/jce.jar -$(eval $(call SetupArchive,BUILD_JCE_JAR,,\ +ifneq ($(BUILD_CRYPTO),no) + $(eval $(call SetupArchive,BUILD_JCE_JAR,,\ SRCS:=$(JDK_OUTPUTDIR)/classes, \ SUFFIXES:=.class,\ INCLUDES:= javax/crypto sun/security/internal,\ @@ -575,101 +583,106 @@ $(eval $(call SetupArchive,BUILD_JCE_JAR,,\ MANIFEST:=$(JCE_MANIFEST), \ SKIP_METAINF := true)) -$(JCE_JAR_UNSIGNED): $(JCE_MANIFEST) + $(JCE_JAR_UNSIGNED): $(JCE_MANIFEST) + + JARS += $(JCE_JAR_UNSIGNED) +endif ifndef OPENJDK - JCE_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/jce/jce.jar - $(JCE_JAR_DST) : $(JCE_JAR_SRC) + JCE_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/jce/jce.jar + $(JCE_JAR_DST) : $(JCE_JAR_SRC) @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt jce.jar..." $(install-file) else - $(JCE_JAR_DST) : $(JCE_JAR_UNSIGNED) + $(JCE_JAR_DST) : $(JCE_JAR_UNSIGNED) $(install-file) endif -JARS += $(JCE_JAR_UNSIGNED) - ########################################################################################## US_EXPORT_POLICY_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/security/US_export_policy.jar US_EXPORT_POLICY_JAR_UNSIGNED := $(IMAGES_OUTPUTDIR)/unsigned/US_export_policy.jar -# -# TODO fix so that SetupArchive does not write files into SRCS -# then we don't need this extra copying -# -# NOTE: We currently do not place restrictions on our limited export -# policy. This was not a typo. -# -US_EXPORT_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/unlimited -US_EXPORT_POLICY_JAR_TMP := $(IMAGES_OUTPUTDIR)/US_export_policy_jar.tmp +ifneq ($(BUILD_CRYPTO),no) + # + # TODO fix so that SetupArchive does not write files into SRCS + # then we don't need this extra copying -$(US_EXPORT_POLICY_JAR_TMP)/% : $(US_EXPORT_POLICY_JAR_SRC_DIR)/% + # NOTE: We currently do not place restrictions on our limited export + # policy. This was not a typo. + # + US_EXPORT_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/unlimited + US_EXPORT_POLICY_JAR_TMP := $(IMAGES_OUTPUTDIR)/US_export_policy_jar.tmp + + $(US_EXPORT_POLICY_JAR_TMP)/% : $(US_EXPORT_POLICY_JAR_SRC_DIR)/% $(install-file) -US_EXPORT_POLICY_JAR_DEPS := $(US_EXPORT_POLICY_JAR_TMP)/default_US_export.policy + US_EXPORT_POLICY_JAR_DEPS := $(US_EXPORT_POLICY_JAR_TMP)/default_US_export.policy -$(eval $(call SetupArchive,BUILD_US_EXPORT_POLICY_JAR,$(US_EXPORT_POLICY_JAR_DEPS),\ + $(eval $(call SetupArchive,BUILD_US_EXPORT_POLICY_JAR,$(US_EXPORT_POLICY_JAR_DEPS),\ SRCS:=$(US_EXPORT_POLICY_JAR_TMP), \ SUFFIXES:= .policy,\ JAR:=$(US_EXPORT_POLICY_JAR_UNSIGNED), \ EXTRA_MANIFEST_ATTR := Crypto-Strength: unlimited, \ SKIP_METAINF := true)) + JARS += $(US_EXPORT_POLICY_JAR_UNSIGNED) +endif + ifndef OPENJDK - $(US_EXPORT_POLICY_JAR_DST): $(JDK_TOPDIR)/make/closed/tools/crypto/jce/US_export_policy.jar + $(US_EXPORT_POLICY_JAR_DST): $(JDK_TOPDIR)/make/closed/tools/crypto/jce/US_export_policy.jar $(ECHO) $(LOG_INFO) Copying $(@F) $(install-file) else - $(US_EXPORT_POLICY_JAR_DST): $(US_EXPORT_POLICY_JAR_UNSIGNED) + $(US_EXPORT_POLICY_JAR_DST): $(US_EXPORT_POLICY_JAR_UNSIGNED) $(install-file) endif -JARS += $(US_EXPORT_POLICY_JAR_UNSIGNED) - ########################################################################################## LOCAL_POLICY_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/security/local_policy.jar LOCAL_POLICY_JAR_UNSIGNED := $(IMAGES_OUTPUTDIR)/unsigned/local_policy.jar -# -# TODO fix so that SetupArchive does not write files into SRCS -# then we don't need this extra copying -# -LOCAL_POLICY_JAR_TMP := $(IMAGES_OUTPUTDIR)/local_policy_jar.tmp +ifneq ($(BUILD_CRYPTO),no) + # + # TODO fix so that SetupArchive does not write files into SRCS + # then we don't need this extra copying + # + LOCAL_POLICY_JAR_TMP := $(IMAGES_OUTPUTDIR)/local_policy_jar.tmp -ifeq ($(UNLIMITED_CRYPTO), true) + ifeq ($(UNLIMITED_CRYPTO), true) LOCAL_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/unlimited LOCAL_POLICY_JAR_DEPS := $(LOCAL_POLICY_JAR_TMP)/default_local.policy LOCAL_POLICY_JAR_ATTR := Crypto-Strength: unlimited -else + else LOCAL_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/limited LOCAL_POLICY_JAR_DEPS := $(LOCAL_POLICY_JAR_TMP)/exempt_local.policy \ $(LOCAL_POLICY_JAR_TMP)/default_local.policy LOCAL_POLICY_JAR_ATTR := Crypto-Strength: limited -endif + endif -$(LOCAL_POLICY_JAR_TMP)/% : $(LOCAL_POLICY_JAR_SRC_DIR)/% + $(LOCAL_POLICY_JAR_TMP)/% : $(LOCAL_POLICY_JAR_SRC_DIR)/% $(install-file) -$(eval $(call SetupArchive,BUILD_LOCAL_POLICY_JAR,$(LOCAL_POLICY_JAR_DEPS),\ + $(eval $(call SetupArchive,BUILD_LOCAL_POLICY_JAR,$(LOCAL_POLICY_JAR_DEPS),\ SRCS:=$(LOCAL_POLICY_JAR_TMP),\ SUFFIXES:= .policy,\ JAR:=$(LOCAL_POLICY_JAR_UNSIGNED), \ EXTRA_MANIFEST_ATTR := $(LOCAL_POLICY_JAR_ATTR), \ SKIP_METAINF := true)) + JARS += $(LOCAL_POLICY_JAR_UNSIGNED) +endif + ifndef OPENJDK - $(LOCAL_POLICY_JAR_DST): $(JDK_TOPDIR)/make/closed/tools/crypto/jce/local_policy.jar + $(LOCAL_POLICY_JAR_DST): $(JDK_TOPDIR)/make/closed/tools/crypto/jce/local_policy.jar $(ECHO) $(LOG_INFO) Copying $(@F) $(install-file) else - $(LOCAL_POLICY_JAR_DST): $(LOCAL_POLICY_JAR_UNSIGNED) + $(LOCAL_POLICY_JAR_DST): $(LOCAL_POLICY_JAR_UNSIGNED) $(install-file) endif -JARS += $(LOCAL_POLICY_JAR_UNSIGNED) - ########################################################################################## ifeq ($(OPENJDK_TARGET_OS),windows) diff --git a/jdk/makefiles/Import.gmk b/jdk/makefiles/Import.gmk index 5e99b53f0e8..d25a1829374 100644 --- a/jdk/makefiles/Import.gmk +++ b/jdk/makefiles/Import.gmk @@ -200,6 +200,46 @@ $(INSTALL_LIBRARIES_HERE)/minimal/%.diz : $(INSTALL_LIBRARIES_HERE)/%.diz $(RM) $(basename $@).debuginfo $(MV) $@.tmp $@ -####### +########################################################################################## +# Unpack the binary distributions of the crypto classes if they exist. +SEC_FILES_ZIP:=$(JDK_TOPDIR)/make/tools/crypto/sec-bin.zip +SEC_FILES_WIN_ZIP:=$(JDK_TOPDIR)/make/tools/crypto/sec-windows-bin.zip +JGSS_WIN32_FILES_ZIP:=$(JDK_TOPDIR)/make/tools/crypto/jgss-windows-i586-bin.zip +JGSS_WIN64_FILES_ZIP:=$(JDK_TOPDIR)/make/tools/crypto/jgss-windows-x64-bin.zip + +define unzip-sec-file + $(ECHO) Unzipping $( $@.tmp) + $(MV) $@.tmp $@ +endef + +$(JDK_OUTPUTDIR)/classes/_the.sec-bin.unzipped: $(SEC_FILES_ZIP) + $(call unzip-sec-file) + +$(JDK_OUTPUTDIR)/classes/_the.sec-windows-bin.unzipped: $(SEC_FILES_WIN_ZIP) + $(call unzip-sec-file) + +$(JDK_OUTPUTDIR)/classes/_the.jgss-windows-i586-bin.unzipped: $(JGSS_WIN32_FILES_ZIP) + $(call unzip-sec-file) + +$(JDK_OUTPUTDIR)/classes/_the.jgss-windows-x64-bin.unzipped: $(JGSS_WIN64_FILES_ZIP) + $(call unzip-sec-file) + +ifneq ($(wildcard $(SEC_FILES_ZIP)),) + IMPORT_TARGET_FILES += $(JDK_OUTPUTDIR)/classes/_the.sec-bin.unzipped + ifeq ($(OPENJDK_TARGET_OS),windows) + IMPORT_TARGET_FILES += $(JDK_OUTPUTDIR)/classes/_the.sec-windows-bin.unzipped + ifeq ($(OPENJDK_TARGET_CPU),x86) + IMPORT_TARGET_FILES += $(JDK_OUTPUTDIR)/classes/_the.jgss-windows-i586-bin.unzipped + endif + ifeq ($(OPENJDK_TARGET_CPU),x86_64) + IMPORT_TARGET_FILES += $(JDK_OUTPUTDIR)/classes/_the.jgss-windows-x64-bin.unzipped + endif + endif +endif + +########################################################################################## all: $(IMPORT_TARGET_FILES) diff --git a/jdk/makefiles/Setup.gmk b/jdk/makefiles/Setup.gmk index 95e7b20f39c..8012e547b55 100644 --- a/jdk/makefiles/Setup.gmk +++ b/jdk/makefiles/Setup.gmk @@ -40,7 +40,9 @@ $(eval $(call SetupJavaCompiler,GENERATE_OLDBYTECODE,\ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE,\ JVM:=$(JAVA),\ JAVAC:=$(NEW_JAVAC),\ - FLAGS:=-bootclasspath $(JDK_OUTPUTDIR)/classes -source 8 -target 8 -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS),\ + FLAGS:=-bootclasspath $(JDK_OUTPUTDIR)/classes -source 8 -target 8 \ + -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS) \ + $(GENERATE_JDKBYTECODE_EXTRA_FLAGS),\ SERVER_DIR:=$(SJAVAC_SERVER_DIR),\ SERVER_JVM:=$(SJAVAC_SERVER_JAVA))) From 2ea5ec54191f4fd344ed34ecf52203a1722f7f1b Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Tue, 11 Jun 2013 11:18:02 -0700 Subject: [PATCH 189/206] 8015960: java/util/Locale/LocaleProviders.java failing again on Windows Reviewed-by: alanb --- jdk/test/java/util/Locale/LocaleProviders.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/java/util/Locale/LocaleProviders.java b/jdk/test/java/util/Locale/LocaleProviders.java index 30ad90a4bb7..22533f90670 100644 --- a/jdk/test/java/util/Locale/LocaleProviders.java +++ b/jdk/test/java/util/Locale/LocaleProviders.java @@ -207,6 +207,7 @@ public class LocaleProviders { String jreResult = "\u5e73\u6210 16.11.03 (\u6c34) \u5348\u524d 11:53:47"; Locale l = new Locale("ja", "JP", "JP"); SimpleDateFormat sdf = new SimpleDateFormat("GGGG yyyy.MMM.dd '('E')' a hh:mm:ss", l); + sdf.setTimeZone(TimeZone.getTimeZone("PST")); String result = sdf.format(sampleDate); System.out.println(result); if (LocaleProviderAdapter.getAdapterPreference() From 0df3d2fa1a5571fefd1032204b0c18d2674e2a94 Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Tue, 11 Jun 2013 15:39:20 -0700 Subject: [PATCH 190/206] 8016213: Convert j2se NetBeans project to use top-level make targets Reviewed-by: chegar --- jdk/make/netbeans/common/shared.xml | 8 ++++---- jdk/make/netbeans/j2se/build.xml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jdk/make/netbeans/common/shared.xml b/jdk/make/netbeans/common/shared.xml index 36d57de7c43..26b3a41043c 100644 --- a/jdk/make/netbeans/common/shared.xml +++ b/jdk/make/netbeans/common/shared.xml @@ -77,7 +77,7 @@ System configuration claims architecture is ${platform}-${arch} - + @@ -126,7 +126,7 @@ - @@ -146,7 +146,7 @@ - + @@ -312,7 +312,7 @@ - + diff --git a/jdk/make/netbeans/j2se/build.xml b/jdk/make/netbeans/j2se/build.xml index ea0487a00fe..aaefd4c12ec 100644 --- a/jdk/make/netbeans/j2se/build.xml +++ b/jdk/make/netbeans/j2se/build.xml @@ -37,11 +37,11 @@ - + - + From fdab7e633839190cce959710e5c056bac144affd Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 12 Jun 2013 08:04:11 +0100 Subject: [PATCH 191/206] 8016370: javadoc warnings, unexpected

    mostly Reviewed-by: martin, jjg --- jdk/makefiles/scripts/genExceptions.sh | 4 ++-- jdk/src/share/classes/java/nio/Buffer.java | 24 +++++++++---------- jdk/src/share/classes/java/nio/ByteOrder.java | 3 +-- .../classes/java/nio/X-Buffer.java.template | 20 ++++++++-------- .../AsynchronousServerSocketChannel.java | 2 +- .../classes/java/nio/channels/Channel.java | 2 +- .../java/nio/channels/FileChannel.java | 4 ++-- .../classes/java/nio/channels/FileLock.java | 6 ++--- .../share/classes/java/nio/channels/Pipe.java | 8 +++---- .../java/nio/channels/SelectableChannel.java | 5 ++-- .../java/nio/channels/SelectionKey.java | 14 +++++------ .../classes/java/nio/channels/Selector.java | 4 ++-- .../java/nio/channels/SocketChannel.java | 2 +- .../channels/spi/AbstractSelectionKey.java | 2 +- .../nio/channels/spi/AbstractSelector.java | 2 +- .../nio/channels/spi/SelectorProvider.java | 12 +++++----- .../nio/charset/Charset-X-Coder.java.template | 17 +++++++------ .../classes/java/nio/charset/Charset.java | 20 ++++++++-------- .../classes/java/nio/charset/CoderResult.java | 22 ++++++++--------- .../java/nio/charset/CodingErrorAction.java | 6 ++--- .../charset/UnmappableCharacterException.java | 2 +- .../java/nio/charset/spi/CharsetProvider.java | 6 ++--- 22 files changed, 91 insertions(+), 96 deletions(-) diff --git a/jdk/makefiles/scripts/genExceptions.sh b/jdk/makefiles/scripts/genExceptions.sh index 5a43c8741c5..698e14518e8 100644 --- a/jdk/makefiles/scripts/genExceptions.sh +++ b/jdk/makefiles/scripts/genExceptions.sh @@ -70,7 +70,7 @@ __END__ private $ARG_TYPE $ARG_ID; /** - * Constructs an instance of this class.

    + * Constructs an instance of this class. * * @param $ARG_ID * The $ARG_PHRASE @@ -81,7 +81,7 @@ __END__ } /** - * Retrieves the $ARG_PHRASE.

    + * Retrieves the $ARG_PHRASE. * * @return The $ARG_PHRASE */ diff --git a/jdk/src/share/classes/java/nio/Buffer.java b/jdk/src/share/classes/java/nio/Buffer.java index 24d3cf8c56a..068444a9758 100644 --- a/jdk/src/share/classes/java/nio/Buffer.java +++ b/jdk/src/share/classes/java/nio/Buffer.java @@ -209,7 +209,7 @@ public abstract class Buffer { } /** - * Returns this buffer's capacity.

    + * Returns this buffer's capacity. * * @return The capacity of this buffer */ @@ -218,7 +218,7 @@ public abstract class Buffer { } /** - * Returns this buffer's position.

    + * Returns this buffer's position. * * @return The position of this buffer */ @@ -228,7 +228,7 @@ public abstract class Buffer { /** * Sets this buffer's position. If the mark is defined and larger than the - * new position then it is discarded.

    + * new position then it is discarded. * * @param newPosition * The new position value; must be non-negative @@ -248,7 +248,7 @@ public abstract class Buffer { } /** - * Returns this buffer's limit.

    + * Returns this buffer's limit. * * @return The limit of this buffer */ @@ -259,7 +259,7 @@ public abstract class Buffer { /** * Sets this buffer's limit. If the position is larger than the new limit * then it is set to the new limit. If the mark is defined and larger than - * the new limit then it is discarded.

    + * the new limit then it is discarded. * * @param newLimit * The new limit value; must be non-negative @@ -280,7 +280,7 @@ public abstract class Buffer { } /** - * Sets this buffer's mark at its position.

    + * Sets this buffer's mark at its position. * * @return This buffer */ @@ -383,7 +383,7 @@ public abstract class Buffer { /** * Returns the number of elements between the current position and the - * limit.

    + * limit. * * @return The number of elements remaining in this buffer */ @@ -393,7 +393,7 @@ public abstract class Buffer { /** * Tells whether there are any elements between the current position and - * the limit.

    + * the limit. * * @return true if, and only if, there is at least one element * remaining in this buffer @@ -403,7 +403,7 @@ public abstract class Buffer { } /** - * Tells whether or not this buffer is read-only.

    + * Tells whether or not this buffer is read-only. * * @return true if, and only if, this buffer is read-only */ @@ -477,7 +477,7 @@ public abstract class Buffer { /** * Tells whether or not this buffer is - * direct.

    + * direct. * * @return true if, and only if, this buffer is direct * @@ -491,7 +491,7 @@ public abstract class Buffer { /** * Checks the current position against the limit, throwing a {@link * BufferUnderflowException} if it is not smaller than the limit, and then - * increments the position.

    + * increments the position. * * @return The current position value, before it is incremented */ @@ -512,7 +512,7 @@ public abstract class Buffer { /** * Checks the current position against the limit, throwing a {@link * BufferOverflowException} if it is not smaller than the limit, and then - * increments the position.

    + * increments the position. * * @return The current position value, before it is incremented */ diff --git a/jdk/src/share/classes/java/nio/ByteOrder.java b/jdk/src/share/classes/java/nio/ByteOrder.java index aed6c0095bc..50c7f158b0a 100644 --- a/jdk/src/share/classes/java/nio/ByteOrder.java +++ b/jdk/src/share/classes/java/nio/ByteOrder.java @@ -45,7 +45,6 @@ public final class ByteOrder { /** * Constant denoting big-endian byte order. In this order, the bytes of a * multibyte value are ordered from most significant to least significant. - *

    */ public static final ByteOrder BIG_ENDIAN = new ByteOrder("BIG_ENDIAN"); @@ -53,7 +52,7 @@ public final class ByteOrder { /** * Constant denoting little-endian byte order. In this order, the bytes of * a multibyte value are ordered from least significant to most - * significant.

    + * significant. */ public static final ByteOrder LITTLE_ENDIAN = new ByteOrder("LITTLE_ENDIAN"); diff --git a/jdk/src/share/classes/java/nio/X-Buffer.java.template b/jdk/src/share/classes/java/nio/X-Buffer.java.template index 738b18b51a1..c3037adb4d2 100644 --- a/jdk/src/share/classes/java/nio/X-Buffer.java.template +++ b/jdk/src/share/classes/java/nio/X-Buffer.java.template @@ -551,7 +551,7 @@ public abstract class $Type$Buffer /** * Relative get method. Reads the $type$ at this buffer's - * current position, and then increments the position.

    + * current position, and then increments the position. * * @return The $type$ at the buffer's current position * @@ -581,7 +581,7 @@ public abstract class $Type$Buffer /** * Absolute get method. Reads the $type$ at the given - * index.

    + * index. * * @param index * The index from which the $type$ will be read @@ -658,7 +658,7 @@ public abstract class $Type$Buffer * }
  • * * except that it first checks that there are sufficient $type$s in - * this buffer and it is potentially much more efficient.

    + * this buffer and it is potentially much more efficient. * * @param dst * The array into which $type$s are to be written @@ -739,7 +739,7 @@ public abstract class $Type$Buffer * dst.put(src.get()); * * except that it first checks that there is sufficient space in this - * buffer and it is potentially much more efficient.

    + * buffer and it is potentially much more efficient. * * @param src * The source buffer from which $type$s are to be read; @@ -795,7 +795,7 @@ public abstract class $Type$Buffer * } * * except that it first checks that there is sufficient space in this - * buffer and it is potentially much more efficient.

    + * buffer and it is potentially much more efficient. * * @param src * The array from which $type$s are to be read @@ -882,7 +882,7 @@ public abstract class $Type$Buffer * } * * except that it first checks that there is sufficient space in this - * buffer and it is potentially much more efficient.

    + * buffer and it is potentially much more efficient. * * @param src * The string from which $type$s are to be read @@ -1060,7 +1060,7 @@ public abstract class $Type$Buffer public abstract $Type$Buffer compact(); /** - * Tells whether or not this $type$ buffer is direct.

    + * Tells whether or not this $type$ buffer is direct. * * @return true if, and only if, this buffer is direct */ @@ -1069,7 +1069,7 @@ public abstract class $Type$Buffer #if[!char] /** - * Returns a string summarizing the state of this buffer.

    + * Returns a string summarizing the state of this buffer. * * @return A summary string */ @@ -1254,7 +1254,7 @@ public abstract class $Type$Buffer /** * Reads the character at the given index relative to the current - * position.

    + * position. * * @param index * The index of the character to be read, relative to the position; @@ -1452,7 +1452,7 @@ public abstract class $Type$Buffer } /** - * Modifies this buffer's byte order.

    + * Modifies this buffer's byte order. * * @param bo * The new byte order, diff --git a/jdk/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java b/jdk/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java index 471b53571cb..dc4551b3beb 100644 --- a/jdk/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java +++ b/jdk/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java @@ -253,7 +253,7 @@ public abstract class AsynchronousServerSocketChannel *

    To allow for concurrent handling of new connections, the completion * handler is not invoked directly by the initiating thread when a new * connection is accepted immediately (see Threading). + * href="AsynchronousChannelGroup.html#threading">Threading). * *

    If a security manager has been installed then it verifies that the * address and port number of the connection's remote endpoint are permitted diff --git a/jdk/src/share/classes/java/nio/channels/Channel.java b/jdk/src/share/classes/java/nio/channels/Channel.java index a20de123dfa..88d15ace67f 100644 --- a/jdk/src/share/classes/java/nio/channels/Channel.java +++ b/jdk/src/share/classes/java/nio/channels/Channel.java @@ -56,7 +56,7 @@ import java.io.Closeable; public interface Channel extends Closeable { /** - * Tells whether or not this channel is open.

    + * Tells whether or not this channel is open. * * @return true if, and only if, this channel is open */ diff --git a/jdk/src/share/classes/java/nio/channels/FileChannel.java b/jdk/src/share/classes/java/nio/channels/FileChannel.java index b9fe83db08b..02d9082d230 100644 --- a/jdk/src/share/classes/java/nio/channels/FileChannel.java +++ b/jdk/src/share/classes/java/nio/channels/FileChannel.java @@ -418,7 +418,7 @@ public abstract class FileChannel // -- Other operations -- /** - * Returns this channel's file position.

    + * Returns this channel's file position. * * @return This channel's file position, * a non-negative integer counting the number of bytes @@ -461,7 +461,7 @@ public abstract class FileChannel public abstract FileChannel position(long newPosition) throws IOException; /** - * Returns the current size of this channel's file.

    + * Returns the current size of this channel's file. * * @return The current size of this channel's file, * measured in bytes diff --git a/jdk/src/share/classes/java/nio/channels/FileLock.java b/jdk/src/share/classes/java/nio/channels/FileLock.java index 019b90222fb..e978af43179 100644 --- a/jdk/src/share/classes/java/nio/channels/FileLock.java +++ b/jdk/src/share/classes/java/nio/channels/FileLock.java @@ -124,7 +124,7 @@ public abstract class FileLock implements AutoCloseable { private final boolean shared; /** - * Initializes a new instance of this class.

    + * Initializes a new instance of this class. * * @param channel * The file channel upon whose file this lock is held @@ -249,7 +249,7 @@ public abstract class FileLock implements AutoCloseable { } /** - * Tells whether this lock is shared.

    + * Tells whether this lock is shared. * * @return true if lock is shared, * false if it is exclusive @@ -259,7 +259,7 @@ public abstract class FileLock implements AutoCloseable { } /** - * Tells whether or not this lock overlaps the given lock range.

    + * Tells whether or not this lock overlaps the given lock range. * * @return true if, and only if, this lock and the given lock * range overlap by at least one byte diff --git a/jdk/src/share/classes/java/nio/channels/Pipe.java b/jdk/src/share/classes/java/nio/channels/Pipe.java index c4d7bce7452..af0722e99ab 100644 --- a/jdk/src/share/classes/java/nio/channels/Pipe.java +++ b/jdk/src/share/classes/java/nio/channels/Pipe.java @@ -53,7 +53,7 @@ import java.nio.channels.spi.*; public abstract class Pipe { /** - * A channel representing the readable end of a {@link Pipe}.

    + * A channel representing the readable end of a {@link Pipe}. * * @since 1.4 */ @@ -84,7 +84,7 @@ public abstract class Pipe { } /** - * A channel representing the writable end of a {@link Pipe}.

    + * A channel representing the writable end of a {@link Pipe}. * * @since 1.4 */ @@ -120,14 +120,14 @@ public abstract class Pipe { protected Pipe() { } /** - * Returns this pipe's source channel.

    + * Returns this pipe's source channel. * * @return This pipe's source channel */ public abstract SourceChannel source(); /** - * Returns this pipe's sink channel.

    + * Returns this pipe's sink channel. * * @return This pipe's sink channel */ diff --git a/jdk/src/share/classes/java/nio/channels/SelectableChannel.java b/jdk/src/share/classes/java/nio/channels/SelectableChannel.java index 35569e86ed7..7041c34e188 100644 --- a/jdk/src/share/classes/java/nio/channels/SelectableChannel.java +++ b/jdk/src/share/classes/java/nio/channels/SelectableChannel.java @@ -111,7 +111,7 @@ public abstract class SelectableChannel * identifying this channel's supported operations. The bits that are set * in this integer value denote exactly the operations that are valid for * this channel. This method always returns the same value for a given - * concrete channel class.

    + * concrete channel class. * * @return The valid-operation set */ @@ -140,7 +140,7 @@ public abstract class SelectableChannel /** * Retrieves the key representing the channel's registration with the given - * selector.

    + * selector. * * @return The key returned when this channel was last registered with the * given selector, or null if this channel is not @@ -333,7 +333,6 @@ public abstract class SelectableChannel * configureBlocking} and {@link #register register} methods synchronize. * This is often useful in the implementation of adaptors that require a * specific blocking mode to be maintained for a short period of time. - *

    * * @return The blocking-mode lock object */ diff --git a/jdk/src/share/classes/java/nio/channels/SelectionKey.java b/jdk/src/share/classes/java/nio/channels/SelectionKey.java index 2280cb9e216..7a0ab88ac3e 100644 --- a/jdk/src/share/classes/java/nio/channels/SelectionKey.java +++ b/jdk/src/share/classes/java/nio/channels/SelectionKey.java @@ -119,7 +119,7 @@ public abstract class SelectionKey { /** * Returns the channel for which this key was created. This method will - * continue to return the channel even after the key is cancelled.

    + * continue to return the channel even after the key is cancelled. * * @return This key's channel */ @@ -127,7 +127,7 @@ public abstract class SelectionKey { /** * Returns the selector for which this key was created. This method will - * continue to return the selector even after the key is cancelled.

    + * continue to return the selector even after the key is cancelled. * * @return This key's selector */ @@ -228,7 +228,7 @@ public abstract class SelectionKey { public static final int OP_READ = 1 << 0; /** - * Operation-set bit for write operations.

    + * Operation-set bit for write operations. * *

    Suppose that a selection key's interest set contains * OP_WRITE at the start of a + * Operation-set bit for socket-connect operations. * *

    Suppose that a selection key's interest set contains * OP_CONNECT at the start of a + * Operation-set bit for socket-accept operations. * *

    Suppose that a selection key's interest set contains * OP_ACCEPT at the start of a An invocation of this method of the form k.isConnectable() * behaves in exactly the same way as the expression * - *

    {@code
    +     * 
    {@code
          * k.readyOps() & OP_CONNECT != 0
          * }
    * @@ -389,7 +389,7 @@ public abstract class SelectionKey { } /** - * Retrieves the current attachment.

    + * Retrieves the current attachment. * * @return The object currently attached to this key, * or null if there is no attachment diff --git a/jdk/src/share/classes/java/nio/channels/Selector.java b/jdk/src/share/classes/java/nio/channels/Selector.java index f51b9ed9d2c..d4c200e6942 100644 --- a/jdk/src/share/classes/java/nio/channels/Selector.java +++ b/jdk/src/share/classes/java/nio/channels/Selector.java @@ -228,14 +228,14 @@ public abstract class Selector implements Closeable { } /** - * Tells whether or not this selector is open.

    + * Tells whether or not this selector is open. * * @return true if, and only if, this selector is open */ public abstract boolean isOpen(); /** - * Returns the provider that created this channel.

    + * Returns the provider that created this channel. * * @return The provider that created this channel */ diff --git a/jdk/src/share/classes/java/nio/channels/SocketChannel.java b/jdk/src/share/classes/java/nio/channels/SocketChannel.java index d5f43ba7750..d1274a026a4 100644 --- a/jdk/src/share/classes/java/nio/channels/SocketChannel.java +++ b/jdk/src/share/classes/java/nio/channels/SocketChannel.java @@ -302,7 +302,7 @@ public abstract class SocketChannel /** * Tells whether or not a connection operation is in progress on this - * channel.

    + * channel. * * @return true if, and only if, a connection operation has been * initiated on this channel but not yet completed by invoking the diff --git a/jdk/src/share/classes/java/nio/channels/spi/AbstractSelectionKey.java b/jdk/src/share/classes/java/nio/channels/spi/AbstractSelectionKey.java index 70a0693f962..bf5a4d7c2bf 100644 --- a/jdk/src/share/classes/java/nio/channels/spi/AbstractSelectionKey.java +++ b/jdk/src/share/classes/java/nio/channels/spi/AbstractSelectionKey.java @@ -43,7 +43,7 @@ public abstract class AbstractSelectionKey { /** - * Initializes a new instance of this class.

    + * Initializes a new instance of this class. */ protected AbstractSelectionKey() { } diff --git a/jdk/src/share/classes/java/nio/channels/spi/AbstractSelector.java b/jdk/src/share/classes/java/nio/channels/spi/AbstractSelector.java index daa10ad201d..fea4b0972e9 100644 --- a/jdk/src/share/classes/java/nio/channels/spi/AbstractSelector.java +++ b/jdk/src/share/classes/java/nio/channels/spi/AbstractSelector.java @@ -76,7 +76,7 @@ public abstract class AbstractSelector private final SelectorProvider provider; /** - * Initializes a new instance of this class.

    + * Initializes a new instance of this class. */ protected AbstractSelector(SelectorProvider provider) { this.provider = provider; diff --git a/jdk/src/share/classes/java/nio/channels/spi/SelectorProvider.java b/jdk/src/share/classes/java/nio/channels/spi/SelectorProvider.java index 460e39ecbdc..62d4bf6ffc0 100644 --- a/jdk/src/share/classes/java/nio/channels/spi/SelectorProvider.java +++ b/jdk/src/share/classes/java/nio/channels/spi/SelectorProvider.java @@ -72,7 +72,7 @@ public abstract class SelectorProvider { private static SelectorProvider provider = null; /** - * Initializes a new instance of this class.

    + * Initializes a new instance of this class. * * @throws SecurityException * If a security manager has been installed and it denies @@ -180,7 +180,7 @@ public abstract class SelectorProvider { } /** - * Opens a datagram channel.

    + * Opens a datagram channel. * * @return The new channel */ @@ -206,7 +206,7 @@ public abstract class SelectorProvider { throws IOException; /** - * Opens a pipe.

    + * Opens a pipe. * * @return The new pipe */ @@ -214,7 +214,7 @@ public abstract class SelectorProvider { throws IOException; /** - * Opens a selector.

    + * Opens a selector. * * @return The new selector */ @@ -222,7 +222,7 @@ public abstract class SelectorProvider { throws IOException; /** - * Opens a server-socket channel.

    + * Opens a server-socket channel. * * @return The new channel */ @@ -230,7 +230,7 @@ public abstract class SelectorProvider { throws IOException; /** - * Opens a socket channel.

    + * Opens a socket channel. * * @return The new channel */ diff --git a/jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java.template b/jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java.template index 8b115cc0fd2..34be4eb8375 100644 --- a/jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java.template +++ b/jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java.template @@ -161,7 +161,7 @@ public abstract class Charset$Coder$ { /** * Initializes a new $coder$. The new $coder$ will have the given - * $otypes-per-itype$ and replacement values.

    + * $otypes-per-itype$ and replacement values. * * @param average$ItypesPerOtype$ * A positive float value indicating the expected number of @@ -207,7 +207,7 @@ public abstract class Charset$Coder$ { /** * Initializes a new $coder$. The new $coder$ will have the given * $otypes-per-itype$ values and its replacement will be the - * $replTypeName$ $defaultReplName$.

    + * $replTypeName$ $defaultReplName$. * * @param average$ItypesPerOtype$ * A positive float value indicating the expected number of @@ -230,7 +230,7 @@ public abstract class Charset$Coder$ { } /** - * Returns the charset that created this $coder$.

    + * Returns the charset that created this $coder$. * * @return This $coder$'s charset */ @@ -239,7 +239,7 @@ public abstract class Charset$Coder$ { } /** - * Returns this $coder$'s replacement value.

    + * Returns this $coder$'s replacement value. * * @return This $coder$'s current replacement, * which is never null and is never empty @@ -351,7 +351,7 @@ public abstract class Charset$Coder$ { #end[encoder] /** - * Returns this $coder$'s current action for malformed-input errors.

    + * Returns this $coder$'s current action for malformed-input errors. * * @return The current malformed-input action, which is never null */ @@ -360,7 +360,7 @@ public abstract class Charset$Coder$ { } /** - * Changes this $coder$'s action for malformed-input errors.

    + * Changes this $coder$'s action for malformed-input errors. * *

    This method invokes the {@link #implOnMalformedInput * implOnMalformedInput} method, passing the new action.

    @@ -391,7 +391,6 @@ public abstract class Charset$Coder$ { /** * Returns this $coder$'s current action for unmappable-character errors. - *

    * * @return The current unmappable-character action, which is never * null @@ -435,7 +434,7 @@ public abstract class Charset$Coder$ { /** * Returns the average number of $otype$s that will be produced for each * $itype$ of input. This heuristic value may be used to estimate the size - * of the output buffer required for a given input sequence.

    + * of the output buffer required for a given input sequence. * * @return The average number of $otype$s produced * per $itype$ of input @@ -447,7 +446,7 @@ public abstract class Charset$Coder$ { /** * Returns the maximum number of $otype$s that will be produced for each * $itype$ of input. This value may be used to compute the worst-case size - * of the output buffer required for a given input sequence.

    + * of the output buffer required for a given input sequence. * * @return The maximum number of $otype$s that will be produced per * $itype$ of input diff --git a/jdk/src/share/classes/java/nio/charset/Charset.java b/jdk/src/share/classes/java/nio/charset/Charset.java index 9451c537a36..69c3ab0e19f 100644 --- a/jdk/src/share/classes/java/nio/charset/Charset.java +++ b/jdk/src/share/classes/java/nio/charset/Charset.java @@ -490,7 +490,7 @@ public abstract class Charset } /** - * Tells whether the named charset is supported.

    + * Tells whether the named charset is supported. * * @param charsetName * The name of the requested charset; may be either @@ -510,7 +510,7 @@ public abstract class Charset } /** - * Returns a charset object for the named charset.

    + * Returns a charset object for the named charset. * * @param charsetName * The name of the requested charset; may be either @@ -629,7 +629,7 @@ public abstract class Charset /** * Initializes a new charset with the given canonical name and alias - * set.

    + * set. * * @param canonicalName * The canonical name of this charset @@ -650,7 +650,7 @@ public abstract class Charset } /** - * Returns this charset's canonical name.

    + * Returns this charset's canonical name. * * @return The canonical name of this charset */ @@ -659,7 +659,7 @@ public abstract class Charset } /** - * Returns a set containing this charset's aliases.

    + * Returns a set containing this charset's aliases. * * @return An immutable set of this charset's aliases */ @@ -690,7 +690,7 @@ public abstract class Charset /** * Tells whether or not this charset is registered in the
    IANA Charset - * Registry.

    + * Registry. * * @return true if, and only if, this charset is known by its * implementor to be registered with the IANA @@ -742,14 +742,14 @@ public abstract class Charset public abstract boolean contains(Charset cs); /** - * Constructs a new decoder for this charset.

    + * Constructs a new decoder for this charset. * * @return A new decoder for this charset */ public abstract CharsetDecoder newDecoder(); /** - * Constructs a new encoder for this charset.

    + * Constructs a new encoder for this charset. * * @return A new encoder for this charset * @@ -881,7 +881,7 @@ public abstract class Charset } /** - * Computes a hashcode for this charset.

    + * Computes a hashcode for this charset. * * @return An integer hashcode */ @@ -907,7 +907,7 @@ public abstract class Charset } /** - * Returns a string describing this charset.

    + * Returns a string describing this charset. * * @return A string describing this charset */ diff --git a/jdk/src/share/classes/java/nio/charset/CoderResult.java b/jdk/src/share/classes/java/nio/charset/CoderResult.java index 00f29db07ef..5b2c4d41f89 100644 --- a/jdk/src/share/classes/java/nio/charset/CoderResult.java +++ b/jdk/src/share/classes/java/nio/charset/CoderResult.java @@ -71,7 +71,7 @@ import java.util.HashMap; * * * - * For convenience, the {@link #isError() isError} method returns true + *

    For convenience, the {@link #isError() isError} method returns true * for result objects that describe malformed-input and unmappable-character * errors but false for those that describe underflow or overflow * conditions.

    @@ -112,7 +112,7 @@ public class CoderResult { } /** - * Tells whether or not this object describes an underflow condition.

    + * Tells whether or not this object describes an underflow condition. * * @return true if, and only if, this object denotes underflow */ @@ -121,7 +121,7 @@ public class CoderResult { } /** - * Tells whether or not this object describes an overflow condition.

    + * Tells whether or not this object describes an overflow condition. * * @return true if, and only if, this object denotes overflow */ @@ -130,7 +130,7 @@ public class CoderResult { } /** - * Tells whether or not this object describes an error condition.

    + * Tells whether or not this object describes an error condition. * * @return true if, and only if, this object denotes either a * malformed-input error or an unmappable-character error @@ -141,7 +141,6 @@ public class CoderResult { /** * Tells whether or not this object describes a malformed-input error. - *

    * * @return true if, and only if, this object denotes a * malformed-input error @@ -152,7 +151,7 @@ public class CoderResult { /** * Tells whether or not this object describes an unmappable-character - * error.

    + * error. * * @return true if, and only if, this object denotes an * unmappable-character error @@ -163,7 +162,7 @@ public class CoderResult { /** * Returns the length of the erroneous input described by this - * object  (optional operation).

    + * object  (optional operation). * * @return The length of the erroneous input, a positive integer * @@ -180,14 +179,14 @@ public class CoderResult { /** * Result object indicating underflow, meaning that either the input buffer * has been completely consumed or, if the input buffer is not yet empty, - * that additional input is required.

    + * that additional input is required. */ public static final CoderResult UNDERFLOW = new CoderResult(CR_UNDERFLOW, 0); /** * Result object indicating overflow, meaning that there is insufficient - * room in the output buffer.

    + * room in the output buffer. */ public static final CoderResult OVERFLOW = new CoderResult(CR_OVERFLOW, 0); @@ -226,7 +225,7 @@ public class CoderResult { /** * Static factory method that returns the unique object describing a - * malformed-input error of the given length.

    + * malformed-input error of the given length. * * @return The requested coder-result object */ @@ -242,7 +241,7 @@ public class CoderResult { /** * Static factory method that returns the unique result object describing - * an unmappable-character error of the given length.

    + * an unmappable-character error of the given length. * * @return The requested coder-result object */ @@ -252,7 +251,6 @@ public class CoderResult { /** * Throws an exception appropriate to the result described by this object. - *

    * * @throws BufferUnderflowException * If this object is {@link #UNDERFLOW} diff --git a/jdk/src/share/classes/java/nio/charset/CodingErrorAction.java b/jdk/src/share/classes/java/nio/charset/CodingErrorAction.java index 8c9cb2193b2..8ca30e4900b 100644 --- a/jdk/src/share/classes/java/nio/charset/CodingErrorAction.java +++ b/jdk/src/share/classes/java/nio/charset/CodingErrorAction.java @@ -50,7 +50,7 @@ public class CodingErrorAction { /** * Action indicating that a coding error is to be handled by dropping the - * erroneous input and resuming the coding operation.

    + * erroneous input and resuming the coding operation. */ public static final CodingErrorAction IGNORE = new CodingErrorAction("IGNORE"); @@ -58,7 +58,7 @@ public class CodingErrorAction { /** * Action indicating that a coding error is to be handled by dropping the * erroneous input, appending the coder's replacement value to the output - * buffer, and resuming the coding operation.

    + * buffer, and resuming the coding operation. */ public static final CodingErrorAction REPLACE = new CodingErrorAction("REPLACE"); @@ -73,7 +73,7 @@ public class CodingErrorAction { = new CodingErrorAction("REPORT"); /** - * Returns a string describing this action.

    + * Returns a string describing this action. * * @return A descriptive string */ diff --git a/jdk/src/share/classes/java/nio/charset/UnmappableCharacterException.java b/jdk/src/share/classes/java/nio/charset/UnmappableCharacterException.java index 4af924fd1fc..5fa12476d68 100644 --- a/jdk/src/share/classes/java/nio/charset/UnmappableCharacterException.java +++ b/jdk/src/share/classes/java/nio/charset/UnmappableCharacterException.java @@ -29,7 +29,7 @@ package java.nio.charset; /** * Checked exception thrown when an input character (or byte) sequence * is valid but cannot be mapped to an output byte (or character) - * sequence.

    + * sequence. * * @since 1.4 */ diff --git a/jdk/src/share/classes/java/nio/charset/spi/CharsetProvider.java b/jdk/src/share/classes/java/nio/charset/spi/CharsetProvider.java index a4d646a86e2..3525e201d87 100644 --- a/jdk/src/share/classes/java/nio/charset/spi/CharsetProvider.java +++ b/jdk/src/share/classes/java/nio/charset/spi/CharsetProvider.java @@ -72,7 +72,7 @@ import java.util.Iterator; public abstract class CharsetProvider { /** - * Initializes a new charset provider.

    + * Initializes a new charset provider. * * @throws SecurityException * If a security manager has been installed and it denies @@ -88,14 +88,14 @@ public abstract class CharsetProvider { * Creates an iterator that iterates over the charsets supported by this * provider. This method is used in the implementation of the {@link * java.nio.charset.Charset#availableCharsets Charset.availableCharsets} - * method.

    + * method. * * @return The new iterator */ public abstract Iterator charsets(); /** - * Retrieves a charset for the given charset name.

    + * Retrieves a charset for the given charset name. * * @param charsetName * The name of the requested charset; may be either From d233c11556944101cc679a5f6c6b559884e01459 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 12 Jun 2013 09:44:34 +0100 Subject: [PATCH 192/206] 8016369: java/lang/instrument/RetransformBigClass.sh failing again Reviewed-by: sla, sergei --- jdk/test/java/lang/instrument/MakeJAR4.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/test/java/lang/instrument/MakeJAR4.sh b/jdk/test/java/lang/instrument/MakeJAR4.sh index 0f6e9f6cbc4..91a7e8dd0dd 100644 --- a/jdk/test/java/lang/instrument/MakeJAR4.sh +++ b/jdk/test/java/lang/instrument/MakeJAR4.sh @@ -43,4 +43,4 @@ while [ $# != 0 ] ; do done -${JAR} "${TESTTOOLVMOPTS}" cvfm ${AGENT}.jar ${AGENT}.mf ${AGENT}*.class ${OTHER}*.java +${JAR} ${TESTTOOLVMOPTS} cvfm ${AGENT}.jar ${AGENT}.mf ${AGENT}*.class ${OTHER}*.java From e19945c794b759f9ca34ab39f9f80b9a8739a6a8 Mon Sep 17 00:00:00 2001 From: Brent Christian Date: Wed, 12 Jun 2013 11:11:59 -0700 Subject: [PATCH 193/206] 8010325: Remove hash32() method and hash32 int field from java.lang.String Reviewed-by: alanb, mduigou --- jdk/src/share/classes/java/lang/String.java | 97 ------- jdk/src/share/classes/java/util/HashMap.java | 7 +- .../share/classes/java/util/Hashtable.java | 7 +- .../share/classes/java/util/WeakHashMap.java | 4 +- jdk/src/share/classes/sun/misc/Hashing.java | 239 ------------------ jdk/test/sun/misc/Hashing.java | 127 ---------- 6 files changed, 13 insertions(+), 468 deletions(-) delete mode 100644 jdk/src/share/classes/sun/misc/Hashing.java delete mode 100644 jdk/test/sun/misc/Hashing.java diff --git a/jdk/src/share/classes/java/lang/String.java b/jdk/src/share/classes/java/lang/String.java index 748c8a4bbef..651a85017ed 100644 --- a/jdk/src/share/classes/java/lang/String.java +++ b/jdk/src/share/classes/java/lang/String.java @@ -3156,101 +3156,4 @@ public final class String * guaranteed to be from a pool of unique strings. */ public native String intern(); - - /** - * Seed value used for each alternative hash calculated. - */ - private static final int HASHING_SEED; - - static { - long nanos = System.nanoTime(); - long now = System.currentTimeMillis(); - int SEED_MATERIAL[] = { - System.identityHashCode(String.class), - System.identityHashCode(System.class), - (int) (nanos >>> 32), - (int) nanos, - (int) (now >>> 32), - (int) now, - (int) (System.nanoTime() >>> 2) - }; - - // Use murmur3 to scramble the seeding material. - // Inline implementation to avoid loading classes - int h1 = 0; - - // body - for(int k1 : SEED_MATERIAL) { - k1 *= 0xcc9e2d51; - k1 = (k1 << 15) | (k1 >>> 17); - k1 *= 0x1b873593; - - h1 ^= k1; - h1 = (h1 << 13) | (h1 >>> 19); - h1 = h1 * 5 + 0xe6546b64; - } - - // tail (always empty, as body is always 32-bit chunks) - - // finalization - - h1 ^= SEED_MATERIAL.length * 4; - - // finalization mix force all bits of a hash block to avalanche - h1 ^= h1 >>> 16; - h1 *= 0x85ebca6b; - h1 ^= h1 >>> 13; - h1 *= 0xc2b2ae35; - h1 ^= h1 >>> 16; - - HASHING_SEED = h1; - } - - /** - * Cached value of the hashing algorithm result - */ - private transient int hash32 = 0; - - /** - * Return a 32-bit hash code value for this object. - *

    - * The general contract of {@code hash32} is: - *

      - *
    • Whenever it is invoked on the same object more than once during - * an execution of a Java application, the {@code hash32} method - * must consistently return the same integer, provided no information - * used in {@code equals} comparisons on the object is modified. - * This integer need not remain consistent from one execution of an - * application to another execution of the same application. - *
    • If two objects are equal according to the {@code equals(Object)} - * method, then calling the {@code hash32} method on each of - * the two objects must produce the same integer result. - *
    • It is not required that if two objects are unequal - * according to the {@link java.lang.Object#equals(java.lang.Object)} - * method, then calling the {@code hash32} method on each of the - * two objects must produce distinct integer results. However, the - * programmer should be aware that producing distinct integer results - * for unequal objects may improve the performance of hash tables. - *
    - * - * The hash value will never be zero. - * - * @return a hash code value for this object. - * @see java.lang.Object#equals(java.lang.Object) - */ - public int hash32() { - int h = hash32; - if (0 == h) { - // harmless data race on hash32 here. - h = sun.misc.Hashing.murmur3_32(HASHING_SEED, value, 0, value.length); - - // ensure result is not zero to avoid recalcing - h = (0 != h) ? h : 1; - - hash32 = h; - } - - return h; - } - } diff --git a/jdk/src/share/classes/java/util/HashMap.java b/jdk/src/share/classes/java/util/HashMap.java index c9b106ff759..55f28011689 100644 --- a/jdk/src/share/classes/java/util/HashMap.java +++ b/jdk/src/share/classes/java/util/HashMap.java @@ -28,6 +28,7 @@ package java.util; import java.io.*; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +import java.util.concurrent.ThreadLocalRandom; import java.util.function.Consumer; import java.util.function.BiFunction; import java.util.function.Function; @@ -912,7 +913,8 @@ public class HashMap */ final int initHashSeed() { if (sun.misc.VM.isBooted() && Holder.USE_HASHSEED) { - return sun.misc.Hashing.randomHashSeed(this); + int seed = ThreadLocalRandom.current().nextInt(); + return (seed != 0) ? seed : 1; } return 0; } @@ -2572,8 +2574,9 @@ public class HashMap // set other fields that need values if (Holder.USE_HASHSEED) { + int seed = ThreadLocalRandom.current().nextInt(); Holder.UNSAFE.putIntVolatile(this, Holder.HASHSEED_OFFSET, - sun.misc.Hashing.randomHashSeed(this)); + (seed != 0) ? seed : 1); } table = EMPTY_TABLE; diff --git a/jdk/src/share/classes/java/util/Hashtable.java b/jdk/src/share/classes/java/util/Hashtable.java index a078aa3e207..50b3f8b4366 100644 --- a/jdk/src/share/classes/java/util/Hashtable.java +++ b/jdk/src/share/classes/java/util/Hashtable.java @@ -26,6 +26,7 @@ package java.util; import java.io.*; +import java.util.concurrent.ThreadLocalRandom; import java.util.function.BiConsumer; import java.util.function.Function; import java.util.function.BiFunction; @@ -219,7 +220,8 @@ public class Hashtable */ final int initHashSeed() { if (sun.misc.VM.isBooted() && Holder.USE_HASHSEED) { - return sun.misc.Hashing.randomHashSeed(this); + int seed = ThreadLocalRandom.current().nextInt(); + return (seed != 0) ? seed : 1; } return 0; } @@ -1206,8 +1208,9 @@ public class Hashtable // set hashMask if (Holder.USE_HASHSEED) { + int seed = ThreadLocalRandom.current().nextInt(); Holder.UNSAFE.putIntVolatile(this, Holder.HASHSEED_OFFSET, - sun.misc.Hashing.randomHashSeed(this)); + (seed != 0) ? seed : 1); } // Read the original length of the array and number of elements diff --git a/jdk/src/share/classes/java/util/WeakHashMap.java b/jdk/src/share/classes/java/util/WeakHashMap.java index 183909afd1e..d354a773c8c 100644 --- a/jdk/src/share/classes/java/util/WeakHashMap.java +++ b/jdk/src/share/classes/java/util/WeakHashMap.java @@ -27,6 +27,7 @@ package java.util; import java.lang.ref.WeakReference; import java.lang.ref.ReferenceQueue; +import java.util.concurrent.ThreadLocalRandom; import java.util.function.Consumer; @@ -215,7 +216,8 @@ public class WeakHashMap if (sun.misc.VM.isBooted() && Holder.USE_HASHSEED) { // Do not set hashSeed more than once! // assert hashSeed == 0; - hashSeed = sun.misc.Hashing.randomHashSeed(this); + int seed = ThreadLocalRandom.current().nextInt(); + hashSeed = (seed != 0) ? seed : 1; } } diff --git a/jdk/src/share/classes/sun/misc/Hashing.java b/jdk/src/share/classes/sun/misc/Hashing.java deleted file mode 100644 index 39ed201da3e..00000000000 --- a/jdk/src/share/classes/sun/misc/Hashing.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package sun.misc; - -import java.util.concurrent.ThreadLocalRandom; - -/** - * Hashing utilities. - * - * Little endian implementations of Murmur3 hashing. - */ -public class Hashing { - - /** - * Static utility methods only. - */ - private Hashing() { - throw new Error("No instances"); - } - - public static int murmur3_32(byte[] data) { - return murmur3_32(0, data, 0, data.length); - } - - public static int murmur3_32(int seed, byte[] data) { - return murmur3_32(seed, data, 0, data.length); - } - - @SuppressWarnings("fallthrough") - public static int murmur3_32(int seed, byte[] data, int offset, int len) { - int h1 = seed; - int count = len; - - // body - while (count >= 4) { - int k1 = (data[offset] & 0x0FF) - | (data[offset + 1] & 0x0FF) << 8 - | (data[offset + 2] & 0x0FF) << 16 - | data[offset + 3] << 24; - - count -= 4; - offset += 4; - - k1 *= 0xcc9e2d51; - k1 = Integer.rotateLeft(k1, 15); - k1 *= 0x1b873593; - - h1 ^= k1; - h1 = Integer.rotateLeft(h1, 13); - h1 = h1 * 5 + 0xe6546b64; - } - - // tail - - if (count > 0) { - int k1 = 0; - - switch (count) { - case 3: - k1 ^= (data[offset + 2] & 0xff) << 16; - // fall through - case 2: - k1 ^= (data[offset + 1] & 0xff) << 8; - // fall through - case 1: - k1 ^= (data[offset] & 0xff); - // fall through - default: - k1 *= 0xcc9e2d51; - k1 = Integer.rotateLeft(k1, 15); - k1 *= 0x1b873593; - h1 ^= k1; - } - } - - // finalization - - h1 ^= len; - - // finalization mix force all bits of a hash block to avalanche - h1 ^= h1 >>> 16; - h1 *= 0x85ebca6b; - h1 ^= h1 >>> 13; - h1 *= 0xc2b2ae35; - h1 ^= h1 >>> 16; - - return h1; - } - - public static int murmur3_32(char[] data) { - return murmur3_32(0, data, 0, data.length); - } - - public static int murmur3_32(int seed, char[] data) { - return murmur3_32(seed, data, 0, data.length); - } - - public static int murmur3_32(int seed, char[] data, int offset, int len) { - int h1 = seed; - - int off = offset; - int count = len; - - // body - while (count >= 2) { - int k1 = (data[off++] & 0xFFFF) | (data[off++] << 16); - - count -= 2; - - k1 *= 0xcc9e2d51; - k1 = Integer.rotateLeft(k1, 15); - k1 *= 0x1b873593; - - h1 ^= k1; - h1 = Integer.rotateLeft(h1, 13); - h1 = h1 * 5 + 0xe6546b64; - } - - // tail - - if (count > 0) { - int k1 = data[off]; - - k1 *= 0xcc9e2d51; - k1 = Integer.rotateLeft(k1, 15); - k1 *= 0x1b873593; - h1 ^= k1; - } - - // finalization - - h1 ^= len * (Character.SIZE / Byte.SIZE); - - // finalization mix force all bits of a hash block to avalanche - h1 ^= h1 >>> 16; - h1 *= 0x85ebca6b; - h1 ^= h1 >>> 13; - h1 *= 0xc2b2ae35; - h1 ^= h1 >>> 16; - - return h1; - } - - public static int murmur3_32(int[] data) { - return murmur3_32(0, data, 0, data.length); - } - - public static int murmur3_32(int seed, int[] data) { - return murmur3_32(seed, data, 0, data.length); - } - - public static int murmur3_32(int seed, int[] data, int offset, int len) { - int h1 = seed; - - int off = offset; - int end = offset + len; - - // body - while (off < end) { - int k1 = data[off++]; - - k1 *= 0xcc9e2d51; - k1 = Integer.rotateLeft(k1, 15); - k1 *= 0x1b873593; - - h1 ^= k1; - h1 = Integer.rotateLeft(h1, 13); - h1 = h1 * 5 + 0xe6546b64; - } - - // tail (always empty, as body is always 32-bit chunks) - - // finalization - - h1 ^= len * (Integer.SIZE / Byte.SIZE); - - // finalization mix force all bits of a hash block to avalanche - h1 ^= h1 >>> 16; - h1 *= 0x85ebca6b; - h1 ^= h1 >>> 13; - h1 *= 0xc2b2ae35; - h1 ^= h1 >>> 16; - - return h1; - } - - /** - * Return a non-zero 32-bit pseudo random value. The {@code instance} object - * may be used as part of the value. - * - * @param instance an object to use if desired in choosing value. - * @return a non-zero 32-bit pseudo random value. - */ - public static int randomHashSeed(Object instance) { - int seed; - if (sun.misc.VM.isBooted()) { - seed = ThreadLocalRandom.current().nextInt(); - } else { - // lower quality "random" seed value--still better than zero and not - // not practically reversible. - int hashing_seed[] = { - System.identityHashCode(Hashing.class), - System.identityHashCode(instance), - System.identityHashCode(Thread.currentThread()), - (int) Thread.currentThread().getId(), - (int) (System.currentTimeMillis() >>> 2), // resolution is poor - (int) (System.nanoTime() >>> 5), // resolution is poor - (int) (Runtime.getRuntime().freeMemory() >>> 4) // alloc min - }; - - seed = murmur3_32(hashing_seed); - } - - // force to non-zero. - return (0 != seed) ? seed : 1; - } -} diff --git a/jdk/test/sun/misc/Hashing.java b/jdk/test/sun/misc/Hashing.java deleted file mode 100644 index 0b5baeff368..00000000000 --- a/jdk/test/sun/misc/Hashing.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2012, 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 @summary Ensure that Murmur3 hash performs according to specification. - * @compile -XDignore.symbol.file Hashing.java - */ -public class Hashing { - - static final byte ONE_BYTE[] = { - (byte) 0x80}; - static final byte TWO_BYTE[] = { - (byte) 0x80, (byte) 0x81}; - static final char ONE_CHAR[] = { - (char) 0x8180}; - static final byte THREE_BYTE[] = { - (byte) 0x80, (byte) 0x81, (byte) 0x82}; - static final byte FOUR_BYTE[] = { - (byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83}; - static final char TWO_CHAR[] = { - (char) 0x8180, (char) 0x8382}; - static final int ONE_INT[] = { - 0x83828180}; - static final byte SIX_BYTE[] = { - (byte) 0x80, (byte) 0x81, (byte) 0x82, - (byte) 0x83, (byte) 0x84, (byte) 0x85}; - static final char THREE_CHAR[] = { - (char) 0x8180, (char) 0x8382, (char) 0x8584}; - static final byte EIGHT_BYTE[] = { - (byte) 0x80, (byte) 0x81, (byte) 0x82, - (byte) 0x83, (byte) 0x84, (byte) 0x85, - (byte) 0x86, (byte) 0x87}; - static final char FOUR_CHAR[] = { - (char) 0x8180, (char) 0x8382, - (char) 0x8584, (char) 0x8786}; - static final int TWO_INT[] = { - 0x83828180, 0x87868584}; - // per http://code.google.com/p/smhasher/source/browse/trunk/main.cpp, line:72 - static final int MURMUR3_32_X86_CHECK_VALUE = 0xB0F57EE3; - - public static void testMurmur3_32_ByteArray() { - System.out.println("testMurmur3_32_ByteArray"); - - byte[] vector = new byte[256]; - byte[] hashes = new byte[4 * 256]; - - for (int i = 0; i < 256; i++) { - vector[i] = (byte) i; - } - - // Hash subranges {}, {0}, {0,1}, {0,1,2}, ..., {0,...,255} - for (int i = 0; i < 256; i++) { - int hash = sun.misc.Hashing.murmur3_32(256 - i, vector, 0, i); - - hashes[i * 4] = (byte) hash; - hashes[i * 4 + 1] = (byte) (hash >>> 8); - hashes[i * 4 + 2] = (byte) (hash >>> 16); - hashes[i * 4 + 3] = (byte) (hash >>> 24); - } - - // hash to get final result. - int final_hash = sun.misc.Hashing.murmur3_32(0, hashes); - - if (MURMUR3_32_X86_CHECK_VALUE != final_hash) { - throw new RuntimeException( - String.format("Calculated hash result not as expected. Expected %08X got %08X", - MURMUR3_32_X86_CHECK_VALUE, - final_hash)); - } - } - - public static void testEquivalentHashes() { - int bytes, chars, ints; - - System.out.println("testEquivalentHashes"); - - bytes = sun.misc.Hashing.murmur3_32(TWO_BYTE); - chars = sun.misc.Hashing.murmur3_32(ONE_CHAR); - if (bytes != chars) { - throw new RuntimeException(String.format("Hashes did not match. b:%08x != c:%08x", bytes, chars)); - } - - bytes = sun.misc.Hashing.murmur3_32(FOUR_BYTE); - chars = sun.misc.Hashing.murmur3_32(TWO_CHAR); - ints = sun.misc.Hashing.murmur3_32(ONE_INT); - if ((bytes != chars) || (bytes != ints)) { - throw new RuntimeException(String.format("Hashes did not match. b:%08x != c:%08x != i:%08x", bytes, chars, ints)); - } - bytes = sun.misc.Hashing.murmur3_32(SIX_BYTE); - chars = sun.misc.Hashing.murmur3_32(THREE_CHAR); - if (bytes != chars) { - throw new RuntimeException(String.format("Hashes did not match. b:%08x != c:%08x", bytes, chars)); - } - - bytes = sun.misc.Hashing.murmur3_32(EIGHT_BYTE); - chars = sun.misc.Hashing.murmur3_32(FOUR_CHAR); - ints = sun.misc.Hashing.murmur3_32(TWO_INT); - if ((bytes != chars) || (bytes != ints)) { - throw new RuntimeException(String.format("Hashes did not match. b:%08x != c:%08x != i:%08x", bytes, chars, ints)); - } - } - - public static void main(String[] args) { - testMurmur3_32_ByteArray(); - testEquivalentHashes(); - } -} From 5a6e3cdfded5ab060055aa16554ce632db345d1e Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Wed, 12 Jun 2013 14:07:14 -0700 Subject: [PATCH 194/206] 8016448: java/util/BitSet/BitSetStreamTest.java no longer compiles, missed by 8015895 Reviewed-by: mduigou --- jdk/test/java/util/BitSet/BitSetStreamTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jdk/test/java/util/BitSet/BitSetStreamTest.java b/jdk/test/java/util/BitSet/BitSetStreamTest.java index a7fae5c9421..394f3ac3337 100644 --- a/jdk/test/java/util/BitSet/BitSetStreamTest.java +++ b/jdk/test/java/util/BitSet/BitSetStreamTest.java @@ -65,10 +65,10 @@ public class BitSetStreamTest { { "index 0", IntStream.of(0) }, { "index 255", IntStream.of(255) }, { "every bit", IntStream.range(0, 255) }, - { "step 2", IntStream.range(0, 255, 2) }, - { "step 3", IntStream.range(0, 255, 3) }, - { "step 5", IntStream.range(0, 255, 5) }, - { "step 7", IntStream.range(0, 255, 7) }, + { "step 2", IntStream.range(0, 255).map(f -> f * 2) }, + { "step 3", IntStream.range(0, 255).map(f -> f * 3) }, + { "step 5", IntStream.range(0, 255).map(f -> f * 5) }, + { "step 7", IntStream.range(0, 255).map(f -> f * 7) }, { "1, 10, 100, 1000", IntStream.of(1, 10, 100, 1000) }, { "25 fibs", IntStream.generate(new Fibs()).limit(25) } }; From 77e684366c45f5e2dc0eb93a904273de60a3734e Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Thu, 13 Jun 2013 09:59:29 +0800 Subject: [PATCH 195/206] 8014310: JAAS/Krb5LoginModule using des encytypes failure with NPE after JDK-8012679 Reviewed-by: valeriep --- .../classes/sun/security/krb5/Config.java | 27 ++++----- .../sun/security/krb5/EncryptionKey.java | 33 ----------- .../classes/sun/security/krb5/KrbApReq.java | 4 -- .../classes/sun/security/krb5/KrbTgsReq.java | 7 +-- .../security/krb5/internal/crypto/EType.java | 16 +++--- .../security/krb5/internal/ktab/KeyTab.java | 32 ++--------- .../sun/security/krb5/auto/BasicKrb5Test.java | 11 ++-- jdk/test/sun/security/krb5/auto/OneKDC.java | 11 +++- .../sun/security/krb5/auto/OnlyDesLogin.java | 56 +++++++++++++++++++ 9 files changed, 96 insertions(+), 101 deletions(-) create mode 100644 jdk/test/sun/security/krb5/auto/OnlyDesLogin.java diff --git a/jdk/src/share/classes/sun/security/krb5/Config.java b/jdk/src/share/classes/sun/security/krb5/Config.java index 1b63cd60295..5771886023c 100644 --- a/jdk/src/share/classes/sun/security/krb5/Config.java +++ b/jdk/src/share/classes/sun/security/krb5/Config.java @@ -761,22 +761,23 @@ public class Config { } /** - * Returns the default encryption types. - * + * Returns all etypes specified in krb5.conf for the given configName, + * or all the builtin defaults. This result is always non-empty. + * If no etypes are found, an exception is thrown. */ - public int[] defaultEtype(String enctypes) { + public int[] defaultEtype(String configName) throws KrbException { String default_enctypes; - default_enctypes = get("libdefaults", enctypes); - String delim = " "; - StringTokenizer st; + default_enctypes = get("libdefaults", configName); int[] etype; if (default_enctypes == null) { if (DEBUG) { System.out.println("Using builtin default etypes for " + - enctypes); + configName); } etype = EType.getBuiltInDefaults(); } else { + String delim = " "; + StringTokenizer st; for (int j = 0; j < default_enctypes.length(); j++) { if (default_enctypes.substring(j, j + 1).equals(",")) { // only two delimiters are allowed to use @@ -791,17 +792,13 @@ public class Config { int type; for (int i = 0; i < len; i++) { type = Config.getType(st.nextToken()); - if ((type != -1) && - (EType.isSupported(type))) { + if (type != -1 && EType.isSupported(type)) { ls.add(type); } } if (ls.isEmpty()) { - if (DEBUG) { - System.out.println( - "no supported default etypes for " + enctypes); - } - return null; + throw new KrbException("no supported default etypes for " + + configName); } else { etype = new int[ls.size()]; for (int i = 0; i < etype.length; i++) { @@ -811,7 +808,7 @@ public class Config { } if (DEBUG) { - System.out.print("default etypes for " + enctypes + ":"); + System.out.print("default etypes for " + configName + ":"); for (int i = 0; i < etype.length; i++) { System.out.print(" " + etype[i]); } diff --git a/jdk/src/share/classes/sun/security/krb5/EncryptionKey.java b/jdk/src/share/classes/sun/security/krb5/EncryptionKey.java index ba27220f66f..155ccf67138 100644 --- a/jdk/src/share/classes/sun/security/krb5/EncryptionKey.java +++ b/jdk/src/share/classes/sun/security/krb5/EncryptionKey.java @@ -97,36 +97,6 @@ public class EncryptionKey return new EncryptionKey(keyValue, keyType, kvno); } - /** - * Obtains the latest version of the secret key of - * the principal from a keytab. - * - * @param princ the principal whose secret key is desired - * @param keytab the path to the keytab file. A value of null - * will be accepted to indicate that the default path should be - * searched. - * @returns the secret key or null if none was found. - */ - /* - // Replaced by acquireSecretKeys - public static EncryptionKey acquireSecretKey(PrincipalName princ, - String keytab) - throws KrbException, IOException { - - if (princ == null) { - throw new IllegalArgumentException( - "Cannot have null pricipal name to look in keytab."); - } - - KeyTab ktab = KeyTab.getInstance(keytab); - - if (ktab == null) - return null; - - return ktab.readServiceKey(princ); - } - */ - /** * Obtains all versions of the secret key of the principal from a * keytab. @@ -208,9 +178,6 @@ public class EncryptionKey String salt) throws KrbException { int[] etypes = EType.getDefaults("default_tkt_enctypes"); - if (etypes == null) { - etypes = EType.getBuiltInDefaults(); - } EncryptionKey[] encKeys = new EncryptionKey[etypes.length]; for (int i = 0; i < etypes.length; i++) { diff --git a/jdk/src/share/classes/sun/security/krb5/KrbApReq.java b/jdk/src/share/classes/sun/security/krb5/KrbApReq.java index 2bc01f693f5..7ea5d85bf36 100644 --- a/jdk/src/share/classes/sun/security/krb5/KrbApReq.java +++ b/jdk/src/share/classes/sun/security/krb5/KrbApReq.java @@ -490,10 +490,6 @@ public class KrbApReq { // Check that key is one of the permitted types private static void checkPermittedEType(int target) throws KrbException { int[] etypes = EType.getDefaults("permitted_enctypes"); - if (etypes == null) { - throw new KrbException( - "No supported encryption types listed in permitted_enctypes"); - } if (!EType.isSupported(target, etypes)) { throw new KrbException(EType.toString(target) + " encryption type not in permitted_enctypes list"); diff --git a/jdk/src/share/classes/sun/security/krb5/KrbTgsReq.java b/jdk/src/share/classes/sun/security/krb5/KrbTgsReq.java index 32263b53770..fa599e47892 100644 --- a/jdk/src/share/classes/sun/security/krb5/KrbTgsReq.java +++ b/jdk/src/share/classes/sun/security/krb5/KrbTgsReq.java @@ -291,8 +291,7 @@ public class KrbTgsReq { Ticket[] additionalTickets, EncryptionKey subKey, PAData extraPA) - throws Asn1Exception, IOException, KdcErrException, KrbApErrException, - UnknownHostException, KrbCryptoException { + throws IOException, KrbException, UnknownHostException { KerberosTime req_till = null; if (till == null) { req_till = new KerberosTime(0); @@ -314,10 +313,6 @@ public class KrbTgsReq { int[] req_eTypes = null; if (eTypes == null) { req_eTypes = EType.getDefaults("default_tgs_enctypes"); - if (req_eTypes == null) { - throw new KrbCryptoException( - "No supported encryption types listed in default_tgs_enctypes"); - } } else { req_eTypes = eTypes; } diff --git a/jdk/src/share/classes/sun/security/krb5/internal/crypto/EType.java b/jdk/src/share/classes/sun/security/krb5/internal/crypto/EType.java index 91d0c2faada..534bc8fcfbc 100644 --- a/jdk/src/share/classes/sun/security/krb5/internal/crypto/EType.java +++ b/jdk/src/share/classes/sun/security/krb5/internal/crypto/EType.java @@ -230,11 +230,14 @@ public abstract class EType { /** * Retrieves the default etypes from the configuration file, or * if that's not available, return the built-in list of default etypes. + * This result is always non-empty. If no etypes are found, + * an exception is thrown. */ - // used in KrbAsReq, KeyTab - public static int[] getDefaults(String configName) { + public static int[] getDefaults(String configName) + throws KrbException { + Config config = null; try { - return Config.getInstance().defaultEtype(configName); + config = Config.getInstance(); } catch (KrbException exc) { if (DEBUG) { System.out.println("Exception while getting " + @@ -243,6 +246,7 @@ public abstract class EType { } return getBuiltInDefaults(); } + return config.defaultEtype(configName); } /** @@ -254,12 +258,8 @@ public abstract class EType { * we have keys. */ public static int[] getDefaults(String configName, EncryptionKey[] keys) - throws KrbException { + throws KrbException { int[] answer = getDefaults(configName); - if (answer == null) { - throw new KrbException("No supported encryption types listed in " - + configName); - } List list = new ArrayList<>(answer.length); for (int i = 0; i < answer.length; i++) { diff --git a/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java b/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java index c1372ff35f4..4d08539fde0 100644 --- a/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java +++ b/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java @@ -279,8 +279,7 @@ public class KeyTab implements KeyTabConstants { /** * Reads all keys for a service from the keytab file that have - * etypes that have been configured for use. If there are multiple - * keys with same etype, the one with the highest kvno is returned. + * etypes that have been configured for use. * @param service the PrincipalName of the requested service * @return an array containing all the service keys, never null */ @@ -313,35 +312,12 @@ public class KeyTab implements KeyTabConstants { size = keys.size(); EncryptionKey[] retVal = keys.toArray(new EncryptionKey[size]); - // Sort keys according to default_tkt_enctypes - if (DEBUG) { - System.out.println("Ordering keys wrt default_tkt_enctypes list"); - } - - final int[] etypes = EType.getDefaults("default_tkt_enctypes"); - - // Sort the keys, k1 is preferred than k2 if: - // 1. k1's etype appears earlier in etypes than k2's - // 2. If same, k1's KVNO is higher + // Sort the keys by kvno. Sometimes we must choose a single key (say, + // generate encrypted timestamp in AS-REQ). A key with a higher KVNO + // sounds like a newer one. Arrays.sort(retVal, new Comparator() { @Override public int compare(EncryptionKey o1, EncryptionKey o2) { - if (etypes != null) { - int o1EType = o1.getEType(); - int o2EType = o2.getEType(); - if (o1EType != o2EType) { - for (int i=0; i Date: Thu, 13 Jun 2013 10:00:00 +0800 Subject: [PATCH 196/206] 8015274: TEST_BUG: Step2: After selecting 'View Warning Log', it is empty instead of FileNotFound 8015276: TEST_BUG: The 'ptool.test' can't be saved in the 'tmp' folder 8016158: Instruction is not clear on how to use keytool to create JKS store in case Reviewed-by: mullan --- .../sun/security/tools/policytool/Alias.sh | 5 ++ .../security/tools/policytool/ChangeUI.html | 9 ++- .../sun/security/tools/policytool/ChangeUI.sh | 7 +- .../security/tools/policytool/OpenPolicy.sh | 5 ++ .../sun/security/tools/policytool/SaveAs.sh | 5 ++ .../tools/policytool/UpdatePermissions.html | 17 ++--- .../tools/policytool/UpdatePermissions.sh | 6 ++ .../security/tools/policytool/UsePolicy.sh | 5 ++ .../sun/security/tools/policytool/i18n.html | 73 ++++++++++--------- .../sun/security/tools/policytool/i18n.sh | 23 +++++- 10 files changed, 105 insertions(+), 50 deletions(-) diff --git a/jdk/test/sun/security/tools/policytool/Alias.sh b/jdk/test/sun/security/tools/policytool/Alias.sh index 4db8c09b42a..ae1e4082004 100644 --- a/jdk/test/sun/security/tools/policytool/Alias.sh +++ b/jdk/test/sun/security/tools/policytool/Alias.sh @@ -52,6 +52,11 @@ case "$OS" in PS=":" FS="/" ;; + CYGWIN* ) + NULL=/dev/null + PS=";" + FS="/" + ;; Windows* ) NULL=NUL PS=";" diff --git a/jdk/test/sun/security/tools/policytool/ChangeUI.html b/jdk/test/sun/security/tools/policytool/ChangeUI.html index d025716ea03..da22d7b8cf8 100644 --- a/jdk/test/sun/security/tools/policytool/ChangeUI.html +++ b/jdk/test/sun/security/tools/policytool/ChangeUI.html @@ -17,7 +17,8 @@ reading these instructions.

    First, policytool will be invoked.

      -
    1. If testing on Windows, create a temporary directory. (Example: C:\foo\tmp) +
    2. Find (or create) a temporary directory that you have write access to. +(Example: 'C:\foo\tmp' on Windows or '/tmp' on other systems)
    3. Add new policy entry
    4. Add permission:
      @@ -63,9 +64,9 @@ First, policytool will be invoked.

    5. Confirm there are 2 entries in the permission list
    6. Press cancel
    7. Save as "/tmp/p"
      -If testing on Windows, save in the temporary directory created in Step 0. -(Example: Save as "C:\foo\tmp\p.policy") -
    8. Confirm that the file /tmp/p (or C:\foo\tmp\p.policy) looks like +(Or use the temporary directory mentioned in Step 0 if it's not '/tmp'. + For example, "C:\foo\tmp\p" on Windows) +
    9. Confirm that the file created in the previous step looks like
       /* AUTOMATICALLY GENERATED ON Tue Jul 19 16:27:30 CST 2005*/
       /* DO NOT EDIT */
      diff --git a/jdk/test/sun/security/tools/policytool/ChangeUI.sh b/jdk/test/sun/security/tools/policytool/ChangeUI.sh
      index 95e25af1227..1b6a7984087 100644
      --- a/jdk/test/sun/security/tools/policytool/ChangeUI.sh
      +++ b/jdk/test/sun/security/tools/policytool/ChangeUI.sh
      @@ -22,7 +22,7 @@
       #
       
       # @test
      -# @bug  6296772 6293981 6290216
      +# @bug  6296772 6293981 6290216 8015276
       # @summary FilePermission and DelegationPermission, and cancel button
       #
       # @run applet/manual=done ChangeUI.html
      @@ -51,6 +51,11 @@ case "$OS" in
           PS=":"
           FS="/"
           ;;
      +  CYGWIN* )
      +    NULL=/dev/null
      +    PS=";"
      +    FS="/"
      +    ;;
         Windows* )
           NULL=NUL
           PS=";"
      diff --git a/jdk/test/sun/security/tools/policytool/OpenPolicy.sh b/jdk/test/sun/security/tools/policytool/OpenPolicy.sh
      index 5aca3324661..325b817c3d2 100644
      --- a/jdk/test/sun/security/tools/policytool/OpenPolicy.sh
      +++ b/jdk/test/sun/security/tools/policytool/OpenPolicy.sh
      @@ -51,6 +51,11 @@ case "$OS" in
           PS=":"
           FS="/"
           ;;
      +  CYGWIN* )
      +    NULL=/dev/null
      +    PS=";"
      +    FS="/"
      +    ;;
         Windows* )
           NULL=NUL
           PS=";"
      diff --git a/jdk/test/sun/security/tools/policytool/SaveAs.sh b/jdk/test/sun/security/tools/policytool/SaveAs.sh
      index 661ebd99a3e..af18ad96c21 100644
      --- a/jdk/test/sun/security/tools/policytool/SaveAs.sh
      +++ b/jdk/test/sun/security/tools/policytool/SaveAs.sh
      @@ -52,6 +52,11 @@ case "$OS" in
           PS=":"
           FS="/"
           ;;
      +  CYGWIN* )
      +    NULL=/dev/null
      +    PS=";"
      +    FS="/"
      +    ;;
         Windows* )
           NULL=NUL
           PS=";"
      diff --git a/jdk/test/sun/security/tools/policytool/UpdatePermissions.html b/jdk/test/sun/security/tools/policytool/UpdatePermissions.html
      index 2a59b5908ae..31e6fcf7fc3 100644
      --- a/jdk/test/sun/security/tools/policytool/UpdatePermissions.html
      +++ b/jdk/test/sun/security/tools/policytool/UpdatePermissions.html
      @@ -10,8 +10,8 @@ reading these instructions.

      First, policytool will be invoked.

      Then, follow these steps:
      -0) If testing on Windows, create a temporary directory. -(Example: C:\foo\tmp)

      +0) Find (or create) a temporary directory that you have write access to. +(Example: 'C:\foo\tmp' on Windows or '/tmp' on other systems)

      1) Click on the "Add Policy Entry" button in the main policytool window.

      @@ -32,13 +32,10 @@ select "Save As".

      8) In the SaveAs window, enter "/tmp/ptool.test" as the file name and click "OK".
      -If testing on Windows, use the temporary directory created in Step 0. -(Example: Save as "C:\foo\tmp\ptool.test")

      - -9) cat /tmp/ptool.test
      -If testing on Windows, check the contents of the file created in the previous -step.

      +(Or use the temporary directory mentioned in Step 0 if it's not '/tmp'. +For example, "C:\foo\tmp\ptool.test" on Windows)

      +9) Check the content of the file created in the previous step

      10) check to make sure that the new entry is in the policy file.

      @@ -53,8 +50,8 @@ step.

      In the confirmation dialog pop-up, click "OK".

      -Exit policytool. If testing on Windows, delete the temporary directory and its -contents created during this test.

      +Exit policytool. Delete the files created during this test. If the +temporary directory is also newly created, empty and delete it.

      Press "Pass" if ... press "Fail" otherwise.

      diff --git a/jdk/test/sun/security/tools/policytool/UpdatePermissions.sh b/jdk/test/sun/security/tools/policytool/UpdatePermissions.sh index eada9d734cd..05978a38b57 100644 --- a/jdk/test/sun/security/tools/policytool/UpdatePermissions.sh +++ b/jdk/test/sun/security/tools/policytool/UpdatePermissions.sh @@ -23,6 +23,7 @@ # @test # @bug 4218206 +# @bug 8015276 # @summary missing or invalid permission target names in policy tool # # @run applet/manual=done UpdatePermissions.html @@ -51,6 +52,11 @@ case "$OS" in PS=":" FS="/" ;; + CYGWIN* ) + NULL=/dev/null + PS=";" + FS="/" + ;; Windows* ) NULL=NUL PS=";" diff --git a/jdk/test/sun/security/tools/policytool/UsePolicy.sh b/jdk/test/sun/security/tools/policytool/UsePolicy.sh index 3422f2cfc15..c8412389a3b 100644 --- a/jdk/test/sun/security/tools/policytool/UsePolicy.sh +++ b/jdk/test/sun/security/tools/policytool/UsePolicy.sh @@ -51,6 +51,11 @@ case "$OS" in PS=":" FS="/" ;; + CYGWIN* ) + NULL=/dev/null + PS=";" + FS="/" + ;; Windows* ) NULL=NUL PS=";" diff --git a/jdk/test/sun/security/tools/policytool/i18n.html b/jdk/test/sun/security/tools/policytool/i18n.html index 6c70d24398c..b358c50d2d9 100644 --- a/jdk/test/sun/security/tools/policytool/i18n.html +++ b/jdk/test/sun/security/tools/policytool/i18n.html @@ -15,10 +15,15 @@ If at any time an exception is thrown, or if any message is incomprehensible, then the test failed. Otherwise, the test passed.

      +Preparation: Find (or create) a temporary directory that you have write +access to (Example: 'C:\tmp' on Windows or '/tmp' on other systems) and copy +the files "ks", "good", "bad" from the scratch sub-directory of this test's +working directory (the -w argument of jtreg) into the temporary directory. +If 'policy1' or 'policy2' already exists in this directory, remove it. +

      Press "Pass" if ... press "Fail" otherwise.

      -

        -
      1. If testing on Windows, create a temporary directory. (Example: C:\foo\tmp) +
        1. Pull down the 'File' and 'KeyStore' menus and check values
        2. Pull down 'File' menu and select 'View Warning Log'. Confirm FileNotFound.
        3. Pull down 'File' menu and select 'New'. @@ -46,65 +51,65 @@ Press "Pass" if ... press "Fail" otherwise.
        4. Select "play" from Target menu.
        5. Click OK, confirm changed permission.
        6. Type "hello" for 'CodeBase', click on 'Done', and check error message +
        7. Clean up the 'CodeBase' textbox
        8. Type "hello" for 'SignedBy', click on 'Done', and check warning message -
        9. Click, on 'Edit Policy Entry' and 'Remove Policy Entry' +
        10. Click on 'Edit Policy Entry' and 'Remove Policy Entry' and check error messages -
        11. Select policy entry, click on 'Edit Policy Entry', and check pop-up window +
        12. Select policy entry, click on 'Edit Policy Entry', check pop-up window and close it
        13. Select policy entry, click on 'Remove Policy Entry', and check pop-up window
        14. Do not remove the entry, click 'Cancel'.
        15. Pull down 'File' menu and select 'Exit'. Confirm Save option. Click 'Cancel'. -
        16. Select 'File' menu value 'Save' and enter "/tmp/policy1" as the filename.
          - If testing on Windows, use the temporary directory created in Step 0. - (Example: Save as "C:\foo\tmp\policy1")
          - Check status message. +
        17. Select 'File' menu value 'Save' and save into file "policy1" in the + temporary directory. Check status message.
        18. Select 'File' menu value 'New'
        19. Click 'Add Policy Entry', type in "hello" for 'SignedBy' field, click 'Done'. Confirm warning.
        20. Select 'File' menu value 'Open' and confirm save option - (do not save changes) -
        21. Type "/tmp/policy1" (if Windows, "C:\foo\tmp\policy1") for the filename - and confirm warning message
          + (Click 'Cancel', do not save changes)
        22. Pull down 'File' menu, select 'View Warning Log' and confirm KeyStore alias warning
        23. Pull down 'KeyStore' menu and select 'Edit' -
        24. Enter 'foo' as KeyStore URL and check error -
        25. Using keytool create JKS keystore -
        26. Enter KeyStore URL but leave other fields empty. Should succeed. +
        27. Enter 'foo' as KeyStore URL, click 'OK', and check error +
        28. Enter KeyStore URL "file:/tmp/ks" (Or use the temporary directory mentioned + in the preparation if it's not '/tmp'. For example, "file:/C:/tmp/ks" on Windows) + but leave other fields empty. Click 'OK'. Should succeed.
        29. Pull down 'KeyStore' menu and select 'Edit' -
        30. Confirm URL and Type values. -
        31. Enter 'foo' as the provider and check error message. -
        32. Enter 'SUN' as the provider. Should succeed. +
        33. Confirm URL and Type values. The Type should be "jks" +
        34. Enter 'foo' as the provider, click 'OK' and check error message. +
        35. Enter 'SUN' as the provider, click 'OK'. Should succeed.
        36. Pull down 'KeyStore' menu and select 'Edit'
        37. Confirm URL, Type, and Provider values. -
        38. Enter 'foo' as the password URL and check error message. -
        39. Enter URL with bad password and check error message. -
        40. Enter URL with good password. Should succeed. +
        41. Enter 'foo' as the password URL, click 'OK' and check error message. +
        42. Enter URL "file:/tmp/bad" (Or use the temporary directory mentioned in + the preparation if it's not '/tmp'. For example, "file:/C:/tmp/bad" on Windows), + click 'OK' and check error message. +
        43. Enter URL "file:/tmp/good" (Or use the temporary directory mentioned in + the preparation if it's not '/tmp'. For example, "file:/C:/tmp/good" on Windows) + and click 'OK'. Should succeed.
        44. Pull down 'KeyStore' menu and select 'Edit'
        45. Confirm URL, Type, Provider, and Password URL values.
        46. Click OK -
        47. Pull down 'File' menu and select 'Save As'. Enter "/tmp/policy2" - (if Windows, "C:\foo\tmp\policy2"). - Confirm status message.
          +
        48. Pull down 'File' menu and select 'Save As' and save into file "policy2" + in the temporary directory. Confirm status message.
        49. Pull down 'File' menu and select 'New'. -
        50. Pull down 'File' menu and select 'Open'. Enter "/tmp/policy2" - (if Windows, "C:\foo\tmp\policy2"). - Confirm warning message.
          +
        51. Pull down 'File' menu and select 'Open' and open "policy2" in the + temporary directory.
        52. Click on 'Add Policy Entry', enter Codebase 'http://foo', SignedBy 'bar'. Click on 'Done' and confirm alias warning.
        53. Double-Click on just created policy entry, confirm edit window appears. -
        54. Change SignedBy to an alias in previously created keystore. +
        55. Change SignedBy to an 'hello'.
        56. Click on Done and confirm it worked with no warning.
        57. Double-Click on "SignedBy hello" policy entry and confirm edit window appears.
        58. Click on Edit/Remove Principal, confirm errors.
        59. Click on 'Add Principal' and check new window.
        60. Click on 'OK' and confirm error message (no principal name) -
        61. Enter valid KeyStore alias as principal name, click OK and +
        62. Enter 'hello' as principal name, click OK and confirm status message.
        63. Confirm new principal in Principals list. -
        64. Click on 'Done' (creating policy entry), confirm alias warning. +
        65. Click on 'Done' (creating policy entry).
        66. View warning log and confirm X500Principal/KeyStore alias message.
        67. Confirm principal added to policy entry in main window listing.
        68. Double click on that entry. @@ -116,14 +121,14 @@ Press "Pass" if ... press "Fail" otherwise. Confirm name cleared. Type 'foo' as name. Click OK. Confirm error. type 'cn=foo' as name. Click OK. should succeed.
        69. Confirm changed principal in list. -
        70. Click on 'Add Permission', and add any FilePermission. -
        71. Click on 'Done' in Policy Entry window. Confirm alias warning. +
        72. Click on 'Add Permission', and add a FilePermission, choose a target and + an action. Click OK. +
        73. Click on 'Done' in Policy Entry window.
        74. Confirm entries in main window listing.
        75. Select 'File' menu value 'Exit'
        76. Save Changes, confirm status message. -
        77. If testing on Windows, delete the temporary directory and its contents - created during this test. -
        +
      2. Delete all files created during this test. If the temporary directory + is also newly created, empty and delete it.

      diff --git a/jdk/test/sun/security/tools/policytool/i18n.sh b/jdk/test/sun/security/tools/policytool/i18n.sh index 8537d48c708..58b59e060b2 100644 --- a/jdk/test/sun/security/tools/policytool/i18n.sh +++ b/jdk/test/sun/security/tools/policytool/i18n.sh @@ -23,10 +23,13 @@ # @test # @bug 4348370 +# @bug 8015274 +# @bug 8015276 +# @bug 8016158 # @summary policytool not i18n compliant # # @run applet/manual=done i18n.html -# @run shell i18n.sh +# @run shell/timeout=1200 i18n.sh # @run applet/manual=yesno i18n.html # set a few environment variables so that the shell-script can run stand-alone @@ -51,6 +54,11 @@ case "$OS" in PS=":" FS="/" ;; + CYGWIN* ) + NULL=/dev/null + PS=";" + FS="/" + ;; Windows* ) NULL=NUL PS=";" @@ -66,6 +74,19 @@ esac echo "HELLO!" +echo "Checking for $HOME/.java.policy" + +# 8015274 +if [ -e $HOME/.java.policy ]; then + echo "You have a .java.policy file in your HOME directory" + echo "The file must be removed before running this test" + exit 1 +fi + +${TESTJAVA}${FS}bin${FS}keytool -genkeypair -alias hello -dname CN=Hello \ + -storepass changeit -keypass changeit -keystore ks +echo changeit > good +echo badpass > bad ${TESTJAVA}${FS}bin${FS}policytool exit $? From cd61a1e1a557a32e7be9c3649f0d2c8b1ba497bd Mon Sep 17 00:00:00 2001 From: Yong Jeffrey Huang Date: Wed, 12 Jun 2013 23:54:55 -0700 Subject: [PATCH 197/206] 7040556: SimpleDateFormat.format Portuguese Month should not be capitalized Reviewed-by: okutsu --- .../sun/text/resources/pt/FormatData_pt.java | 24 +++++++++---------- jdk/test/sun/text/resources/LocaleData | 18 +++++++++++--- .../sun/text/resources/LocaleDataTest.java | 2 +- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt.java b/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt.java index ec36c0c7045..32e6c1e14b2 100644 --- a/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt.java +++ b/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt.java @@ -103,18 +103,18 @@ public class FormatData_pt extends ParallelListResourceBundle { }, { "MonthAbbreviations", new String[] { - "Jan", // abb january - "Fev", // abb february - "Mar", // abb march - "Abr", // abb april - "Mai", // abb may - "Jun", // abb june - "Jul", // abb july - "Ago", // abb august - "Set", // abb september - "Out", // abb october - "Nov", // abb november - "Dez", // abb december + "jan", // abb january + "fev", // abb february + "mar", // abb march + "abr", // abb april + "mai", // abb may + "jun", // abb june + "jul", // abb july + "ago", // abb august + "set", // abb september + "out", // abb october + "nov", // abb november + "dez", // abb december "" // abb month 13 if applicable } }, diff --git a/jdk/test/sun/text/resources/LocaleData b/jdk/test/sun/text/resources/LocaleData index 7d95a57d7ba..91d4c46b854 100644 --- a/jdk/test/sun/text/resources/LocaleData +++ b/jdk/test/sun/text/resources/LocaleData @@ -28,9 +28,6 @@ FormatData/pt_BR/DateTimePatterns/0={1} {0} FormatData/pt_BR/NumberElements/0=, FormatData/pt_BR/NumberElements/1=. FormatData/pt_BR/NumberElements/2=; -FormatData/pt_BR/MonthAbbreviations/0=Jan -FormatData/pt_BR/MonthAbbreviations/1=Fev -FormatData/pt_BR/MonthAbbreviations/2=Mar FormatData/pt_BR/DayAbbreviations/0=Dom FormatData/pt_BR/DayAbbreviations/1=Seg FormatData/pt_BR/DayAbbreviations/2=Ter @@ -7667,3 +7664,18 @@ LocaleNames/sq/sq=shqip # bug 7074882 FormatData/mt/MonthNames/7=Awwissu FormatData/mt/MonthAbbreviations/7=Aww + +# bug 7040556 +FormatData/pt/MonthAbbreviations/0=jan +FormatData/pt/MonthAbbreviations/1=fev +FormatData/pt/MonthAbbreviations/2=mar +FormatData/pt/MonthAbbreviations/3=abr +FormatData/pt/MonthAbbreviations/4=mai +FormatData/pt/MonthAbbreviations/5=jun +FormatData/pt/MonthAbbreviations/6=jul +FormatData/pt/MonthAbbreviations/7=ago +FormatData/pt/MonthAbbreviations/8=set +FormatData/pt/MonthAbbreviations/9=out +FormatData/pt/MonthAbbreviations/10=nov +FormatData/pt/MonthAbbreviations/11=dez + diff --git a/jdk/test/sun/text/resources/LocaleDataTest.java b/jdk/test/sun/text/resources/LocaleDataTest.java index ca5d7fee153..73cd7e805ad 100644 --- a/jdk/test/sun/text/resources/LocaleDataTest.java +++ b/jdk/test/sun/text/resources/LocaleDataTest.java @@ -35,7 +35,7 @@ * 6645405 6650730 6910489 6573250 6870908 6585666 6716626 6914413 6916787 * 6919624 6998391 7019267 7020960 7025837 7020583 7036905 7066203 7101495 * 7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509 - * 7114053 7074882 + * 7114053 7074882 7040556 * @summary Verify locale data * */ From aed188663e46966de93b8adf8fd52850305cde80 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 13 Jun 2013 11:13:30 +0200 Subject: [PATCH 198/206] 8016251: Balanced spliterator for SpinedBuffer Co-authored-by: Brian Goetz Co-authored-by: Peter Levart Reviewed-by: mduigou --- .../java/util/stream/DoublePipeline.java | 2 +- .../classes/java/util/stream/IntPipeline.java | 2 +- .../java/util/stream/LongPipeline.java | 3 +- .../share/classes/java/util/stream/Node.java | 24 +- .../share/classes/java/util/stream/Nodes.java | 30 +-- .../classes/java/util/stream/SortedOps.java | 12 +- .../java/util/stream/SpinedBuffer.java | 234 ++++++++++++------ .../java/util/stream/DoubleNodeTest.java | 4 +- .../java/util/stream/IntNodeTest.java | 4 +- .../java/util/stream/LongNodeTest.java | 4 +- .../java/util/stream/SpinedBufferTest.java | 6 +- 11 files changed, 202 insertions(+), 123 deletions(-) diff --git a/jdk/src/share/classes/java/util/stream/DoublePipeline.java b/jdk/src/share/classes/java/util/stream/DoublePipeline.java index 5b1b4c7b4f3..c934445b8f0 100644 --- a/jdk/src/share/classes/java/util/stream/DoublePipeline.java +++ b/jdk/src/share/classes/java/util/stream/DoublePipeline.java @@ -461,7 +461,7 @@ abstract class DoublePipeline @Override public final double[] toArray() { return Nodes.flattenDouble((Node.OfDouble) evaluateToArrayNode(Double[]::new)) - .asDoubleArray(); + .asPrimitiveArray(); } // diff --git a/jdk/src/share/classes/java/util/stream/IntPipeline.java b/jdk/src/share/classes/java/util/stream/IntPipeline.java index c96588a6a69..aa7155abbde 100644 --- a/jdk/src/share/classes/java/util/stream/IntPipeline.java +++ b/jdk/src/share/classes/java/util/stream/IntPipeline.java @@ -498,7 +498,7 @@ abstract class IntPipeline @Override public final int[] toArray() { return Nodes.flattenInt((Node.OfInt) evaluateToArrayNode(Integer[]::new)) - .asIntArray(); + .asPrimitiveArray(); } // diff --git a/jdk/src/share/classes/java/util/stream/LongPipeline.java b/jdk/src/share/classes/java/util/stream/LongPipeline.java index 2c7e2f4a032..9cbc9785be4 100644 --- a/jdk/src/share/classes/java/util/stream/LongPipeline.java +++ b/jdk/src/share/classes/java/util/stream/LongPipeline.java @@ -479,7 +479,8 @@ abstract class LongPipeline @Override public final long[] toArray() { - return Nodes.flattenLong((Node.OfLong) evaluateToArrayNode(Long[]::new)).asLongArray(); + return Nodes.flattenLong((Node.OfLong) evaluateToArrayNode(Long[]::new)) + .asPrimitiveArray(); } diff --git a/jdk/src/share/classes/java/util/stream/Node.java b/jdk/src/share/classes/java/util/stream/Node.java index 528c3a6cca2..3cd765a6922 100644 --- a/jdk/src/share/classes/java/util/stream/Node.java +++ b/jdk/src/share/classes/java/util/stream/Node.java @@ -242,7 +242,7 @@ interface Node { * an instance of an Integer[] array with a length of {@link #count()} * and then invokes {@link #copyInto(Integer[], int)} with that * Integer[] array at an offset of 0. This is not efficient and it is - * recommended to invoke {@link #asIntArray()}. + * recommended to invoke {@link #asPrimitiveArray()}. */ @Override default Integer[] asArray(IntFunction generator) { @@ -254,7 +254,7 @@ interface Node { /** * {@inheritDoc} * - * @implSpec the default implementation invokes {@link #asIntArray()} to + * @implSpec the default implementation invokes {@link #asPrimitiveArray()} to * obtain an int[] array then and copies the elements from that int[] * array into the boxed Integer[] array. This is not efficient and it * is recommended to invoke {@link #copyInto(int[], int)}. @@ -264,7 +264,7 @@ interface Node { if (Tripwire.ENABLED) Tripwire.trip(getClass(), "{0} calling Node.OfInt.copyInto(Integer[], int)"); - int[] array = asIntArray(); + int[] array = asPrimitiveArray(); for (int i = 0; i < array.length; i++) { boxed[offset + i] = array[i]; } @@ -285,7 +285,7 @@ interface Node { * * @return an array containing the contents of this {@code Node} */ - int[] asIntArray(); + int[] asPrimitiveArray(); /** * Copies the content of this {@code Node} into an int[] array, starting @@ -362,7 +362,7 @@ interface Node { * an instance of a Long[] array with a length of {@link #count()} and * then invokes {@link #copyInto(Long[], int)} with that Long[] array at * an offset of 0. This is not efficient and it is recommended to - * invoke {@link #asLongArray()}. + * invoke {@link #asPrimitiveArray()}. */ @Override default Long[] asArray(IntFunction generator) { @@ -374,7 +374,7 @@ interface Node { /** * {@inheritDoc} * - * @implSpec the default implementation invokes {@link #asLongArray()} + * @implSpec the default implementation invokes {@link #asPrimitiveArray()} * to obtain a long[] array then and copies the elements from that * long[] array into the boxed Long[] array. This is not efficient and * it is recommended to invoke {@link #copyInto(long[], int)}. @@ -384,7 +384,7 @@ interface Node { if (Tripwire.ENABLED) Tripwire.trip(getClass(), "{0} calling Node.OfInt.copyInto(Long[], int)"); - long[] array = asLongArray(); + long[] array = asPrimitiveArray(); for (int i = 0; i < array.length; i++) { boxed[offset + i] = array[i]; } @@ -405,7 +405,7 @@ interface Node { * * @return an array containing the contents of this {@code Node} */ - long[] asLongArray(); + long[] asPrimitiveArray(); /** * Copies the content of this {@code Node} into a long[] array, starting @@ -485,7 +485,7 @@ interface Node { * an instance of a Double[] array with a length of {@link #count()} and * then invokes {@link #copyInto(Double[], int)} with that Double[] * array at an offset of 0. This is not efficient and it is recommended - * to invoke {@link #asDoubleArray()}. + * to invoke {@link #asPrimitiveArray()}. */ @Override default Double[] asArray(IntFunction generator) { @@ -497,7 +497,7 @@ interface Node { /** * {@inheritDoc} * - * @implSpec the default implementation invokes {@link #asDoubleArray()} + * @implSpec the default implementation invokes {@link #asPrimitiveArray()} * to obtain a double[] array then and copies the elements from that * double[] array into the boxed Double[] array. This is not efficient * and it is recommended to invoke {@link #copyInto(double[], int)}. @@ -507,7 +507,7 @@ interface Node { if (Tripwire.ENABLED) Tripwire.trip(getClass(), "{0} calling Node.OfDouble.copyInto(Double[], int)"); - double[] array = asDoubleArray(); + double[] array = asPrimitiveArray(); for (int i = 0; i < array.length; i++) { boxed[offset + i] = array[i]; } @@ -528,7 +528,7 @@ interface Node { * * @return an array containing the contents of this {@code Node} */ - double[] asDoubleArray(); + double[] asPrimitiveArray(); /** * Copies the content of this {@code Node} into a double[] array, starting diff --git a/jdk/src/share/classes/java/util/stream/Nodes.java b/jdk/src/share/classes/java/util/stream/Nodes.java index 57e8a7c070c..e4ccfb96f9a 100644 --- a/jdk/src/share/classes/java/util/stream/Nodes.java +++ b/jdk/src/share/classes/java/util/stream/Nodes.java @@ -679,7 +679,7 @@ final class Nodes { } @Override - public int[] asIntArray() { + public int[] asPrimitiveArray() { return EMPTY_INT_ARRAY; } } @@ -696,7 +696,7 @@ final class Nodes { } @Override - public long[] asLongArray() { + public long[] asPrimitiveArray() { return EMPTY_LONG_ARRAY; } } @@ -713,7 +713,7 @@ final class Nodes { } @Override - public double[] asDoubleArray() { + public double[] asPrimitiveArray() { return EMPTY_DOUBLE_ARRAY; } } @@ -1395,7 +1395,7 @@ final class Nodes { } @Override - public int[] asIntArray() { + public int[] asPrimitiveArray() { if (array.length == curSize) { return array; } else { @@ -1449,7 +1449,7 @@ final class Nodes { } @Override - public long[] asLongArray() { + public long[] asPrimitiveArray() { if (array.length == curSize) { return array; } else { @@ -1503,7 +1503,7 @@ final class Nodes { } @Override - public double[] asDoubleArray() { + public double[] asPrimitiveArray() { if (array.length == curSize) { return array; } else { @@ -1561,7 +1561,7 @@ final class Nodes { } @Override - public int[] asIntArray() { + public int[] asPrimitiveArray() { int[] array = new int[(int) count()]; copyInto(array, 0); return array; @@ -1594,7 +1594,7 @@ final class Nodes { } @Override - public long[] asLongArray() { + public long[] asPrimitiveArray() { long[] array = new long[(int) count()]; copyInto(array, 0); return array; @@ -1627,7 +1627,7 @@ final class Nodes { } @Override - public double[] asDoubleArray() { + public double[] asPrimitiveArray() { double[] array = new double[(int) count()]; copyInto(array, 0); return array; @@ -1844,9 +1844,9 @@ final class Nodes { } @Override - public int[] asIntArray() { + public int[] asPrimitiveArray() { assert !building : "during building"; - return super.asIntArray(); + return super.asPrimitiveArray(); } @Override @@ -1904,9 +1904,9 @@ final class Nodes { } @Override - public long[] asLongArray() { + public long[] asPrimitiveArray() { assert !building : "during building"; - return super.asLongArray(); + return super.asPrimitiveArray(); } @Override @@ -1964,9 +1964,9 @@ final class Nodes { } @Override - public double[] asDoubleArray() { + public double[] asPrimitiveArray() { assert !building : "during building"; - return super.asDoubleArray(); + return super.asPrimitiveArray(); } @Override diff --git a/jdk/src/share/classes/java/util/stream/SortedOps.java b/jdk/src/share/classes/java/util/stream/SortedOps.java index 976f207f662..7b2a6934b4e 100644 --- a/jdk/src/share/classes/java/util/stream/SortedOps.java +++ b/jdk/src/share/classes/java/util/stream/SortedOps.java @@ -192,7 +192,7 @@ final class SortedOps { else { Node.OfInt n = (Node.OfInt) helper.evaluate(spliterator, true, generator); - int[] content = n.asIntArray(); + int[] content = n.asPrimitiveArray(); Arrays.parallelSort(content); return Nodes.node(content); @@ -231,7 +231,7 @@ final class SortedOps { else { Node.OfLong n = (Node.OfLong) helper.evaluate(spliterator, true, generator); - long[] content = n.asLongArray(); + long[] content = n.asPrimitiveArray(); Arrays.parallelSort(content); return Nodes.node(content); @@ -270,7 +270,7 @@ final class SortedOps { else { Node.OfDouble n = (Node.OfDouble) helper.evaluate(spliterator, true, generator); - double[] content = n.asDoubleArray(); + double[] content = n.asPrimitiveArray(); Arrays.parallelSort(content); return Nodes.node(content); @@ -401,7 +401,7 @@ final class SortedOps { @Override public void end() { - int[] ints = b.asIntArray(); + int[] ints = b.asPrimitiveArray(); Arrays.sort(ints); downstream.begin(ints.length); for (int anInt : ints) @@ -466,7 +466,7 @@ final class SortedOps { @Override public void end() { - long[] longs = b.asLongArray(); + long[] longs = b.asPrimitiveArray(); Arrays.sort(longs); downstream.begin(longs.length); for (long aLong : longs) @@ -531,7 +531,7 @@ final class SortedOps { @Override public void end() { - double[] doubles = b.asDoubleArray(); + double[] doubles = b.asPrimitiveArray(); Arrays.sort(doubles); downstream.begin(doubles.length); for (double aDouble : doubles) diff --git a/jdk/src/share/classes/java/util/stream/SpinedBuffer.java b/jdk/src/share/classes/java/util/stream/SpinedBuffer.java index 68625e2dd1d..77c375612ea 100644 --- a/jdk/src/share/classes/java/util/stream/SpinedBuffer.java +++ b/jdk/src/share/classes/java/util/stream/SpinedBuffer.java @@ -269,25 +269,45 @@ class SpinedBuffer * Return a {@link Spliterator} describing the contents of the buffer. */ public Spliterator spliterator() { - return new Spliterator() { + class Splitr implements Spliterator { // The current spine index int splSpineIndex; + // Last spine index + final int lastSpineIndex; + // The current element index into the current spine int splElementIndex; - // When splSpineIndex >= spineIndex and splElementIndex >= elementIndex then + // Last spine's last element index + 1 + final int lastSpineElementFence; + + // When splSpineIndex >= lastSpineIndex and + // splElementIndex >= lastSpineElementFence then // this spliterator is fully traversed // tryAdvance can set splSpineIndex > spineIndex if the last spine is full // The current spine array - E[] splChunk = (spine == null) ? curChunk : spine[0]; + E[] splChunk; + + Splitr(int firstSpineIndex, int lastSpineIndex, + int firstSpineElementIndex, int lastSpineElementFence) { + this.splSpineIndex = firstSpineIndex; + this.lastSpineIndex = lastSpineIndex; + this.splElementIndex = firstSpineElementIndex; + this.lastSpineElementFence = lastSpineElementFence; + assert spine != null || firstSpineIndex == 0 && lastSpineIndex == 0; + splChunk = (spine == null) ? curChunk : spine[firstSpineIndex]; + } @Override public long estimateSize() { - return (spine == null) - ? (elementIndex - splElementIndex) - : count() - (priorElementCount[splSpineIndex] + splElementIndex); + return (splSpineIndex == lastSpineIndex) + ? (long) lastSpineElementFence - splElementIndex + : // # of elements prior to end - + priorElementCount[lastSpineIndex] + lastSpineElementFence - + // # of elements prior to current + priorElementCount[splSpineIndex] - splElementIndex; } @Override @@ -297,14 +317,14 @@ class SpinedBuffer @Override public boolean tryAdvance(Consumer consumer) { - if (splSpineIndex < spineIndex - || (splSpineIndex == spineIndex && splElementIndex < elementIndex)) { + if (splSpineIndex < lastSpineIndex + || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) { consumer.accept(splChunk[splElementIndex++]); if (splElementIndex == splChunk.length) { splElementIndex = 0; ++splSpineIndex; - if (spine != null && splSpineIndex < spine.length) + if (spine != null && splSpineIndex <= lastSpineIndex) splChunk = spine[splSpineIndex]; } return true; @@ -314,45 +334,47 @@ class SpinedBuffer @Override public void forEachRemaining(Consumer consumer) { - if (splSpineIndex < spineIndex - || (splSpineIndex == spineIndex && splElementIndex < elementIndex)) { + if (splSpineIndex < lastSpineIndex + || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) { int i = splElementIndex; // completed chunks, if any - for (int sp = splSpineIndex; sp < spineIndex; sp++) { + for (int sp = splSpineIndex; sp < lastSpineIndex; sp++) { E[] chunk = spine[sp]; for (; i < chunk.length; i++) { consumer.accept(chunk[i]); } i = 0; } - - // current chunk - E[] chunk = curChunk; - int hElementIndex = elementIndex; + // last (or current uncompleted) chunk + E[] chunk = (splSpineIndex == lastSpineIndex) ? splChunk : spine[lastSpineIndex]; + int hElementIndex = lastSpineElementFence; for (; i < hElementIndex; i++) { consumer.accept(chunk[i]); } - - splSpineIndex = spineIndex; - splElementIndex = elementIndex; + // mark consumed + splSpineIndex = lastSpineIndex; + splElementIndex = lastSpineElementFence; } } @Override public Spliterator trySplit() { - if (splSpineIndex < spineIndex) { - Spliterator ret = Arrays.spliterator(spine[splSpineIndex], - splElementIndex, spine[splSpineIndex].length); - splChunk = spine[++splSpineIndex]; + if (splSpineIndex < lastSpineIndex) { + // split just before last chunk (if it is full this means 50:50 split) + Spliterator ret = new Splitr(splSpineIndex, lastSpineIndex - 1, + splElementIndex, spine[lastSpineIndex-1].length); + // position to start of last chunk + splSpineIndex = lastSpineIndex; splElementIndex = 0; + splChunk = spine[splSpineIndex]; return ret; } - else if (splSpineIndex == spineIndex) { - int t = (elementIndex - splElementIndex) / 2; + else if (splSpineIndex == lastSpineIndex) { + int t = (lastSpineElementFence - splElementIndex) / 2; if (t == 0) return null; else { - Spliterator ret = Arrays.spliterator(curChunk, splElementIndex, splElementIndex + t); + Spliterator ret = Arrays.spliterator(splChunk, splElementIndex, splElementIndex + t); splElementIndex += t; return ret; } @@ -361,7 +383,8 @@ class SpinedBuffer return null; } } - }; + } + return new Splitr(0, spineIndex, 0, elementIndex); } /** @@ -436,7 +459,7 @@ class SpinedBuffer protected abstract T_ARR[] newArrayArray(int size); /** Create a new array of the proper type and size */ - protected abstract T_ARR newArray(int size); + public abstract T_ARR newArray(int size); /** Get the length of an array */ protected abstract int arrayLength(T_ARR array); @@ -555,30 +578,53 @@ class SpinedBuffer arrayForEach(curChunk, 0, elementIndex, consumer); } - abstract class BaseSpliterator> - implements Spliterator { + abstract class BaseSpliterator> + implements Spliterator.OfPrimitive { // The current spine index int splSpineIndex; + // Last spine index + final int lastSpineIndex; + // The current element index into the current spine int splElementIndex; - // When splSpineIndex >= spineIndex and splElementIndex >= elementIndex then + // Last spine's last element index + 1 + final int lastSpineElementFence; + + // When splSpineIndex >= lastSpineIndex and + // splElementIndex >= lastSpineElementFence then // this spliterator is fully traversed // tryAdvance can set splSpineIndex > spineIndex if the last spine is full // The current spine array - T_ARR splChunk = (spine == null) ? curChunk : spine[0]; + T_ARR splChunk; + + BaseSpliterator(int firstSpineIndex, int lastSpineIndex, + int firstSpineElementIndex, int lastSpineElementFence) { + this.splSpineIndex = firstSpineIndex; + this.lastSpineIndex = lastSpineIndex; + this.splElementIndex = firstSpineElementIndex; + this.lastSpineElementFence = lastSpineElementFence; + assert spine != null || firstSpineIndex == 0 && lastSpineIndex == 0; + splChunk = (spine == null) ? curChunk : spine[firstSpineIndex]; + } + + abstract T_SPLITR newSpliterator(int firstSpineIndex, int lastSpineIndex, + int firstSpineElementIndex, int lastSpineElementFence); abstract void arrayForOne(T_ARR array, int index, T_CONS consumer); - abstract T_SPLITER arraySpliterator(T_ARR array, int offset, int len); + abstract T_SPLITR arraySpliterator(T_ARR array, int offset, int len); @Override public long estimateSize() { - return (spine == null) - ? (elementIndex - splElementIndex) - : count() - (priorElementCount[splSpineIndex] + splElementIndex); + return (splSpineIndex == lastSpineIndex) + ? (long) lastSpineElementFence - splElementIndex + : // # of elements prior to end - + priorElementCount[lastSpineIndex] + lastSpineElementFence - + // # of elements prior to current + priorElementCount[splSpineIndex] - splElementIndex; } @Override @@ -586,15 +632,16 @@ class SpinedBuffer return SPLITERATOR_CHARACTERISTICS; } + @Override public boolean tryAdvance(T_CONS consumer) { - if (splSpineIndex < spineIndex - || (splSpineIndex == spineIndex && splElementIndex < elementIndex)) { + if (splSpineIndex < lastSpineIndex + || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) { arrayForOne(splChunk, splElementIndex++, consumer); if (splElementIndex == arrayLength(splChunk)) { splElementIndex = 0; ++splSpineIndex; - if (spine != null && splSpineIndex < spine.length) + if (spine != null && splSpineIndex <= lastSpineIndex) splChunk = spine[splSpineIndex]; } return true; @@ -602,39 +649,44 @@ class SpinedBuffer return false; } + @Override public void forEachRemaining(T_CONS consumer) { - if (splSpineIndex < spineIndex - || (splSpineIndex == spineIndex && splElementIndex < elementIndex)) { + if (splSpineIndex < lastSpineIndex + || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) { int i = splElementIndex; // completed chunks, if any - for (int sp = splSpineIndex; sp < spineIndex; sp++) { + for (int sp = splSpineIndex; sp < lastSpineIndex; sp++) { T_ARR chunk = spine[sp]; arrayForEach(chunk, i, arrayLength(chunk), consumer); i = 0; } - - arrayForEach(curChunk, i, elementIndex, consumer); - - splSpineIndex = spineIndex; - splElementIndex = elementIndex; + // last (or current uncompleted) chunk + T_ARR chunk = (splSpineIndex == lastSpineIndex) ? splChunk : spine[lastSpineIndex]; + arrayForEach(chunk, i, lastSpineElementFence, consumer); + // mark consumed + splSpineIndex = lastSpineIndex; + splElementIndex = lastSpineElementFence; } } @Override - public T_SPLITER trySplit() { - if (splSpineIndex < spineIndex) { - T_SPLITER ret = arraySpliterator(spine[splSpineIndex], splElementIndex, - arrayLength(spine[splSpineIndex]) - splElementIndex); - splChunk = spine[++splSpineIndex]; + public T_SPLITR trySplit() { + if (splSpineIndex < lastSpineIndex) { + // split just before last chunk (if it is full this means 50:50 split) + T_SPLITR ret = newSpliterator(splSpineIndex, lastSpineIndex - 1, + splElementIndex, arrayLength(spine[lastSpineIndex - 1])); + // position us to start of last chunk + splSpineIndex = lastSpineIndex; splElementIndex = 0; + splChunk = spine[splSpineIndex]; return ret; } - else if (splSpineIndex == spineIndex) { - int t = (elementIndex - splElementIndex) / 2; + else if (splSpineIndex == lastSpineIndex) { + int t = (lastSpineElementFence - splElementIndex) / 2; if (t == 0) return null; else { - T_SPLITER ret = arraySpliterator(curChunk, splElementIndex, t); + T_SPLITR ret = arraySpliterator(splChunk, splElementIndex, t); splElementIndex += t; return ret; } @@ -675,7 +727,7 @@ class SpinedBuffer } @Override - protected int[] newArray(int size) { + public int[] newArray(int size) { return new int[size]; } @@ -706,10 +758,6 @@ class SpinedBuffer return spine[ch][(int) (index-priorElementCount[ch])]; } - public int[] asIntArray() { - return asPrimitiveArray(); - } - @Override public PrimitiveIterator.OfInt iterator() { return Spliterators.iterator(spliterator()); @@ -718,6 +766,18 @@ class SpinedBuffer public Spliterator.OfInt spliterator() { class Splitr extends BaseSpliterator implements Spliterator.OfInt { + Splitr(int firstSpineIndex, int lastSpineIndex, + int firstSpineElementIndex, int lastSpineElementFence) { + super(firstSpineIndex, lastSpineIndex, + firstSpineElementIndex, lastSpineElementFence); + } + + @Override + Splitr newSpliterator(int firstSpineIndex, int lastSpineIndex, + int firstSpineElementIndex, int lastSpineElementFence) { + return new Splitr(firstSpineIndex, lastSpineIndex, + firstSpineElementIndex, lastSpineElementFence); + } @Override void arrayForOne(int[] array, int index, IntConsumer consumer) { @@ -728,13 +788,13 @@ class SpinedBuffer Spliterator.OfInt arraySpliterator(int[] array, int offset, int len) { return Arrays.spliterator(array, offset, offset+len); } - }; - return new Splitr(); + } + return new Splitr(0, spineIndex, 0, elementIndex); } @Override public String toString() { - int[] array = asIntArray(); + int[] array = asPrimitiveArray(); if (array.length < 200) { return String.format("%s[length=%d, chunks=%d]%s", getClass().getSimpleName(), array.length, @@ -778,7 +838,7 @@ class SpinedBuffer } @Override - protected long[] newArray(int size) { + public long[] newArray(int size) { return new long[size]; } @@ -809,10 +869,6 @@ class SpinedBuffer return spine[ch][(int) (index-priorElementCount[ch])]; } - public long[] asLongArray() { - return asPrimitiveArray(); - } - @Override public PrimitiveIterator.OfLong iterator() { return Spliterators.iterator(spliterator()); @@ -822,6 +878,19 @@ class SpinedBuffer public Spliterator.OfLong spliterator() { class Splitr extends BaseSpliterator implements Spliterator.OfLong { + Splitr(int firstSpineIndex, int lastSpineIndex, + int firstSpineElementIndex, int lastSpineElementFence) { + super(firstSpineIndex, lastSpineIndex, + firstSpineElementIndex, lastSpineElementFence); + } + + @Override + Splitr newSpliterator(int firstSpineIndex, int lastSpineIndex, + int firstSpineElementIndex, int lastSpineElementFence) { + return new Splitr(firstSpineIndex, lastSpineIndex, + firstSpineElementIndex, lastSpineElementFence); + } + @Override void arrayForOne(long[] array, int index, LongConsumer consumer) { consumer.accept(array[index]); @@ -831,13 +900,13 @@ class SpinedBuffer Spliterator.OfLong arraySpliterator(long[] array, int offset, int len) { return Arrays.spliterator(array, offset, offset+len); } - }; - return new Splitr(); + } + return new Splitr(0, spineIndex, 0, elementIndex); } @Override public String toString() { - long[] array = asLongArray(); + long[] array = asPrimitiveArray(); if (array.length < 200) { return String.format("%s[length=%d, chunks=%d]%s", getClass().getSimpleName(), array.length, @@ -882,7 +951,7 @@ class SpinedBuffer } @Override - protected double[] newArray(int size) { + public double[] newArray(int size) { return new double[size]; } @@ -913,10 +982,6 @@ class SpinedBuffer return spine[ch][(int) (index-priorElementCount[ch])]; } - public double[] asDoubleArray() { - return asPrimitiveArray(); - } - @Override public PrimitiveIterator.OfDouble iterator() { return Spliterators.iterator(spliterator()); @@ -925,6 +990,19 @@ class SpinedBuffer public Spliterator.OfDouble spliterator() { class Splitr extends BaseSpliterator implements Spliterator.OfDouble { + Splitr(int firstSpineIndex, int lastSpineIndex, + int firstSpineElementIndex, int lastSpineElementFence) { + super(firstSpineIndex, lastSpineIndex, + firstSpineElementIndex, lastSpineElementFence); + } + + @Override + Splitr newSpliterator(int firstSpineIndex, int lastSpineIndex, + int firstSpineElementIndex, int lastSpineElementFence) { + return new Splitr(firstSpineIndex, lastSpineIndex, + firstSpineElementIndex, lastSpineElementFence); + } + @Override void arrayForOne(double[] array, int index, DoubleConsumer consumer) { consumer.accept(array[index]); @@ -935,12 +1013,12 @@ class SpinedBuffer return Arrays.spliterator(array, offset, offset+len); } } - return new Splitr(); + return new Splitr(0, spineIndex, 0, elementIndex); } @Override public String toString() { - double[] array = asDoubleArray(); + double[] array = asPrimitiveArray(); if (array.length < 200) { return String.format("%s[length=%d, chunks=%d]%s", getClass().getSimpleName(), array.length, diff --git a/jdk/test/java/util/stream/boottest/java/util/stream/DoubleNodeTest.java b/jdk/test/java/util/stream/boottest/java/util/stream/DoubleNodeTest.java index c348102cf08..f0d5380984d 100644 --- a/jdk/test/java/util/stream/boottest/java/util/stream/DoubleNodeTest.java +++ b/jdk/test/java/util/stream/boottest/java/util/stream/DoubleNodeTest.java @@ -122,12 +122,12 @@ public class DoubleNodeTest extends OpTestCase { @Test(dataProvider = "nodes") public void testAsArray(double[] array, Node.OfDouble n) { - assertEquals(n.asDoubleArray(), array); + assertEquals(n.asPrimitiveArray(), array); } @Test(dataProvider = "nodes") public void testFlattenAsArray(double[] array, Node.OfDouble n) { - assertEquals(Nodes.flattenDouble(n).asDoubleArray(), array); + assertEquals(Nodes.flattenDouble(n).asPrimitiveArray(), array); } @Test(dataProvider = "nodes") diff --git a/jdk/test/java/util/stream/boottest/java/util/stream/IntNodeTest.java b/jdk/test/java/util/stream/boottest/java/util/stream/IntNodeTest.java index b9292578d45..7b91f8ea8ad 100644 --- a/jdk/test/java/util/stream/boottest/java/util/stream/IntNodeTest.java +++ b/jdk/test/java/util/stream/boottest/java/util/stream/IntNodeTest.java @@ -122,12 +122,12 @@ public class IntNodeTest extends OpTestCase { @Test(dataProvider = "nodes") public void testAsArray(int[] array, Node.OfInt n) { - assertEquals(n.asIntArray(), array); + assertEquals(n.asPrimitiveArray(), array); } @Test(dataProvider = "nodes") public void testFlattenAsArray(int[] array, Node.OfInt n) { - assertEquals(Nodes.flattenInt(n).asIntArray(), array); + assertEquals(Nodes.flattenInt(n).asPrimitiveArray(), array); } @Test(dataProvider = "nodes") diff --git a/jdk/test/java/util/stream/boottest/java/util/stream/LongNodeTest.java b/jdk/test/java/util/stream/boottest/java/util/stream/LongNodeTest.java index a14bcd0ee7b..877517ebd6f 100644 --- a/jdk/test/java/util/stream/boottest/java/util/stream/LongNodeTest.java +++ b/jdk/test/java/util/stream/boottest/java/util/stream/LongNodeTest.java @@ -122,12 +122,12 @@ public class LongNodeTest extends OpTestCase { @Test(dataProvider = "nodes") public void testAsArray(long[] array, Node.OfLong n) { - assertEquals(n.asLongArray(), array); + assertEquals(n.asPrimitiveArray(), array); } @Test(dataProvider = "nodes") public void testFlattenAsArray(long[] array, Node.OfLong n) { - assertEquals(Nodes.flattenLong(n).asLongArray(), array); + assertEquals(Nodes.flattenLong(n).asPrimitiveArray(), array); } @Test(dataProvider = "nodes") diff --git a/jdk/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java b/jdk/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java index ad891f74694..8f9c4ffd886 100644 --- a/jdk/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java +++ b/jdk/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java @@ -210,7 +210,7 @@ public class SpinedBufferTest { list2.clear(); sb.forEach((int i) -> list2.add(i)); assertEquals(list1, list2); - int[] array = sb.asIntArray(); + int[] array = sb.asPrimitiveArray(); list2.clear(); for (int i : array) list2.add(i); @@ -285,7 +285,7 @@ public class SpinedBufferTest { list2.clear(); sb.forEach((long i) -> list2.add(i)); assertEquals(list1, list2); - long[] array = sb.asLongArray(); + long[] array = sb.asPrimitiveArray(); list2.clear(); for (long i : array) list2.add(i); @@ -361,7 +361,7 @@ public class SpinedBufferTest { list2.clear(); sb.forEach((double i) -> list2.add(i)); assertEquals(list1, list2); - double[] array = sb.asDoubleArray(); + double[] array = sb.asPrimitiveArray(); list2.clear(); for (double i : array) list2.add(i); From b5954586075750770bec765fa082b4f33e08c6fd Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Thu, 13 Jun 2013 15:15:03 +0400 Subject: [PATCH 199/206] 7181748: java/lang/ThreadGroup/Suspend.java test fails intermittently Reviewed-by: chegar, dholmes --- jdk/test/java/lang/ThreadGroup/Suspend.java | 58 ++++++++++++--------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/jdk/test/java/lang/ThreadGroup/Suspend.java b/jdk/test/java/lang/ThreadGroup/Suspend.java index 6c417b98f27..b66d835da15 100644 --- a/jdk/test/java/lang/ThreadGroup/Suspend.java +++ b/jdk/test/java/lang/ThreadGroup/Suspend.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 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 @@ -23,47 +23,55 @@ /** * @test - * @bug 4176355 + * @bug 4176355 7181748 * @summary Suspending a ThreadGroup that contains the current thread has * unpredictable results. */ public class Suspend implements Runnable { - private static Thread first=null; - private static Thread second=null; - private static ThreadGroup group = new ThreadGroup(""); - private static int count = 0; - Suspend() { - Thread thread = new Thread(group, this); - if (first == null) - first = thread; - else - second = thread; - - thread.start(); - } + private static volatile int count = 0; + private static final ThreadGroup group = new ThreadGroup(""); + private static final Thread first = new Thread(group, new Suspend()); + private static final Thread second = new Thread(group, new Suspend()); public void run() { while (true) { try { - Thread.sleep(1000); // Give other thread a chance to start - if (Thread.currentThread() == first) - group.suspend(); - else + Thread.sleep(100); + if (Thread.currentThread() == first) { + if (second.isAlive()) { + group.suspend(); + } + } else { count++; - } catch(InterruptedException e){ + } + } catch (InterruptedException e) { } } } public static void main(String[] args) throws Exception { - for (int i=0; i<2; i++) - new Suspend(); - Thread.sleep(3000); + // Launch two threads as part of the same thread group + first.start(); + second.start(); + + // Wait for the thread group suspend to be issued + while (!first.isAlive() || !second.isAlive()) { + Thread.sleep(100); + } + Thread.sleep(1000); + // Suppose, the thread group is now suspended + + count = 0; + Thread.sleep(1000); + + // Increment of the count indicates that the second thread is still running boolean failed = (count > 1); - first.stop(); second.stop(); - if (failed) + first.stop(); + second.stop(); + if (failed) { throw new RuntimeException("Failure."); + } } } From 8b668ed3557e79cf31e83aca20e56726a42c39d3 Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 18:57:05 +0200 Subject: [PATCH 200/206] Added tag jdk8-b92 for changeset 2fd6acba737b --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 25e7a3c7d92..8d065deab4a 100644 --- a/.hgtags +++ b/.hgtags @@ -213,3 +213,4 @@ e517701a4d0e25ae9c7945bca6e1762a8c5d8aa6 jdk8-b88 4dec41b3c5e3bb616f0c6f15830d940905aa5d16 jdk8-b89 f09ab0c416185e3cba371e81bcb6a16060c90f44 jdk8-b90 80b6c3172dc2cfceb022411292d290a967f9c728 jdk8-b91 +2fd6acba737b01e705e1f7c33588c922a3787f13 jdk8-b92 From 47f305febbe69c51a51544b20f0271507b8237d4 Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 18:58:01 +0200 Subject: [PATCH 201/206] Added tag jdk8-b93 for changeset b72ae39e1329 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 8d065deab4a..e411eb8ffc5 100644 --- a/.hgtags +++ b/.hgtags @@ -214,3 +214,4 @@ e517701a4d0e25ae9c7945bca6e1762a8c5d8aa6 jdk8-b88 f09ab0c416185e3cba371e81bcb6a16060c90f44 jdk8-b90 80b6c3172dc2cfceb022411292d290a967f9c728 jdk8-b91 2fd6acba737b01e705e1f7c33588c922a3787f13 jdk8-b92 +b72ae39e1329fefae50d4690db4fde43f3841a95 jdk8-b93 From 343d4c485660b98f5923876e9062f3fd074d02e0 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 13 Jun 2013 09:48:58 -0700 Subject: [PATCH 202/206] Added tag jdk8-b94 for changeset 166c25c5681e --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index b91e542c25e..6e2a50acf2f 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -215,3 +215,4 @@ c63eda8f63008a4398d2c22ac8d72f7fef6f9238 jdk8-b90 169451cf0cc53bde5af24f9820ea3f35ec4b4df4 jdk8-b91 a2a2a91075ad85becbe10a39d7fd04ef9bea8df5 jdk8-b92 691d6c6cd332d98b0f0221445a73906776f31f72 jdk8-b93 +51479fa56b7c4363c6d87c2e8b898d8185cf4b22 jdk8-b94 From 310a5ee8e559286ab0d0717c0f295b9fc0c5f336 Mon Sep 17 00:00:00 2001 From: Kurchi Subhra Hazra Date: Thu, 13 Jun 2013 11:23:00 -0700 Subject: [PATCH 203/206] 8015421: NegativeArraySizeException occurs in ChunkedOutputStream() with Integer.MAX_VALUE Ensure integer overflow does not occur Reviewed-by: chegar --- jdk/src/share/classes/sun/net/www/http/ChunkedOutputStream.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/sun/net/www/http/ChunkedOutputStream.java b/jdk/src/share/classes/sun/net/www/http/ChunkedOutputStream.java index 96f5d8d3ae7..fc23ac683be 100644 --- a/jdk/src/share/classes/sun/net/www/http/ChunkedOutputStream.java +++ b/jdk/src/share/classes/sun/net/www/http/ChunkedOutputStream.java @@ -125,7 +125,7 @@ public class ChunkedOutputStream extends PrintStream { completeHeader = getHeader(preferredChunkDataSize); /* start with an initial buffer */ - buf = new byte[preferredChunkDataSize + 32]; + buf = new byte[preferredChunkGrossSize]; reset(); } From eb00b0e4f342393053946e774a9be3d5fec3702d Mon Sep 17 00:00:00 2001 From: Kurchi Subhra Hazra Date: Thu, 13 Jun 2013 17:48:11 -0700 Subject: [PATCH 204/206] 7169142: CookieHandler does not work with localhost Add .local to derived effective hostnames without dot Reviewed-by: chegar --- .../share/classes/java/net/CookieManager.java | 5 +- .../net/CookieHandler/LocalHostCookie.java | 124 ++++++++++++++++++ 2 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/net/CookieHandler/LocalHostCookie.java diff --git a/jdk/src/share/classes/java/net/CookieManager.java b/jdk/src/share/classes/java/net/CookieManager.java index fde828f95ea..1ad4b6ee93a 100644 --- a/jdk/src/share/classes/java/net/CookieManager.java +++ b/jdk/src/share/classes/java/net/CookieManager.java @@ -309,7 +309,10 @@ public class CookieManager extends CookieHandler // there is no dot at the beginning of effective request-host, // the default Domain can only domain-match itself.) if (cookie.getDomain() == null) { - cookie.setDomain(uri.getHost()); + String host = uri.getHost(); + if (host != null && !host.contains(".")) + host += ".local"; + cookie.setDomain(host); } String ports = cookie.getPortlist(); if (ports != null) { diff --git a/jdk/test/java/net/CookieHandler/LocalHostCookie.java b/jdk/test/java/net/CookieHandler/LocalHostCookie.java new file mode 100644 index 00000000000..ac8d61622ef --- /dev/null +++ b/jdk/test/java/net/CookieHandler/LocalHostCookie.java @@ -0,0 +1,124 @@ +/* + * 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.net.httpserver.*; +import java.io.IOException; +import java.io.OutputStream; +import java.net.*; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Executors; + +/* + * @test + * @bug 7169142 + * @summary CookieHandler does not work with localhost + * @run main/othervm LocalHostCookie + */ +public class LocalHostCookie { + + public static void main(String[] args) throws Exception { + new LocalHostCookie().runTest(); + } + + public void runTest() throws Exception { + Server s = null; + try { + s = new Server(); + s.startServer(); + URL url = new URL("http","localhost", s.getPort(), "/"); + HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); + urlConnection.setRequestMethod("GET"); + urlConnection.setDoOutput(true); + urlConnection.connect(); + urlConnection.getInputStream(); + + CookieHandler cookieHandler = CookieHandler.getDefault(); + if (cookieHandler == null) { + cookieHandler = new java.net.CookieManager(); + CookieHandler.setDefault(cookieHandler); + } + cookieHandler.put(urlConnection.getURL().toURI(), + urlConnection.getHeaderFields()); + Map> map = + cookieHandler.get(urlConnection.getURL().toURI(), + urlConnection.getHeaderFields()); + if (map.containsKey("Cookie")) { + List list = map.get("Cookie"); + // name-value list will be empty if ".local" is not appended + if (list == null || list.size() == 0) { + throw new RuntimeException("Test failed!"); + } + } + } finally { + s.stopServer(); + } + } + + class Server { + HttpServer server; + + public void startServer() { + InetSocketAddress addr = new InetSocketAddress(0); + try { + server = HttpServer.create(addr, 0); + } catch (IOException ioe) { + throw new RuntimeException("Server could not be created"); + } + + server.createContext("/", new MyCookieHandler()); + server.start(); + } + + public int getPort() { + return server.getAddress().getPort(); + } + + public void stopServer() { + server.stop(0); + } + } + + class MyCookieHandler implements HttpHandler { + + @Override + public void handle(HttpExchange exchange) throws IOException { + String requestMethod = exchange.getRequestMethod(); + if (requestMethod.equalsIgnoreCase("GET")){ + Headers responseHeaders = exchange.getResponseHeaders(); + responseHeaders.set("Content-Type", "text/plain"); + responseHeaders.set("Date", "June 13th 2012"); + // No domain value set + responseHeaders.set("Set-Cookie2", "name=value"); + exchange.sendResponseHeaders(200, 0); + OutputStream os = exchange.getResponseBody(); + String str = "This is what the server sent!"; + os.write(str.getBytes()); + os.flush(); + os.close(); + } + } + } +} + From 48a8955ad62971bfd843dd9acae26422b971050a Mon Sep 17 00:00:00 2001 From: John Zavgren Date: Fri, 14 Jun 2013 09:13:03 -0400 Subject: [PATCH 205/206] 8014307: Memory leak ... security/jgss/wrapper/GSSLibStub.c I modified the native procedure: Java_sun_security_jgss_wrapper_GSSLibStub_initContext() so that allocated memory is freed when errors occur. Reviewed-by: chegar, valeriep --- .../share/native/sun/security/jgss/wrapper/GSSLibStub.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c b/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c index 541a1d3edc2..e0da98aab74 100644 --- a/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c +++ b/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c @@ -329,6 +329,8 @@ Java_sun_security_jgss_wrapper_GSSLibStub_importName(JNIEnv *env, initGSSBuffer(env, jnameVal, &nameVal); nameType = newGSSOID(env, jnameType); if ((*env)->ExceptionCheck(env)) { + deleteGSSOID(nameType); + resetGSSBuffer(env, jnameVal, &nameVal); return jlong_zero; } @@ -823,6 +825,7 @@ Java_sun_security_jgss_wrapper_GSSLibStub_initContext(JNIEnv *env, FID_NativeGSSContext_lifetime)); cb = getGSSCB(env, jcb); if ((*env)->ExceptionCheck(env)) { + free(cb); return NULL; } @@ -927,6 +930,8 @@ Java_sun_security_jgss_wrapper_GSSLibStub_acceptContext(JNIEnv *env, initGSSBuffer(env, jinToken, &inToken); cb = getGSSCB(env, jcb); if ((*env)->ExceptionCheck(env)) { + free(cb); + resetGSSBuffer(env, jinToken, &inToken); return NULL; } srcName = GSS_C_NO_NAME; @@ -979,6 +984,7 @@ Java_sun_security_jgss_wrapper_GSSLibStub_acceptContext(JNIEnv *env, /* return immediately if an exception has occurred */ if ((*env)->ExceptionCheck(env)) { + resetGSSBuffer(env, jinToken, &inToken); return NULL; } sprintf(debugBuf, "[GSSLibStub_acceptContext] set targetName=%ld", @@ -993,6 +999,7 @@ Java_sun_security_jgss_wrapper_GSSLibStub_acceptContext(JNIEnv *env, ptr_to_jlong(srcName), jobj); /* return immediately if an exception has occurred */ if ((*env)->ExceptionCheck(env)) { + resetGSSBuffer(env, jinToken, &inToken); return NULL; } sprintf(debugBuf, "[GSSLibStub_acceptContext] set srcName=%ld", @@ -1019,6 +1026,7 @@ Java_sun_security_jgss_wrapper_GSSLibStub_acceptContext(JNIEnv *env, ptr_to_jlong(delCred), jsrcName, jMech); /* return immediately if an exception has occurred */ if ((*env)->ExceptionCheck(env)) { + resetGSSBuffer(env, jinToken, &inToken); return NULL; } (*env)->SetObjectField(env, jcontextSpi, From 52cfa3dc50da177e1765e0b3e7ea0fc23f3d62e7 Mon Sep 17 00:00:00 2001 From: Aleksej Efimov Date: Fri, 14 Jun 2013 15:14:56 +0400 Subject: [PATCH 206/206] 8015978: Incorrect transformation of XPath expression "string(-0)" Reviewed-by: darcy, joehw --- .../jaxp/XPath/8015978/XPathNegativeZero.java | 72 +++++++++++++++++++ .../javax/xml/jaxp/XPath/8015978/dummy.xml | 1 + .../xml/jaxp/XPath/8015978/negativezero.xsl | 4 ++ 3 files changed, 77 insertions(+) create mode 100644 jdk/test/javax/xml/jaxp/XPath/8015978/XPathNegativeZero.java create mode 100644 jdk/test/javax/xml/jaxp/XPath/8015978/dummy.xml create mode 100644 jdk/test/javax/xml/jaxp/XPath/8015978/negativezero.xsl diff --git a/jdk/test/javax/xml/jaxp/XPath/8015978/XPathNegativeZero.java b/jdk/test/javax/xml/jaxp/XPath/8015978/XPathNegativeZero.java new file mode 100644 index 00000000000..79a3ed51535 --- /dev/null +++ b/jdk/test/javax/xml/jaxp/XPath/8015978/XPathNegativeZero.java @@ -0,0 +1,72 @@ +/* + * 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 8015978 + * @summary Incorrect transformation of XPath expression "string(-0)" + * @run main XPathNegativeZero + * @author aleksej.efimov@oracle.com + */ + +import java.io.File; +import java.io.StringWriter; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.Templates; +import javax.xml.transform.Transformer; +import javax.xml.transform.Source; +import javax.xml.transform.Result; +import javax.xml.transform.stream.StreamSource; +import javax.xml.transform.stream.StreamResult; + + +public class XPathNegativeZero { + + static final String EXPECTEDXML = "\"0\""; + + public static void main(final String[] args) throws Exception { + //file name of XML file to transform + final String xml = System.getProperty("test.src", ".")+"/dummy.xml"; + //file name of XSL file w/ transformation + final String xsl = System.getProperty("test.src", ".")+"/negativezero.xsl"; + final String result = xform(xml, xsl).trim(); + + System.out.println("transformed XML: '"+result+ "' expected XML: '"+EXPECTEDXML+"'"); + if (!result.equals(EXPECTEDXML)) + throw new Exception("Negative zero was incorrectly transformed"); + } + + private static String xform(final String xml, final String xsl) throws Exception { + final TransformerFactory tf = TransformerFactory.newInstance(); + final Source xslsrc = new StreamSource(new File(xsl)); + final Templates tmpl = tf.newTemplates(xslsrc); + final Transformer t = tmpl.newTransformer(); + + StringWriter writer = new StringWriter(); + final Source src = new StreamSource(new File(xml)); + final Result res = new StreamResult(writer); + + t.transform(src, res); + return writer.toString(); + } +} diff --git a/jdk/test/javax/xml/jaxp/XPath/8015978/dummy.xml b/jdk/test/javax/xml/jaxp/XPath/8015978/dummy.xml new file mode 100644 index 00000000000..3ad73ac3b6f --- /dev/null +++ b/jdk/test/javax/xml/jaxp/XPath/8015978/dummy.xml @@ -0,0 +1 @@ + diff --git a/jdk/test/javax/xml/jaxp/XPath/8015978/negativezero.xsl b/jdk/test/javax/xml/jaxp/XPath/8015978/negativezero.xsl new file mode 100644 index 00000000000..5ee2dbe6dd5 --- /dev/null +++ b/jdk/test/javax/xml/jaxp/XPath/8015978/negativezero.xsl @@ -0,0 +1,4 @@ + + + "" +