mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-15 21:05:11 +00:00
Merge
This commit is contained in:
commit
e1ca4d3a94
1
.hgtags
1
.hgtags
@ -323,3 +323,4 @@ c25e882cee9622ec75c4e9d60633539a2f0a8809 jdk9-b77
|
||||
c8753d0be1778944dc512ec86a459941ea1ad2c3 jdk9-b78
|
||||
3966bd3b8167419aa05c6718a4af1cf54b1e3c58 jdk9-b79
|
||||
3c9f5bd909ae7187f24622ee4b69f8a5756a9271 jdk9-b80
|
||||
2050b3a0aadcb0e024bf798197421d58e54ec8bf jdk9-b81
|
||||
|
||||
@ -323,3 +323,4 @@ d82072b699b880a1f647a5e2d7c0f86cec958941 jdk9-b76
|
||||
8c40d4143ee13bdf8170c68cc384c36ab1e9fadb jdk9-b78
|
||||
ba08a9f79b9849716bae1f39f71333d47f604012 jdk9-b79
|
||||
f7c5ae2933c0b8510a420d1713a955e4ffc7ad0b jdk9-b80
|
||||
b8afcf91331d78626a583ec1b63164468d6f4181 jdk9-b81
|
||||
|
||||
@ -4364,7 +4364,7 @@ VS_SDK_PLATFORM_NAME_2013=
|
||||
#CUSTOM_AUTOCONF_INCLUDE
|
||||
|
||||
# Do not change or remove the following line, it is needed for consistency checks:
|
||||
DATE_WHEN_GENERATED=1435822080
|
||||
DATE_WHEN_GENERATED=1441958217
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
@ -38307,6 +38307,48 @@ $as_echo "$as_me: Rewriting OBJCOPY to \"$new_complete\"" >&6;}
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$OPENJDK_BUILD_OS" = xsolaris; then
|
||||
# objcopy prior to 2.21.1 on solaris is broken and is not usable.
|
||||
# Rewrite objcopy version output to VALID_VERSION or BAD_VERSION.
|
||||
# - version number is last blank separate word on first line
|
||||
# - version number formats that have been seen:
|
||||
# - <major>.<minor>
|
||||
# - <major>.<minor>.<micro>
|
||||
OBJCOPY_VERSION=`$OBJCOPY --version | $HEAD -n 1`
|
||||
# The outer [ ] is to prevent m4 from eating the [] in the sed expression.
|
||||
OBJCOPY_VERSION_CHECK=`$ECHO $OBJCOPY_VERSION | $SED -n \
|
||||
-e 's/.* //' \
|
||||
-e '/^[01]\./b bad' \
|
||||
-e '/^2\./{' \
|
||||
-e ' s/^2\.//' \
|
||||
-e ' /^[0-9]$/b bad' \
|
||||
-e ' /^[0-9]\./b bad' \
|
||||
-e ' /^1[0-9]$/b bad' \
|
||||
-e ' /^1[0-9]\./b bad' \
|
||||
-e ' /^20\./b bad' \
|
||||
-e ' /^21\.0$/b bad' \
|
||||
-e ' /^21\.0\./b bad' \
|
||||
-e '}' \
|
||||
-e ':good' \
|
||||
-e 's/.*/VALID_VERSION/p' \
|
||||
-e 'q' \
|
||||
-e ':bad' \
|
||||
-e 's/.*/BAD_VERSION/p' \
|
||||
-e 'q'`
|
||||
if test "x$OBJCOPY_VERSION_CHECK" = xBAD_VERSION; then
|
||||
OBJCOPY=
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring found objcopy since it is broken (prior to 2.21.1). No debug symbols will be generated." >&5
|
||||
$as_echo "$as_me: WARNING: Ignoring found objcopy since it is broken (prior to 2.21.1). No debug symbols will be generated." >&2;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: objcopy reports version $OBJCOPY_VERSION" >&5
|
||||
$as_echo "$as_me: objcopy reports version $OBJCOPY_VERSION" >&6;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: Note: patch 149063-01 or newer contains the correct Solaris 10 SPARC version" >&5
|
||||
$as_echo "$as_me: Note: patch 149063-01 or newer contains the correct Solaris 10 SPARC version" >&6;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: Note: patch 149064-01 or newer contains the correct Solaris 10 X86 version" >&5
|
||||
$as_echo "$as_me: Note: patch 149064-01 or newer contains the correct Solaris 10 X86 version" >&6;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: Note: Solaris 11 Update 1 contains the correct version" >&5
|
||||
$as_echo "$as_me: Note: Solaris 11 Update 1 contains the correct version" >&6;}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@ -30,25 +30,6 @@
|
||||
# (called @OPENJDK_BUILD_AUTOCONF_NAME@ by autoconf)
|
||||
# using 'configure @CONFIGURE_COMMAND_LINE@'
|
||||
|
||||
# When calling macros, the spaces between arguments are
|
||||
# often semantically important! Sometimes we need to subst
|
||||
# spaces and commas, therefore we need the following macros.
|
||||
X:=
|
||||
SPACE:=$(X) $(X)
|
||||
COMMA:=,
|
||||
DOLLAR:=$$
|
||||
HASH:=\#
|
||||
LEFT_PAREN:=(
|
||||
RIGHT_PAREN:=)
|
||||
SQUOTE:='
|
||||
#'
|
||||
DQUOTE:="
|
||||
#"
|
||||
define NEWLINE
|
||||
|
||||
|
||||
endef
|
||||
|
||||
# The command line given to configure.
|
||||
CONFIGURE_COMMAND_LINE:=@CONFIGURE_COMMAND_LINE@
|
||||
|
||||
|
||||
@ -586,6 +586,43 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA],
|
||||
# Only call fixup if objcopy was found.
|
||||
if test -n "$OBJCOPY"; then
|
||||
BASIC_FIXUP_EXECUTABLE(OBJCOPY)
|
||||
if test "x$OPENJDK_BUILD_OS" = xsolaris; then
|
||||
# objcopy prior to 2.21.1 on solaris is broken and is not usable.
|
||||
# Rewrite objcopy version output to VALID_VERSION or BAD_VERSION.
|
||||
# - version number is last blank separate word on first line
|
||||
# - version number formats that have been seen:
|
||||
# - <major>.<minor>
|
||||
# - <major>.<minor>.<micro>
|
||||
OBJCOPY_VERSION=`$OBJCOPY --version | $HEAD -n 1`
|
||||
# The outer [ ] is to prevent m4 from eating the [] in the sed expression.
|
||||
[ OBJCOPY_VERSION_CHECK=`$ECHO $OBJCOPY_VERSION | $SED -n \
|
||||
-e 's/.* //' \
|
||||
-e '/^[01]\./b bad' \
|
||||
-e '/^2\./{' \
|
||||
-e ' s/^2\.//' \
|
||||
-e ' /^[0-9]$/b bad' \
|
||||
-e ' /^[0-9]\./b bad' \
|
||||
-e ' /^1[0-9]$/b bad' \
|
||||
-e ' /^1[0-9]\./b bad' \
|
||||
-e ' /^20\./b bad' \
|
||||
-e ' /^21\.0$/b bad' \
|
||||
-e ' /^21\.0\./b bad' \
|
||||
-e '}' \
|
||||
-e ':good' \
|
||||
-e 's/.*/VALID_VERSION/p' \
|
||||
-e 'q' \
|
||||
-e ':bad' \
|
||||
-e 's/.*/BAD_VERSION/p' \
|
||||
-e 'q'` ]
|
||||
if test "x$OBJCOPY_VERSION_CHECK" = xBAD_VERSION; then
|
||||
OBJCOPY=
|
||||
AC_MSG_WARN([Ignoring found objcopy since it is broken (prior to 2.21.1). No debug symbols will be generated.])
|
||||
AC_MSG_NOTICE([objcopy reports version $OBJCOPY_VERSION])
|
||||
AC_MSG_NOTICE([Note: patch 149063-01 or newer contains the correct Solaris 10 SPARC version])
|
||||
AC_MSG_NOTICE([Note: patch 149064-01 or newer contains the correct Solaris 10 X86 version])
|
||||
AC_MSG_NOTICE([Note: Solaris 11 Update 1 contains the correct version])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@ -323,3 +323,4 @@ d8126bc88fa5cd1ae4e44d86a4b1280ca1c9e2aa jdk9-b76
|
||||
182bb7accc5253bcfefd8edc1d4997ec8f9f8694 jdk9-b78
|
||||
4ab250b8fac66ef8cd15ee78c40f0c651c96e16a jdk9-b79
|
||||
821a0373ef2d1642a9824facb938b901ad010413 jdk9-b80
|
||||
45c35b7f5b40d5af0085e4a7b3a4d6e3e0347c35 jdk9-b81
|
||||
|
||||
@ -483,3 +483,4 @@ e66c3813789debfc06f206afde1bf7a84cb08451 jdk9-b77
|
||||
20dc06b04fe5ec373879414d60ef82ac70faef98 jdk9-b78
|
||||
e9e63d93bbfe2c6c23447e2c1f5cc71c98671cba jdk9-b79
|
||||
8e8377739c06b99b9011c003c77e0bef84c91e09 jdk9-b80
|
||||
4142c190cd5ca4fb70ec367b4f97ef936272d8ef jdk9-b81
|
||||
|
||||
@ -745,13 +745,12 @@ void CodeCache::gc_prologue() {
|
||||
|
||||
void CodeCache::gc_epilogue() {
|
||||
assert_locked_or_safepoint(CodeCache_lock);
|
||||
NMethodIterator iter;
|
||||
while(iter.next()) {
|
||||
nmethod* nm = iter.method();
|
||||
if (!nm->is_zombie()) {
|
||||
if (needs_cache_clean()) {
|
||||
// Clean ICs of unloaded nmethods as well because they may reference other
|
||||
// unloaded nmethods that may be flushed earlier in the sweeper cycle.
|
||||
NOT_DEBUG(if (needs_cache_clean())) {
|
||||
NMethodIterator iter;
|
||||
while(iter.next_alive()) {
|
||||
nmethod* nm = iter.method();
|
||||
assert(!nm->is_unloaded(), "Tautology");
|
||||
DEBUG_ONLY(if (needs_cache_clean())) {
|
||||
nm->cleanup_inline_caches();
|
||||
}
|
||||
DEBUG_ONLY(nm->verify());
|
||||
|
||||
@ -287,6 +287,7 @@ bool CompiledIC::is_call_to_compiled() const {
|
||||
assert( is_c1_method ||
|
||||
!is_monomorphic ||
|
||||
is_optimized() ||
|
||||
!caller->is_alive() ||
|
||||
(cached_metadata() != NULL && cached_metadata()->is_klass()), "sanity check");
|
||||
#endif // ASSERT
|
||||
return is_monomorphic;
|
||||
@ -321,7 +322,7 @@ bool CompiledIC::is_call_to_interpreted() const {
|
||||
}
|
||||
|
||||
|
||||
void CompiledIC::set_to_clean() {
|
||||
void CompiledIC::set_to_clean(bool in_use) {
|
||||
assert(SafepointSynchronize::is_at_safepoint() || CompiledIC_lock->is_locked() , "MT-unsafe call");
|
||||
if (TraceInlineCacheClearing || TraceICs) {
|
||||
tty->print_cr("IC@" INTPTR_FORMAT ": set to clean", p2i(instruction_address()));
|
||||
@ -337,7 +338,7 @@ void CompiledIC::set_to_clean() {
|
||||
|
||||
// A zombie transition will always be safe, since the metadata has already been set to NULL, so
|
||||
// we only need to patch the destination
|
||||
bool safe_transition = is_optimized() || SafepointSynchronize::is_at_safepoint();
|
||||
bool safe_transition = !in_use || is_optimized() || SafepointSynchronize::is_at_safepoint();
|
||||
|
||||
if (safe_transition) {
|
||||
// Kill any leftover stub we might have too
|
||||
|
||||
@ -214,7 +214,7 @@ class CompiledIC: public ResourceObj {
|
||||
//
|
||||
// They all takes a TRAP argument, since they can cause a GC if the inline-cache buffer is full.
|
||||
//
|
||||
void set_to_clean();
|
||||
void set_to_clean(bool in_use = true);
|
||||
void set_to_monomorphic(CompiledICInfo& info);
|
||||
void clear_ic_stub();
|
||||
|
||||
|
||||
@ -1050,7 +1050,7 @@ void nmethod::cleanup_inline_caches() {
|
||||
if( cb != NULL && cb->is_nmethod() ) {
|
||||
nmethod* nm = (nmethod*)cb;
|
||||
// Clean inline caches pointing to zombie, non-entrant and unloaded methods
|
||||
if (!nm->is_in_use() || (nm->method()->code() != nm)) ic->set_to_clean();
|
||||
if (!nm->is_in_use() || (nm->method()->code() != nm)) ic->set_to_clean(is_alive());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1150,7 +1150,7 @@ void nmethod::mark_as_seen_on_stack() {
|
||||
// Tell if a non-entrant method can be converted to a zombie (i.e.,
|
||||
// there are no activations on the stack, not in use by the VM,
|
||||
// and not in use by the ServiceThread)
|
||||
bool nmethod::can_not_entrant_be_converted() {
|
||||
bool nmethod::can_convert_to_zombie() {
|
||||
assert(is_not_entrant(), "must be a non-entrant method");
|
||||
|
||||
// Since the nmethod sweeper only does partial sweep the sweeper's traversal
|
||||
|
||||
@ -577,7 +577,7 @@ public:
|
||||
|
||||
// See comment at definition of _last_seen_on_stack
|
||||
void mark_as_seen_on_stack();
|
||||
bool can_not_entrant_be_converted();
|
||||
bool can_convert_to_zombie();
|
||||
|
||||
// Evolution support. We make old (discarded) compiled methods point to new Method*s.
|
||||
void set_method(Method* method) { _method = method; }
|
||||
|
||||
@ -673,8 +673,7 @@ static void enqueue_cfg_uses(Node* m, Unique_Node_List& wq) {
|
||||
Node* PhaseIdealLoop::try_move_store_before_loop(Node* n, Node *n_ctrl) {
|
||||
// Store has to be first in the loop body
|
||||
IdealLoopTree *n_loop = get_loop(n_ctrl);
|
||||
if (n->is_Store() && n_loop != _ltree_root && n_loop->is_loop()) {
|
||||
assert(n->in(0), "store should have control set");
|
||||
if (n->is_Store() && n_loop != _ltree_root && n_loop->is_loop() && n->in(0) != NULL) {
|
||||
Node* address = n->in(MemNode::Address);
|
||||
Node* value = n->in(MemNode::ValueIn);
|
||||
Node* mem = n->in(MemNode::Memory);
|
||||
@ -748,8 +747,7 @@ Node* PhaseIdealLoop::try_move_store_before_loop(Node* n, Node *n_ctrl) {
|
||||
|
||||
// Try moving a store out of a loop, right after the loop
|
||||
void PhaseIdealLoop::try_move_store_after_loop(Node* n) {
|
||||
if (n->is_Store()) {
|
||||
assert(n->in(0), "store should have control set");
|
||||
if (n->is_Store() && n->in(0) != NULL) {
|
||||
Node *n_ctrl = get_ctrl(n);
|
||||
IdealLoopTree *n_loop = get_loop(n_ctrl);
|
||||
// Store must be in a loop
|
||||
|
||||
@ -1576,51 +1576,58 @@ void PhaseStringOpts::replace_string_concat(StringConcat* sc) {
|
||||
|
||||
Node* result;
|
||||
if (!kit.stopped()) {
|
||||
|
||||
// length now contains the number of characters needed for the
|
||||
// char[] so create a new AllocateArray for the char[]
|
||||
Node* char_array = NULL;
|
||||
{
|
||||
PreserveReexecuteState preexecs(&kit);
|
||||
// The original jvms is for an allocation of either a String or
|
||||
// StringBuffer so no stack adjustment is necessary for proper
|
||||
// reexecution. If we deoptimize in the slow path the bytecode
|
||||
// will be reexecuted and the char[] allocation will be thrown away.
|
||||
kit.jvms()->set_should_reexecute(true);
|
||||
char_array = kit.new_array(__ makecon(TypeKlassPtr::make(ciTypeArrayKlass::make(T_CHAR))),
|
||||
length, 1);
|
||||
}
|
||||
if (sc->num_arguments() == 1 &&
|
||||
(sc->mode(0) == StringConcat::StringMode ||
|
||||
sc->mode(0) == StringConcat::StringNullCheckMode)) {
|
||||
// Handle the case when there is only a single String argument.
|
||||
// In this case, we can just pull the value from the String itself.
|
||||
char_array = kit.load_String_value(kit.control(), sc->argument(0));
|
||||
} else {
|
||||
// length now contains the number of characters needed for the
|
||||
// char[] so create a new AllocateArray for the char[]
|
||||
{
|
||||
PreserveReexecuteState preexecs(&kit);
|
||||
// The original jvms is for an allocation of either a String or
|
||||
// StringBuffer so no stack adjustment is necessary for proper
|
||||
// reexecution. If we deoptimize in the slow path the bytecode
|
||||
// will be reexecuted and the char[] allocation will be thrown away.
|
||||
kit.jvms()->set_should_reexecute(true);
|
||||
char_array = kit.new_array(__ makecon(TypeKlassPtr::make(ciTypeArrayKlass::make(T_CHAR))),
|
||||
length, 1);
|
||||
}
|
||||
|
||||
// Mark the allocation so that zeroing is skipped since the code
|
||||
// below will overwrite the entire array
|
||||
AllocateArrayNode* char_alloc = AllocateArrayNode::Ideal_array_allocation(char_array, _gvn);
|
||||
char_alloc->maybe_set_complete(_gvn);
|
||||
// Mark the allocation so that zeroing is skipped since the code
|
||||
// below will overwrite the entire array
|
||||
AllocateArrayNode* char_alloc = AllocateArrayNode::Ideal_array_allocation(char_array, _gvn);
|
||||
char_alloc->maybe_set_complete(_gvn);
|
||||
|
||||
// Now copy the string representations into the final char[]
|
||||
Node* start = __ intcon(0);
|
||||
for (int argi = 0; argi < sc->num_arguments(); argi++) {
|
||||
Node* arg = sc->argument(argi);
|
||||
switch (sc->mode(argi)) {
|
||||
case StringConcat::IntMode: {
|
||||
Node* end = __ AddI(start, string_sizes->in(argi));
|
||||
// getChars words backwards so pass the ending point as well as the start
|
||||
int_getChars(kit, arg, char_array, start, end);
|
||||
start = end;
|
||||
break;
|
||||
// Now copy the string representations into the final char[]
|
||||
Node* start = __ intcon(0);
|
||||
for (int argi = 0; argi < sc->num_arguments(); argi++) {
|
||||
Node* arg = sc->argument(argi);
|
||||
switch (sc->mode(argi)) {
|
||||
case StringConcat::IntMode: {
|
||||
Node* end = __ AddI(start, string_sizes->in(argi));
|
||||
// getChars words backwards so pass the ending point as well as the start
|
||||
int_getChars(kit, arg, char_array, start, end);
|
||||
start = end;
|
||||
break;
|
||||
}
|
||||
case StringConcat::StringNullCheckMode:
|
||||
case StringConcat::StringMode: {
|
||||
start = copy_string(kit, arg, char_array, start);
|
||||
break;
|
||||
}
|
||||
case StringConcat::CharMode: {
|
||||
__ store_to_memory(kit.control(), kit.array_element_address(char_array, start, T_CHAR),
|
||||
arg, T_CHAR, char_adr_idx, MemNode::unordered);
|
||||
start = __ AddI(start, __ intcon(1));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
case StringConcat::StringNullCheckMode:
|
||||
case StringConcat::StringMode: {
|
||||
start = copy_string(kit, arg, char_array, start);
|
||||
break;
|
||||
}
|
||||
case StringConcat::CharMode: {
|
||||
__ store_to_memory(kit.control(), kit.array_element_address(char_array, start, T_CHAR),
|
||||
arg, T_CHAR, char_adr_idx, MemNode::unordered);
|
||||
start = __ AddI(start, __ intcon(1));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -611,7 +611,7 @@ NMethodSweeper::MethodStateChange NMethodSweeper::process_nmethod(nmethod* nm) {
|
||||
} else if (nm->is_not_entrant()) {
|
||||
// If there are no current activations of this method on the
|
||||
// stack we can safely convert it to a zombie method
|
||||
if (nm->can_not_entrant_be_converted()) {
|
||||
if (nm->can_convert_to_zombie()) {
|
||||
// Clear ICStubs to prevent back patching stubs of zombie or unloaded
|
||||
// nmethods during the next safepoint (see ICStub::finalize).
|
||||
{
|
||||
@ -645,6 +645,12 @@ NMethodSweeper::MethodStateChange NMethodSweeper::process_nmethod(nmethod* nm) {
|
||||
assert(result == None, "sanity");
|
||||
result = Flushed;
|
||||
} else {
|
||||
{
|
||||
// Clean ICs of unloaded nmethods as well because they may reference other
|
||||
// unloaded nmethods that may be flushed earlier in the sweeper cycle.
|
||||
MutexLocker cl(CompiledIC_lock);
|
||||
nm->cleanup_inline_caches();
|
||||
}
|
||||
// Code cache state change is tracked in make_zombie()
|
||||
nm->make_zombie();
|
||||
SWEEP(nm);
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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 8134288
|
||||
* @summary Store nodes may not have a control if used to update profiling
|
||||
* @run main/othervm -XX:-ProfileInterpreter -XX:-TieredCompilation -XX:-BackgroundCompilation TestMoveStoresOutOfLoopsStoreNoCtrl
|
||||
*
|
||||
*/
|
||||
|
||||
public class TestMoveStoresOutOfLoopsStoreNoCtrl {
|
||||
|
||||
static void test(boolean flag) {
|
||||
for (int i = 0; i < 20000; i++) {
|
||||
if (flag) {
|
||||
int j = 0;
|
||||
do {
|
||||
j++;
|
||||
} while(j < 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public void main(String[] args) {
|
||||
test(false);
|
||||
}
|
||||
|
||||
}
|
||||
@ -323,3 +323,4 @@ be357705874c4ba1a69c38fb211e5e31e35bf9cb jdk9-b77
|
||||
5b1899c9822db4a80a29cac82af492afea9f8f41 jdk9-b78
|
||||
cf809edc840ff7546677d38b13ebd8b3cae2bbda jdk9-b79
|
||||
f464f9b2fb1178f6a957e5730b4b5252c6149ed9 jdk9-b80
|
||||
6a418934997fc4b56664b88f8417e2f0fe658091 jdk9-b81
|
||||
|
||||
@ -326,3 +326,4 @@ bd6ece68cf8aca34c8d992569892060c82cfd3f1 jdk9-b77
|
||||
ac1748bab0743137574be3451307b6a6361719eb jdk9-b78
|
||||
42ae657e0e104fa7877996b8095f2e3ab1596118 jdk9-b79
|
||||
e9940bf1c8ddaa6f1f5f1813846b080f0ccaf50b jdk9-b80
|
||||
139338618c77d793ab8b550f06819ddb8381316f jdk9-b81
|
||||
|
||||
@ -323,3 +323,4 @@ f376824d4940f45719d91838f3f6249f873440db jdk9-b72
|
||||
0940ce86c614458f5bdd72278b190abbf36b7b45 jdk9-b78
|
||||
d99c2ffdd0f15753e69126583688f2f075a0a5e8 jdk9-b79
|
||||
4947810137ae53abba3028cc366af953d90fa81a jdk9-b80
|
||||
fdc13a2d32867ca3c57b7fa2620c6b59c83168cb jdk9-b81
|
||||
|
||||
@ -38,7 +38,9 @@ include SetupJavaCompilers.gmk
|
||||
|
||||
$(eval $(call SetupJavaCompilation,BUILD_TOOLS_JDK, \
|
||||
SETUP := GENERATE_OLDBYTECODE, \
|
||||
ADD_JAVAC_FLAGS := "-Xbootclasspath/p:$(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes$(PATH_SEP)$(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes", \
|
||||
ADD_JAVAC_FLAGS := -Xbootclasspath/p:$(call PathList, \
|
||||
$(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes \
|
||||
$(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes), \
|
||||
SRC := $(JDK_TOPDIR)/make/src/classes $(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes, \
|
||||
BIN := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes, \
|
||||
COPY := boot.modules ext.modules))
|
||||
@ -126,11 +128,11 @@ TOOL_CLDRCONVERTER = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes
|
||||
build.tools.cldrconverter.CLDRConverter
|
||||
|
||||
TOOL_GENMODULESXML = $(JAVA_SMALL) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \
|
||||
-cp "$(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes$(PATH_SEP)$(JDK_OUTPUTDIR)" \
|
||||
-cp $(call PathList, $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes $(JDK_OUTPUTDIR)) \
|
||||
build.tools.module.GenJdepsModulesXml
|
||||
|
||||
TOOL_IMAGEBUILDER = $(JAVA_SMALL) -Xbootclasspath/p:$(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes \
|
||||
-cp "$(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes$(PATH_SEP)$(JDK_OUTPUTDIR)" \
|
||||
-cp $(call PathList, $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes $(JDK_OUTPUTDIR)) \
|
||||
build.tools.module.ImageBuilder
|
||||
|
||||
##########################################################################################
|
||||
@ -157,28 +159,6 @@ $(eval $(call SetupCopyFiles,COPY_JIMAGE_SERVICE_PROVIDER, \
|
||||
|
||||
##########################################################################################
|
||||
|
||||
# Tools needed on solaris because OBJCOPY is broken.
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_OS), solaris)
|
||||
$(eval $(call SetupNativeCompilation,ADD_GNU_DEBUGLINK, \
|
||||
SRC := $(JDK_TOPDIR)/make/src/native/add_gnu_debuglink, \
|
||||
TOOLCHAIN := TOOLCHAIN_BUILD, \
|
||||
LDFLAGS := -lelf, \
|
||||
OBJECT_DIR := $(BUILDTOOLS_OUTPUTDIR)/objs/add_gnu_debuglink, \
|
||||
OUTPUT_DIR := $(BUILDTOOLS_OUTPUTDIR)/bin, \
|
||||
PROGRAM := add_gnu_debuglink))
|
||||
|
||||
$(eval $(call SetupNativeCompilation,FIX_EMPTY_SEC_HDR_FLAGS, \
|
||||
SRC := $(JDK_TOPDIR)/make/src/native/fix_empty_sec_hdr_flags, \
|
||||
TOOLCHAIN := TOOLCHAIN_BUILD, \
|
||||
LDFLAGS := -lelf, \
|
||||
OBJECT_DIR := $(BUILDTOOLS_OUTPUTDIR)/objs/fix_empty_sec_hdr_flags, \
|
||||
OUTPUT_DIR := $(BUILDTOOLS_OUTPUTDIR)/bin, \
|
||||
PROGRAM := fix_empty_sec_hdr_flags))
|
||||
|
||||
BUILD_TOOLS_JDK += $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS)
|
||||
endif
|
||||
|
||||
$(BUILD_TOOLS_JDK): $(BUILD_INTERIM_JIMAGE) $(COPY_JIMAGE_SERVICE_PROVIDER)
|
||||
|
||||
java-tools: $(BUILD_TOOLS_JDK)
|
||||
|
||||
@ -77,9 +77,9 @@ $(BEANINFO_OUTPUTDIR)/_the.generated_beaninfo: $(BEANS_SRC) \
|
||||
$(ECHO) Generating beaninfo
|
||||
$(MKDIR) -p $(BEANINFO_OUTPUTDIR)/javax/swing
|
||||
$(JAVA) -Djava.awt.headless=true $(NEW_JAVADOC) \
|
||||
-sourcepath "$(subst $(SPACE),$(PATH_SEP),\
|
||||
-sourcepath $(call PathList,\
|
||||
$(wildcard $(JDK_TOPDIR)/src/*/*/classes) \
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/java.base)" \
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/java.base) \
|
||||
-doclet build.tools.swingbeaninfo.GenDocletBeanInfo \
|
||||
-x $(SWINGBEAN_DEBUG_FLAG) -d $(BEANINFO_OUTPUTDIR)/javax/swing \
|
||||
-t $(DOCLET_DATA_DIR)/SwingBeanInfo.template \
|
||||
|
||||
@ -28,9 +28,6 @@ include NativeCompilation.gmk
|
||||
# Prepare the find cache.
|
||||
$(eval $(call FillCacheFind, $(JDK_TOPDIR)/src/java.base/share/native/launcher))
|
||||
|
||||
# Build tools
|
||||
include Tools.gmk
|
||||
|
||||
# When building a legacy overlay image (on solaris 64 bit), the launchers
|
||||
# need to be built with a different rpath and a different output dir.
|
||||
ifeq ($(OVERLAY_IMAGES), true)
|
||||
|
||||
@ -27,9 +27,6 @@ include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
include NativeCompilation.gmk
|
||||
|
||||
# Build tools
|
||||
include Tools.gmk
|
||||
|
||||
GLOBAL_VERSION_INFO_RESOURCE := $(JDK_TOPDIR)/src/java.base/windows/native/common/version.rc
|
||||
|
||||
# Absolute paths to lib files on windows for use in LDFLAGS. Should figure out a more
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,8 +28,7 @@
|
||||
SUNWprivate_1.1 {
|
||||
global:
|
||||
JNI_OnLoad;
|
||||
Java_java_net_AbstractPlainDatagramSocketImpl_init;
|
||||
Java_java_net_AbstractPlainDatagramSocketImpl_dataAvailable;
|
||||
Java_java_net_PlainDatagramSocketImpl_dataAvailable;
|
||||
Java_java_net_PlainSocketImpl_socketListen;
|
||||
Java_java_net_PlainDatagramSocketImpl_getTTL;
|
||||
Java_java_net_PlainDatagramSocketImpl_init;
|
||||
|
||||
@ -31,8 +31,9 @@ include RMICompilation.gmk
|
||||
|
||||
##########################################################################################
|
||||
|
||||
BTRMIC_CP := $(INTERIM_CORBA_JAR)$(PATH_SEP)$(BUILDTOOLS_OUTPUTDIR)/interim_rmic_classes$(PATH_SEP)$(INTERIM_LANGTOOLS_JAR)
|
||||
BTRMIC_ARGS := "-Xbootclasspath/p:$(BTRMIC_CP)" -cp "$(BTRMIC_CP)"
|
||||
BTRMIC_CP := $(call PathList, $(INTERIM_CORBA_JAR) \
|
||||
$(BUILDTOOLS_OUTPUTDIR)/interim_rmic_classes $(INTERIM_LANGTOOLS_JAR))
|
||||
BTRMIC_ARGS := -Xbootclasspath/p:$(BTRMIC_CP) -cp $(BTRMIC_CP)
|
||||
RMIC := $(JAVA) $(BTRMIC_ARGS) sun.rmi.rmic.Main
|
||||
|
||||
CLASSES_DIR := $(JDK_OUTPUTDIR)/modules
|
||||
|
||||
@ -27,15 +27,12 @@ package build.tools.cldrconverter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
class Bundle {
|
||||
static enum Type {
|
||||
@ -117,6 +114,7 @@ class Bundle {
|
||||
private final String cldrPath;
|
||||
private final EnumSet<Type> bundleTypes;
|
||||
private final String currencies;
|
||||
private Map<String, Object> targetMap;
|
||||
|
||||
static Bundle getBundle(String id) {
|
||||
return bundles.get(id);
|
||||
@ -176,6 +174,10 @@ class Bundle {
|
||||
* visible for the bundle's locale
|
||||
*/
|
||||
Map<String, Object> getTargetMap() throws Exception {
|
||||
if (targetMap != null) {
|
||||
return targetMap;
|
||||
}
|
||||
|
||||
String[] cldrBundles = getCLDRPath().split(",");
|
||||
|
||||
// myMap contains resources for id.
|
||||
@ -398,6 +400,7 @@ class Bundle {
|
||||
}
|
||||
}
|
||||
|
||||
targetMap = myMap;
|
||||
return myMap;
|
||||
}
|
||||
|
||||
@ -632,7 +635,7 @@ class Bundle {
|
||||
return null;
|
||||
}
|
||||
|
||||
static Object[][] jreTimeZoneNames = TimeZoneNames.getContents();
|
||||
static List<Object[]> jreTimeZoneNames = Arrays.asList(TimeZoneNames.getContents());
|
||||
private void fillInJREs(String key, Map<String, String> map) {
|
||||
String tzid = null;
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
package build.tools.cldrconverter;
|
||||
|
||||
import static build.tools.cldrconverter.Bundle.jreTimeZoneNames;
|
||||
import build.tools.cldrconverter.BundleGenerator.BundleType;
|
||||
import java.io.File;
|
||||
import java.nio.file.DirectoryStream;
|
||||
@ -564,6 +565,44 @@ public class CLDRConverter {
|
||||
|
||||
private static Map<String, Object> extractZoneNames(Map<String, Object> map, String id) {
|
||||
Map<String, Object> names = new HashMap<>();
|
||||
|
||||
// Copy over missing time zone ids from JRE for English locale
|
||||
if (id.equals("en")) {
|
||||
Map<String[], String> jreMetaMap = new HashMap<>();
|
||||
jreTimeZoneNames.stream().forEach(e -> {
|
||||
String tzid = (String)e[0];
|
||||
String[] data = (String[])e[1];
|
||||
|
||||
if (map.get(TIMEZONE_ID_PREFIX + tzid) == null &&
|
||||
handlerMetaZones.get(tzid) == null) {
|
||||
// First, check the CLDR meta key
|
||||
Optional<Map.Entry<String, String>> cldrMeta =
|
||||
handlerMetaZones.getData().entrySet().stream()
|
||||
.filter(me ->
|
||||
Arrays.deepEquals(data,
|
||||
(String[])map.get(METAZONE_ID_PREFIX + me.getValue())))
|
||||
.findAny();
|
||||
if (cldrMeta.isPresent()) {
|
||||
names.put(tzid, cldrMeta.get().getValue());
|
||||
} else {
|
||||
// check the JRE meta key, add if there is not.
|
||||
Optional<Map.Entry<String[], String>> jreMeta =
|
||||
jreMetaMap.entrySet().stream()
|
||||
.filter(jm -> Arrays.deepEquals(data, jm.getKey()))
|
||||
.findAny();
|
||||
if (jreMeta.isPresent()) {
|
||||
names.put(tzid, jreMeta.get().getValue());
|
||||
} else {
|
||||
String metaName = "JRE_" + tzid.replaceAll("[/-]", "_");
|
||||
names.put(METAZONE_ID_PREFIX + metaName, data);
|
||||
names.put(tzid, metaName);
|
||||
jreMetaMap.put(data, metaName);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (String tzid : handlerMetaZones.keySet()) {
|
||||
String tzKey = TIMEZONE_ID_PREFIX + tzid;
|
||||
Object data = map.get(tzKey);
|
||||
|
||||
@ -266,22 +266,47 @@ class ResourceBundleGenerator implements BundleGenerator {
|
||||
out.println((CLDRConverter.isBaseModule ? "package sun.util.cldr;\n\n" :
|
||||
"package sun.util.resources.cldr.provider;\n\n")
|
||||
+ "import java.util.HashMap;\n"
|
||||
+ "import java.util.Locale;\n"
|
||||
+ "import java.util.Map;\n"
|
||||
+ "import java.util.ListResourceBundle;\n"
|
||||
+ "import sun.util.locale.provider.LocaleProviderAdapter;\n"
|
||||
+ "import sun.util.locale.provider.LocaleDataMetaInfo;\n");
|
||||
out.printf("public class %s extends ListResourceBundle implements LocaleDataMetaInfo {\n", className);
|
||||
out.println(" @Override\n" +
|
||||
" protected final Object[][] getContents() {\n" +
|
||||
" final Object[][] data = new Object[][] {");
|
||||
out.printf("public class %s implements LocaleDataMetaInfo {\n", className);
|
||||
out.println(" private static final Map<String, String> resourceNameToLocales = new HashMap<>();\n" +
|
||||
(CLDRConverter.isBaseModule ?
|
||||
" private static final Map<Locale, String[]> parentLocalesMap = new HashMap<>();\n\n" : "\n") +
|
||||
" static {\n");
|
||||
|
||||
for (String key : metaInfo.keySet()) {
|
||||
out.printf(" { \"%s\",\n", key);
|
||||
out.printf(" \"%s\" },\n",
|
||||
if (key.startsWith(CLDRConverter.PARENT_LOCALE_PREFIX)) {
|
||||
String parentTag = key.substring(CLDRConverter.PARENT_LOCALE_PREFIX.length());
|
||||
if ("root".equals(parentTag)) {
|
||||
out.printf(" parentLocalesMap.put(Locale.ROOT,\n");
|
||||
} else {
|
||||
out.printf(" parentLocalesMap.put(Locale.forLanguageTag(\"%s\"),\n",
|
||||
parentTag);
|
||||
}
|
||||
String[] childlen = toLocaleList(metaInfo.get(key), true).split(" ");
|
||||
out.printf(" new String[] {\n" +
|
||||
" ");
|
||||
int count = 0;
|
||||
for (int i = 0; i < childlen.length; i++) {
|
||||
String child = childlen[i];
|
||||
out.printf("\"%s\", ", child);
|
||||
count += child.length() + 4;
|
||||
if (i != childlen.length - 1 && count > 64) {
|
||||
out.printf("\n ");
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
out.printf("\n });\n");
|
||||
} else {
|
||||
out.printf(" resourceNameToLocales.put(\"%s\",\n", key);
|
||||
out.printf(" \"%s\");\n",
|
||||
toLocaleList(key.equals("FormatData") ? metaInfo.get("AvailableLocales") :
|
||||
metaInfo.get(key),
|
||||
key.startsWith(CLDRConverter.PARENT_LOCALE_PREFIX)));
|
||||
metaInfo.get(key), false));
|
||||
}
|
||||
}
|
||||
out.println(" };\n return data;\n }\n\n");
|
||||
out.println(" }\n\n");
|
||||
|
||||
out.println(" @Override\n" +
|
||||
" public LocaleProviderAdapter.Type getType() {\n" +
|
||||
@ -290,19 +315,13 @@ class ResourceBundleGenerator implements BundleGenerator {
|
||||
|
||||
out.println(" @Override\n" +
|
||||
" public String availableLanguageTags(String category) {\n" +
|
||||
" return getString(category);\n" +
|
||||
" };\n\n");
|
||||
" return resourceNameToLocales.getOrDefault(category, \"\");\n" +
|
||||
" }\n\n");
|
||||
|
||||
if (CLDRConverter.isBaseModule) {
|
||||
out.printf(" public Map<String, String> parentLocales() {\n" +
|
||||
" Map<String, String> ret = new HashMap<>();\n" +
|
||||
" keySet().stream()\n" +
|
||||
" .filter(key -> key.startsWith(\"%s\"))\n" +
|
||||
" .forEach(key -> ret.put(key.substring(%d), getString(key)));\n" +
|
||||
" return ret.isEmpty() ? null : ret;\n" +
|
||||
" };\n}",
|
||||
CLDRConverter.PARENT_LOCALE_PREFIX,
|
||||
CLDRConverter.PARENT_LOCALE_PREFIX.length());
|
||||
out.printf(" public Map<Locale, String[]> parentLocales() {\n" +
|
||||
" return parentLocalesMap;\n" +
|
||||
" }\n}");
|
||||
} else {
|
||||
out.println("}");
|
||||
}
|
||||
|
||||
@ -1,285 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Name: add_gnu_debuglink.c
|
||||
*
|
||||
* Description: Add a ".gnu_debuglink" section that refers to the specified
|
||||
* debug_info_path to the specified ELF object.
|
||||
*
|
||||
* This program is adapted from the example program shown on the
|
||||
* elf(3elf) man page and from code from the Solaris compiler
|
||||
* driver.
|
||||
*/
|
||||
|
||||
/*
|
||||
* needed to define SHF_EXCLUDE
|
||||
*/
|
||||
#define ELF_TARGET_ALL
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <libelf.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void failure(void);
|
||||
static unsigned int gnu_debuglink_crc32(unsigned int crc, unsigned char *buf,
|
||||
size_t len);
|
||||
|
||||
void
|
||||
main(int argc, char ** argv) {
|
||||
/* new ELF section name */
|
||||
static char SEC_NAME[] = ".gnu_debuglink";
|
||||
|
||||
unsigned char buffer[8 * 1024]; /* I/O buffer */
|
||||
int buffer_len; /* buffer length */
|
||||
char * debug_info_path; /* debug info path */
|
||||
void * ehdr; /* ELF header */
|
||||
Elf * elf; /* ELF descriptor */
|
||||
char * elf_ident; /* ELF identity string */
|
||||
char * elf_obj; /* elf_obj file */
|
||||
int fd; /* descriptor for files */
|
||||
unsigned int file_crc = 0; /* CRC for debug info file */
|
||||
int is_elfclass64; /* is an ELFCLASS64 file? */
|
||||
Elf_Data * link_dat; /* ELF data for new debug info link */
|
||||
Elf_Data * name_dat; /* ELF data for new section name */
|
||||
Elf_Scn * new_scn; /* new ELF section descriptor */
|
||||
void * new_shdr; /* new ELF section header */
|
||||
Elf_Scn * scn; /* ELF section descriptor */
|
||||
void * shdr; /* ELF section header */
|
||||
|
||||
if (argc != 3) {
|
||||
(void) fprintf(stderr, "Usage: %s debug_info_path elf_obj\n", argv[0]);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
debug_info_path = argv[1]; /* save for later */
|
||||
if ((fd = open(debug_info_path, O_RDONLY)) == -1) {
|
||||
(void) fprintf(stderr, "%s: cannot open file.\n", debug_info_path);
|
||||
exit(3);
|
||||
}
|
||||
|
||||
(void) printf("Computing CRC for '%s'\n", debug_info_path);
|
||||
(void) fflush(stdout);
|
||||
/* compute CRC for the debug info file */
|
||||
for (;;) {
|
||||
int len = read(fd, buffer, sizeof buffer);
|
||||
if (len <= 0) {
|
||||
break;
|
||||
}
|
||||
file_crc = gnu_debuglink_crc32(file_crc, buffer, len);
|
||||
}
|
||||
(void) close(fd);
|
||||
|
||||
/* open the elf_obj */
|
||||
elf_obj = argv[2];
|
||||
if ((fd = open(elf_obj, O_RDWR)) == -1) {
|
||||
(void) fprintf(stderr, "%s: cannot open file.\n", elf_obj);
|
||||
exit(4);
|
||||
}
|
||||
|
||||
(void) printf("Opening '%s' for update\n", elf_obj);
|
||||
(void) fflush(stdout);
|
||||
(void) elf_version(EV_CURRENT); /* coordinate ELF versions */
|
||||
|
||||
/* obtain the ELF descriptors from the input file */
|
||||
if ((elf = elf_begin(fd, ELF_C_RDWR, NULL)) == NULL) {
|
||||
failure();
|
||||
}
|
||||
|
||||
/* determine if ELFCLASS64 or not? */
|
||||
elf_ident = elf_getident(elf, NULL);
|
||||
is_elfclass64 = (elf_ident[EI_CLASS] == ELFCLASS64);
|
||||
|
||||
/* get the ELF header */
|
||||
if (is_elfclass64) {
|
||||
ehdr = elf64_getehdr(elf);
|
||||
} else {
|
||||
ehdr = elf32_getehdr(elf);
|
||||
}
|
||||
if (ehdr == NULL) {
|
||||
failure();
|
||||
}
|
||||
|
||||
/* get the ELF section descriptor */
|
||||
if (is_elfclass64) {
|
||||
scn = elf_getscn(elf, ((Elf64_Ehdr *) ehdr)->e_shstrndx);
|
||||
} else {
|
||||
scn = elf_getscn(elf, ((Elf32_Ehdr *) ehdr)->e_shstrndx);
|
||||
}
|
||||
if (scn == NULL) {
|
||||
failure();
|
||||
}
|
||||
|
||||
/* get the section header */
|
||||
if (is_elfclass64) {
|
||||
shdr = elf64_getshdr(scn);
|
||||
} else {
|
||||
shdr = elf32_getshdr(scn);
|
||||
}
|
||||
if (shdr == NULL) {
|
||||
failure();
|
||||
}
|
||||
|
||||
(void) printf("Adding ELF data for new section name\n");
|
||||
(void) fflush(stdout);
|
||||
name_dat = elf_newdata(scn);
|
||||
name_dat->d_buf = (void *) SEC_NAME;
|
||||
if (is_elfclass64) {
|
||||
name_dat->d_off = ((Elf64_Shdr *) shdr)->sh_size + 1;
|
||||
} else {
|
||||
name_dat->d_off = ((Elf32_Shdr *) shdr)->sh_size + 1;
|
||||
}
|
||||
name_dat->d_align = 1;
|
||||
name_dat->d_size = strlen(SEC_NAME) + 1;
|
||||
|
||||
new_scn = elf_newscn(elf);
|
||||
|
||||
if (is_elfclass64) {
|
||||
new_shdr = elf64_getshdr(new_scn);
|
||||
((Elf64_Shdr *) new_shdr)->sh_flags = SHF_EXCLUDE;
|
||||
((Elf64_Shdr *) new_shdr)->sh_type = SHT_PROGBITS;
|
||||
((Elf64_Shdr *) new_shdr)->sh_name = ((Elf64_Shdr *) shdr)->sh_size;
|
||||
((Elf64_Shdr *) new_shdr)->sh_addralign = 1;
|
||||
((Elf64_Shdr *) shdr)->sh_size += (strlen(SEC_NAME) + 1);
|
||||
} else {
|
||||
new_shdr = elf32_getshdr(new_scn);
|
||||
((Elf32_Shdr *) new_shdr)->sh_flags = SHF_EXCLUDE;
|
||||
((Elf32_Shdr *) new_shdr)->sh_type = SHT_PROGBITS;
|
||||
((Elf32_Shdr *) new_shdr)->sh_name = ((Elf32_Shdr *) shdr)->sh_size;
|
||||
((Elf32_Shdr *) new_shdr)->sh_addralign = 1;
|
||||
((Elf32_Shdr *) shdr)->sh_size += (strlen(SEC_NAME) + 1);
|
||||
}
|
||||
|
||||
(void) printf("Adding ELF data for debug_info_path value\n");
|
||||
(void) fflush(stdout);
|
||||
(void) memset(buffer, 0, sizeof buffer);
|
||||
buffer_len = strlen(debug_info_path) + 1; /* +1 for NUL */
|
||||
(void) strncpy((char *) buffer, debug_info_path, buffer_len);
|
||||
if (buffer_len % 4 != 0) {
|
||||
/* not on a 4 byte boundary so pad to the next one */
|
||||
buffer_len += (4 - buffer_len % 4);
|
||||
}
|
||||
/* save the CRC */
|
||||
(void) memcpy(&buffer[buffer_len], &file_crc, sizeof file_crc);
|
||||
buffer_len += sizeof file_crc;
|
||||
|
||||
link_dat = elf_newdata(new_scn);
|
||||
link_dat->d_type = ELF_T_BYTE;
|
||||
link_dat->d_size = buffer_len;
|
||||
link_dat->d_buf = buffer;
|
||||
link_dat->d_align = 1;
|
||||
|
||||
(void) printf("Saving updates to '%s'\n", elf_obj);
|
||||
(void) fflush(stdout);
|
||||
(void) elf_update(elf, ELF_C_NULL); /* recalc ELF memory structures */
|
||||
(void) elf_update(elf, ELF_C_WRITE); /* write out changes to ELF obj */
|
||||
(void) elf_end(elf); /* done with ELF obj */
|
||||
(void) close(fd);
|
||||
|
||||
(void) printf("Done updating '%s'\n", elf_obj);
|
||||
(void) fflush(stdout);
|
||||
exit(0);
|
||||
} /* end main */
|
||||
|
||||
|
||||
static void
|
||||
failure() {
|
||||
(void) fprintf(stderr, "%s\n", elf_errmsg(elf_errno()));
|
||||
exit(5);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The CRC used in gnu_debuglink, retrieved from
|
||||
* http://sourceware.org/gdb/current/onlinedocs/gdb/Separate-Debug-Files.html#Separate-Debug-Files.
|
||||
*/
|
||||
|
||||
static unsigned int
|
||||
gnu_debuglink_crc32(unsigned int crc, unsigned char *buf, size_t len) {
|
||||
static const unsigned int crc32_table[256] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
|
||||
0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
|
||||
0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
|
||||
0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
||||
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
|
||||
0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
||||
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
|
||||
0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
||||
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
|
||||
0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
|
||||
0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
|
||||
0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
||||
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
|
||||
0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
|
||||
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
|
||||
0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
||||
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
|
||||
0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
||||
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
|
||||
0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
|
||||
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
|
||||
0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
|
||||
0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
|
||||
0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
|
||||
0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
|
||||
0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
|
||||
0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
||||
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
|
||||
0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
||||
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
|
||||
0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
||||
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
|
||||
0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
|
||||
0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
|
||||
0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
||||
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
|
||||
0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
|
||||
0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
|
||||
0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
||||
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
|
||||
0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
||||
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
|
||||
0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
|
||||
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
|
||||
0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
|
||||
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
|
||||
0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
|
||||
0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
|
||||
0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
|
||||
0x2d02ef8d
|
||||
};
|
||||
|
||||
unsigned char *end;
|
||||
|
||||
crc = ~crc & 0xffffffff;
|
||||
for (end = buf + len; buf < end; ++buf) {
|
||||
crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
|
||||
}
|
||||
return ~crc & 0xffffffff;
|
||||
}
|
||||
@ -1,181 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Name: fix_empty_sec_hdr_flags.c
|
||||
*
|
||||
* Description: Remove the SHF_ALLOC flag from "empty" section headers.
|
||||
* An "empty" section header has sh_addr == 0 and sh_size == 0.
|
||||
*
|
||||
* This program is adapted from the example program shown on the
|
||||
* elf(3elf) man page and from code from the Solaris compiler
|
||||
* driver.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <libelf.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void failure(void);
|
||||
|
||||
void
|
||||
main(int argc, char ** argv) {
|
||||
void * ehdr; /* ELF header */
|
||||
unsigned int i; /* section counter */
|
||||
int fd; /* descriptor for file */
|
||||
Elf * elf; /* ELF descriptor */
|
||||
char * elf_ident; /* ELF identity string */
|
||||
char * elf_obj; /* elf_obj file */
|
||||
int fix_count; /* number of flags fixed */
|
||||
int is_elfclass64; /* is an ELFCLASS64 file? */
|
||||
Elf_Scn * scn; /* ELF section descriptor */
|
||||
void * shdr; /* ELF section header */
|
||||
Elf_Data * shstrtab; /* ELF section header string table */
|
||||
|
||||
if (argc != 2) {
|
||||
(void) fprintf(stderr, "Usage: %s elf_obj\n", argv[0]);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/* open the elf_obj */
|
||||
elf_obj = argv[1];
|
||||
if ((fd = open(elf_obj, O_RDWR)) == -1) {
|
||||
(void) fprintf(stderr, "%s: cannot open file.\n", elf_obj);
|
||||
exit(3);
|
||||
}
|
||||
|
||||
(void) printf("Opening '%s' for update\n", elf_obj);
|
||||
(void) fflush(stdout);
|
||||
(void) elf_version(EV_CURRENT); /* coordinate ELF versions */
|
||||
|
||||
/* obtain the ELF descriptors from the input file */
|
||||
if ((elf = elf_begin(fd, ELF_C_RDWR, NULL)) == NULL) {
|
||||
failure();
|
||||
}
|
||||
|
||||
/* determine if ELFCLASS64 or not? */
|
||||
elf_ident = elf_getident(elf, NULL);
|
||||
is_elfclass64 = (elf_ident[EI_CLASS] == ELFCLASS64);
|
||||
|
||||
/* get the ELF header */
|
||||
if (is_elfclass64) {
|
||||
ehdr = elf64_getehdr(elf);
|
||||
} else {
|
||||
ehdr = elf32_getehdr(elf);
|
||||
}
|
||||
if (ehdr == NULL) {
|
||||
failure();
|
||||
}
|
||||
|
||||
/* get the ELF section descriptor */
|
||||
if (is_elfclass64) {
|
||||
scn = elf_getscn(elf, ((Elf64_Ehdr *) ehdr)->e_shstrndx);
|
||||
} else {
|
||||
scn = elf_getscn(elf, ((Elf32_Ehdr *) ehdr)->e_shstrndx);
|
||||
}
|
||||
if (scn == NULL) {
|
||||
failure();
|
||||
}
|
||||
|
||||
/* get the section header string table */
|
||||
shstrtab = elf_getdata(scn, NULL);
|
||||
if (shstrtab == NULL) {
|
||||
failure();
|
||||
}
|
||||
|
||||
fix_count = 0;
|
||||
|
||||
/* traverse the sections of the input file */
|
||||
for (i = 1, scn = NULL; scn = elf_nextscn(elf, scn); i++) {
|
||||
int has_flag_set; /* is SHF_ALLOC flag set? */
|
||||
int is_empty; /* is section empty? */
|
||||
char * name; /* short hand pointer */
|
||||
|
||||
/* get the section header */
|
||||
if (is_elfclass64) {
|
||||
shdr = elf64_getshdr(scn);
|
||||
} else {
|
||||
shdr = elf32_getshdr(scn);
|
||||
}
|
||||
if (shdr == NULL) {
|
||||
failure();
|
||||
}
|
||||
|
||||
if (is_elfclass64) {
|
||||
name = (char *)shstrtab->d_buf + ((Elf64_Shdr *) shdr)->sh_name;
|
||||
} else {
|
||||
name = (char *)shstrtab->d_buf + ((Elf32_Shdr *) shdr)->sh_name;
|
||||
}
|
||||
|
||||
if (is_elfclass64) {
|
||||
has_flag_set = ((Elf64_Shdr *) shdr)->sh_flags & SHF_ALLOC;
|
||||
is_empty = ((Elf64_Shdr *) shdr)->sh_addr == 0 &&
|
||||
((Elf64_Shdr *) shdr)->sh_size == 0;
|
||||
} else {
|
||||
has_flag_set = ((Elf32_Shdr *) shdr)->sh_flags & SHF_ALLOC;
|
||||
is_empty = ((Elf32_Shdr *) shdr)->sh_addr == 0 &&
|
||||
((Elf32_Shdr *) shdr)->sh_size == 0;
|
||||
}
|
||||
|
||||
if (is_empty && has_flag_set) {
|
||||
(void) printf("section[%u] '%s' is empty, "
|
||||
"but SHF_ALLOC flag is set.\n", i, name);
|
||||
(void) printf("Clearing the SHF_ALLOC flag.\n");
|
||||
|
||||
if (is_elfclass64) {
|
||||
((Elf64_Shdr *) shdr)->sh_flags &= ~SHF_ALLOC;
|
||||
} else {
|
||||
((Elf32_Shdr *) shdr)->sh_flags &= ~SHF_ALLOC;
|
||||
}
|
||||
fix_count++;
|
||||
}
|
||||
} /* end for each ELF section */
|
||||
|
||||
if (fix_count > 0) {
|
||||
(void) printf("Saving %d updates to '%s'\n", fix_count, elf_obj);
|
||||
(void) fflush(stdout);
|
||||
(void) elf_update(elf, ELF_C_NULL); /* recalc ELF memory structures */
|
||||
(void) elf_update(elf, ELF_C_WRITE); /* write out changes to ELF obj */
|
||||
} else {
|
||||
(void) printf("No SHF_ALLOC flags needed to be cleared.\n");
|
||||
}
|
||||
|
||||
(void) elf_end(elf); /* done with ELF obj */
|
||||
(void) close(fd);
|
||||
|
||||
(void) printf("Done %s '%s'\n",
|
||||
(fix_count > 0) ? "updating" : "with", elf_obj);
|
||||
(void) fflush(stdout);
|
||||
exit(0);
|
||||
} /* end main */
|
||||
|
||||
|
||||
static void
|
||||
failure() {
|
||||
(void) fprintf(stderr, "%s\n", elf_errmsg(elf_errno()));
|
||||
exit(6);
|
||||
}
|
||||
@ -141,15 +141,19 @@ void os_getCmdlineAndUserInfo(JNIEnv *env, jobject jinfo, pid_t pid) {
|
||||
struct stat stat_buf;
|
||||
|
||||
/*
|
||||
* Try to open /proc/<pid>/cmdline
|
||||
* Stat /proc/<pid> to get the user id
|
||||
*/
|
||||
snprintf(fn, sizeof fn, "/proc/%d/cmdline", pid);
|
||||
if ((fd = open(fn, O_RDONLY)) < 0) {
|
||||
return;
|
||||
snprintf(fn, sizeof fn, "/proc/%d", pid);
|
||||
if (stat(fn, &stat_buf) == 0) {
|
||||
unix_getUserInfo(env, jinfo, stat_buf.st_uid);
|
||||
}
|
||||
|
||||
if (fstat(fd, &stat_buf) == 0) {
|
||||
unix_getUserInfo(env, jinfo, stat_buf.st_uid);
|
||||
/*
|
||||
* Try to open /proc/<pid>/cmdline
|
||||
*/
|
||||
strncat(fn, "/cmdline", sizeof fn - strnlen(fn, sizeof fn) - 1);
|
||||
if ((fd = open(fn, O_RDONLY)) < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
do { // Block to break out of on errors
|
||||
|
||||
@ -508,7 +508,7 @@ JNF_COCOA_ENTER(env);
|
||||
SecKeychainRef defaultKeychain = NULL;
|
||||
SecKeychainCopyDefault(&defaultKeychain);
|
||||
|
||||
SecExternalItemType dataType = (isCertificate == JNI_TRUE ? kSecFormatX509Cert : kSecFormatWrappedPKCS8);
|
||||
SecExternalFormat dataFormat = (isCertificate == JNI_TRUE ? kSecFormatX509Cert : kSecFormatWrappedPKCS8);
|
||||
|
||||
// Convert the password obj into a CFStringRef that the keychain importer can use for encryption.
|
||||
SecKeyImportExportParameters paramBlock;
|
||||
@ -533,7 +533,7 @@ JNF_COCOA_ENTER(env);
|
||||
paramBlock.keyUsage = CSSM_KEYUSE_ANY;
|
||||
paramBlock.keyAttributes = CSSM_KEYATTR_RETURN_DEFAULT;
|
||||
|
||||
err = SecKeychainItemImport(cfDataToImport, NULL, &dataType, NULL,
|
||||
err = SecKeychainItemImport(cfDataToImport, NULL, &dataFormat, NULL,
|
||||
0, ¶mBlock, defaultKeychain, &createdItems);
|
||||
|
||||
if (err == noErr) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -68,7 +68,6 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
||||
return null;
|
||||
}
|
||||
});
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -364,6 +363,5 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
||||
return connectDisabled;
|
||||
}
|
||||
|
||||
native int dataAvailable();
|
||||
private static native void init();
|
||||
abstract int dataAvailable();
|
||||
}
|
||||
|
||||
@ -233,8 +233,7 @@ public class DistributionPointFetcher {
|
||||
}
|
||||
CertStore ucs = null;
|
||||
try {
|
||||
ucs = URICertStore.getInstance
|
||||
(new URICertStore.URICertStoreParameters(uri));
|
||||
ucs = URICertStore.getInstance(new URICertStoreParameters(uri));
|
||||
} catch (InvalidAlgorithmParameterException |
|
||||
NoSuchAlgorithmException e) {
|
||||
if (debug != null) {
|
||||
|
||||
@ -44,9 +44,7 @@ import java.security.cert.CRLException;
|
||||
import java.security.cert.CRLSelector;
|
||||
import java.security.cert.URICertStoreParameters;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.security.cert.X509CertSelector;
|
||||
import java.security.cert.X509CRL;
|
||||
import java.security.cert.X509CRLSelector;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -160,12 +158,11 @@ class URICertStore extends CertStoreSpi {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("params must be instanceof URICertStoreParameters");
|
||||
}
|
||||
this.uri = ((URICertStoreParameters) params).uri;
|
||||
this.uri = ((URICertStoreParameters) params).getURI();
|
||||
// if ldap URI, use an LDAPCertStore to fetch certs and CRLs
|
||||
if (uri.getScheme().toLowerCase(Locale.ENGLISH).equals("ldap")) {
|
||||
ldap = true;
|
||||
URICertStoreParameters lparams = new URICertStoreParameters(uri);
|
||||
ldapCertStore = CertStore.getInstance("LDAP", lparams);
|
||||
ldapCertStore = CertStore.getInstance("LDAP", params);
|
||||
}
|
||||
try {
|
||||
factory = CertificateFactory.getInstance("X.509");
|
||||
@ -183,7 +180,7 @@ class URICertStore extends CertStoreSpi {
|
||||
static synchronized CertStore getInstance(URICertStoreParameters params)
|
||||
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
|
||||
if (debug != null) {
|
||||
debug.println("CertStore URI:" + params.uri);
|
||||
debug.println("CertStore URI:" + params.getURI());
|
||||
}
|
||||
CertStore ucs = certStoreCache.get(params);
|
||||
if (ucs == null) {
|
||||
@ -212,8 +209,7 @@ class URICertStore extends CertStoreSpi {
|
||||
}
|
||||
URI uri = ((URIName) gn).getURI();
|
||||
try {
|
||||
return URICertStore.getInstance
|
||||
(new URICertStore.URICertStoreParameters(uri));
|
||||
return URICertStore.getInstance(new URICertStoreParameters(uri));
|
||||
} catch (Exception ex) {
|
||||
if (debug != null) {
|
||||
debug.println("exception creating CertStore: " + ex);
|
||||
@ -420,40 +416,6 @@ class URICertStore extends CertStoreSpi {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CertStoreParameters for the URICertStore.
|
||||
*/
|
||||
static class URICertStoreParameters implements CertStoreParameters {
|
||||
private final URI uri;
|
||||
private volatile int hashCode = 0;
|
||||
URICertStoreParameters(URI uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
@Override public boolean equals(Object obj) {
|
||||
if (!(obj instanceof URICertStoreParameters)) {
|
||||
return false;
|
||||
}
|
||||
URICertStoreParameters params = (URICertStoreParameters) obj;
|
||||
return uri.equals(params.uri);
|
||||
}
|
||||
@Override public int hashCode() {
|
||||
if (hashCode == 0) {
|
||||
int result = 17;
|
||||
result = 37*result + uri.hashCode();
|
||||
hashCode = result;
|
||||
}
|
||||
return hashCode;
|
||||
}
|
||||
@Override public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
/* Cannot happen */
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class allows the URICertStore to be accessed as a CertStore.
|
||||
*/
|
||||
|
||||
@ -41,6 +41,7 @@ import java.util.Objects;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.stream.Stream;
|
||||
import sun.util.locale.provider.JRELocaleProviderAdapter;
|
||||
import sun.util.locale.provider.LocaleProviderAdapter;
|
||||
import sun.util.locale.provider.LocaleDataMetaInfo;
|
||||
@ -148,11 +149,9 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter {
|
||||
private List<Locale> applyParentLocales(String baseName, List<Locale> candidates) {
|
||||
if (Objects.isNull(parentLocalesMap)) {
|
||||
Map<Locale, Locale> map = new HashMap<>();
|
||||
Map<String, String> parentLocales = baseMetaInfo.parentLocales();
|
||||
parentLocales.keySet().forEach(parent -> {
|
||||
Arrays.asList(parentLocales.get(parent).split(" ")).stream().forEach(child -> {
|
||||
map.put(Locale.forLanguageTag(child),
|
||||
"root".equals(parent) ? Locale.ROOT : Locale.forLanguageTag(parent));
|
||||
baseMetaInfo.parentLocales().forEach((parent, children) -> {
|
||||
Stream.of(children).forEach(child -> {
|
||||
map.put(Locale.forLanguageTag(child), parent);
|
||||
});
|
||||
});
|
||||
parentLocalesMap = Collections.unmodifiableMap(map);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007,2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -130,6 +130,8 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
|
||||
|
||||
protected native void disconnect0(int family);
|
||||
|
||||
native int dataAvailable();
|
||||
|
||||
/**
|
||||
* Perform class load-time initializations.
|
||||
*/
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,3 +31,4 @@
|
||||
# and may not be available in a future release.
|
||||
#
|
||||
-server KNOWN
|
||||
-client IGNORE
|
||||
|
||||
@ -35,14 +35,20 @@
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#ifdef __solaris__
|
||||
#if defined(__solaris__)
|
||||
#include <libscf.h>
|
||||
#endif
|
||||
|
||||
#include "jvm.h"
|
||||
#include "TimeZone_md.h"
|
||||
|
||||
#define SKIP_SPACE(p) while (*p == ' ' || *p == '\t') p++;
|
||||
|
||||
#if defined(_ALLBSD_SOURCE)
|
||||
#define dirent64 dirent
|
||||
#define readdir64_r readdir_r
|
||||
#endif
|
||||
|
||||
#if !defined(__solaris__) || defined(__sparcv9) || defined(amd64)
|
||||
#define fileopen fopen
|
||||
#define filegets fgets
|
||||
@ -50,19 +56,20 @@
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(_ALLBSD_SOURCE)
|
||||
|
||||
|
||||
static const char *ETC_TIMEZONE_FILE = "/etc/timezone";
|
||||
static const char *ZONEINFO_DIR = "/usr/share/zoneinfo";
|
||||
static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime";
|
||||
#else
|
||||
#ifdef _AIX
|
||||
static const char *ETC_ENVIRONMENT_FILE = "/etc/environment";
|
||||
#endif
|
||||
static const char *SYS_INIT_FILE = "/etc/default/init";
|
||||
static const char *ZONEINFO_DIR = "/usr/share/lib/zoneinfo";
|
||||
static const char *DEFAULT_ZONEINFO_FILE = "/usr/share/lib/zoneinfo/localtime";
|
||||
#endif /*__linux__*/
|
||||
#endif /* defined(__linux__) || defined(_ALLBSD_SOURCE) */
|
||||
|
||||
#if defined(_AIX)
|
||||
static const char *ETC_ENVIRONMENT_FILE = "/etc/environment";
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(MACOSX) || defined(__solaris__)
|
||||
|
||||
/*
|
||||
* Returns a pointer to the zone ID portion of the given zoneinfo file
|
||||
@ -108,8 +115,8 @@ findZoneinfoFile(char *buf, size_t size, const char *dir)
|
||||
{
|
||||
DIR *dirp = NULL;
|
||||
struct stat statbuf;
|
||||
struct dirent *dp = NULL;
|
||||
struct dirent *entry = NULL;
|
||||
struct dirent64 *dp = NULL;
|
||||
struct dirent64 *entry = NULL;
|
||||
char *pathname = NULL;
|
||||
int fd = -1;
|
||||
char *dbuf = NULL;
|
||||
@ -120,19 +127,13 @@ findZoneinfoFile(char *buf, size_t size, const char *dir)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
entry = (struct dirent *) malloc((size_t) pathconf(dir, _PC_NAME_MAX));
|
||||
entry = (struct dirent64 *) malloc((size_t) pathconf(dir, _PC_NAME_MAX));
|
||||
if (entry == NULL) {
|
||||
(void) closedir(dirp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(_AIX) || defined(__linux__) || defined(MACOSX) || (defined(__solaris__) \
|
||||
&& (defined(_POSIX_PTHREAD_SEMANTICS) || defined(_LP64)))
|
||||
while (readdir_r(dirp, entry, &dp) == 0 && dp != NULL) {
|
||||
#else
|
||||
while ((dp = readdir_r(dirp, entry)) != NULL) {
|
||||
#endif
|
||||
|
||||
while (readdir64_r(dirp, entry, &dp) == 0 && dp != NULL) {
|
||||
/*
|
||||
* Skip '.' and '..' (and possibly other .* files)
|
||||
*/
|
||||
@ -145,7 +146,7 @@ findZoneinfoFile(char *buf, size_t size, const char *dir)
|
||||
*/
|
||||
if ((strcmp(dp->d_name, "ROC") == 0)
|
||||
|| (strcmp(dp->d_name, "posixrules") == 0)
|
||||
#ifdef __solaris__
|
||||
#if defined(__solaris__)
|
||||
/*
|
||||
* Skip the "src" and "tab" directories on Solaris.
|
||||
*/
|
||||
@ -230,7 +231,7 @@ getPlatformTimeZoneID()
|
||||
char *buf;
|
||||
size_t size;
|
||||
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__)
|
||||
/*
|
||||
* Try reading the /etc/timezone file for Debian distros. There's
|
||||
* no spec of the file format available. This parsing assumes that
|
||||
@ -254,7 +255,7 @@ getPlatformTimeZoneID()
|
||||
return tz;
|
||||
}
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
#endif /* defined(__linux__) */
|
||||
|
||||
/*
|
||||
* Next, try /etc/localtime to find the zone ID.
|
||||
@ -318,8 +319,9 @@ getPlatformTimeZoneID()
|
||||
free((void *) buf);
|
||||
return tz;
|
||||
}
|
||||
#else
|
||||
#ifdef __solaris__
|
||||
|
||||
#elif defined(__solaris__)
|
||||
|
||||
#if !defined(__sparcv9) && !defined(amd64)
|
||||
|
||||
/*
|
||||
@ -444,8 +446,7 @@ filegets(char *s, int n, FILE *stream)
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
#endif /* not __sparcv9 */
|
||||
|
||||
#endif /* !defined(__sparcv9) && !defined(amd64) */
|
||||
|
||||
/*
|
||||
* Performs Solaris dependent mapping. Returns a zone ID if
|
||||
@ -546,7 +547,7 @@ cleanupScf(scf_handle_t *h,
|
||||
}
|
||||
|
||||
/*
|
||||
* Retruns a zone ID of Solaris when the TZ value is "localtime".
|
||||
* Returns a zone ID of Solaris when the TZ value is "localtime".
|
||||
* First, it tries scf. If scf fails, it looks for the same file as
|
||||
* /usr/share/lib/zoneinfo/localtime under /usr/share/lib/zoneinfo/.
|
||||
*/
|
||||
@ -615,10 +616,11 @@ getSolarisDefaultZoneID() {
|
||||
free((void *) buf);
|
||||
return tz;
|
||||
}
|
||||
#endif /*__solaris__*/
|
||||
#endif /*__linux__*/
|
||||
|
||||
#ifdef _AIX
|
||||
#endif /* defined(__solaris__) */
|
||||
|
||||
#elif defined(_AIX)
|
||||
|
||||
static char *
|
||||
getPlatformTimeZoneID()
|
||||
{
|
||||
@ -644,178 +646,33 @@ getPlatformTimeZoneID()
|
||||
|
||||
return tz;
|
||||
}
|
||||
static char *mapPlatformToJavaTimezone(const char *java_home_dir, const char *tz);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* findJavaTZ_md() maps platform time zone ID to Java time zone ID
|
||||
* using <java_home>/lib/tzmappings. If the TZ value is not found, it
|
||||
* trys some libc implementation dependent mappings. If it still
|
||||
* can't map to a Java time zone ID, it falls back to the GMT+/-hh:mm
|
||||
* form.
|
||||
*/
|
||||
/*ARGSUSED1*/
|
||||
char *
|
||||
findJavaTZ_md(const char *java_home_dir)
|
||||
{
|
||||
char *tz;
|
||||
char *javatz = NULL;
|
||||
char *freetz = NULL;
|
||||
|
||||
tz = getenv("TZ");
|
||||
|
||||
#if defined(__linux__) || defined(_ALLBSD_SOURCE)
|
||||
if (tz == NULL) {
|
||||
#else
|
||||
#if defined (__solaris__) || defined(_AIX)
|
||||
if (tz == NULL || *tz == '\0') {
|
||||
#endif
|
||||
#endif
|
||||
tz = getPlatformTimeZoneID();
|
||||
freetz = tz;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove any preceding ':'
|
||||
*/
|
||||
if (tz != NULL && *tz == ':') {
|
||||
tz++;
|
||||
}
|
||||
|
||||
#ifdef __solaris__
|
||||
if (tz != NULL && strcmp(tz, "localtime") == 0) {
|
||||
tz = getSolarisDefaultZoneID();
|
||||
if (freetz != NULL) {
|
||||
free((void *) freetz);
|
||||
}
|
||||
freetz = tz;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (tz != NULL) {
|
||||
#ifdef __linux__
|
||||
/*
|
||||
* Ignore "posix/" prefix.
|
||||
*/
|
||||
if (strncmp(tz, "posix/", 6) == 0) {
|
||||
tz += 6;
|
||||
}
|
||||
#endif
|
||||
javatz = strdup(tz);
|
||||
if (freetz != NULL) {
|
||||
free((void *) freetz);
|
||||
}
|
||||
|
||||
#ifdef _AIX
|
||||
freetz = mapPlatformToJavaTimezone(java_home_dir, javatz);
|
||||
if (javatz != NULL) {
|
||||
free((void *) javatz);
|
||||
}
|
||||
javatz = freetz;
|
||||
#endif
|
||||
}
|
||||
|
||||
return javatz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a GMT-offset-based zone ID. (e.g., "GMT-08:00")
|
||||
*/
|
||||
|
||||
#ifdef MACOSX
|
||||
|
||||
char *
|
||||
getGMTOffsetID()
|
||||
{
|
||||
time_t offset;
|
||||
char sign, buf[32];
|
||||
struct tm *local_tm;
|
||||
time_t clock;
|
||||
time_t currenttime;
|
||||
|
||||
clock = time(NULL);
|
||||
tzset();
|
||||
local_tm = localtime(&clock);
|
||||
if (local_tm->tm_gmtoff >= 0) {
|
||||
offset = (time_t) local_tm->tm_gmtoff;
|
||||
sign = '+';
|
||||
} else {
|
||||
offset = (time_t) -local_tm->tm_gmtoff;
|
||||
sign = '-';
|
||||
}
|
||||
sprintf(buf, (const char *)"GMT%c%02d:%02d",
|
||||
sign, (int)(offset/3600), (int)((offset%3600)/60));
|
||||
return strdup(buf);
|
||||
}
|
||||
#else
|
||||
|
||||
char *
|
||||
getGMTOffsetID()
|
||||
{
|
||||
time_t offset;
|
||||
char sign, buf[32];
|
||||
#ifdef __solaris__
|
||||
struct tm localtm;
|
||||
time_t currenttime;
|
||||
|
||||
currenttime = time(NULL);
|
||||
if (localtime_r(¤ttime, &localtm) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
offset = localtm.tm_isdst ? altzone : timezone;
|
||||
#else
|
||||
offset = timezone;
|
||||
#endif /*__linux__*/
|
||||
|
||||
if (offset == 0) {
|
||||
return strdup("GMT");
|
||||
}
|
||||
|
||||
/* Note that the time offset direction is opposite. */
|
||||
if (offset > 0) {
|
||||
sign = '-';
|
||||
} else {
|
||||
offset = -offset;
|
||||
sign = '+';
|
||||
}
|
||||
sprintf(buf, (const char *)"GMT%c%02d:%02d",
|
||||
sign, (int)(offset/3600), (int)((offset%3600)/60));
|
||||
return strdup(buf);
|
||||
}
|
||||
#endif /* MACOSX */
|
||||
|
||||
#ifdef _AIX
|
||||
static char *
|
||||
mapPlatformToJavaTimezone(const char *java_home_dir, const char *tz) {
|
||||
FILE *tzmapf;
|
||||
char mapfilename[PATH_MAX+1];
|
||||
char mapfilename[PATH_MAX + 1];
|
||||
char line[256];
|
||||
int linecount = 0;
|
||||
char temp[100], *temp_tz;
|
||||
char *tz_buf = NULL;
|
||||
char *temp_tz = NULL;
|
||||
char *javatz = NULL;
|
||||
char *str_tmp = NULL;
|
||||
size_t temp_tz_len = 0;
|
||||
size_t tz_len = 0;
|
||||
|
||||
/* On AIX, the TZ environment variable may end with a comma
|
||||
* followed by modifier fields. These are ignored here.
|
||||
*/
|
||||
strncpy(temp, tz, 100);
|
||||
temp_tz = strtok_r(temp, ",", &str_tmp);
|
||||
* followed by modifier fields. These are ignored here. */
|
||||
temp_tz = strchr(tz, ',');
|
||||
tz_len = (temp_tz == NULL) ? strlen(tz) : temp_tz - tz;
|
||||
tz_buf = (char *)malloc(tz_len + 1);
|
||||
memcpy(tz_buf, tz, tz_len);
|
||||
tz_buf[tz_len] = 0;
|
||||
|
||||
if(temp_tz == NULL)
|
||||
goto tzerr;
|
||||
|
||||
temp_tz_len = strlen(temp_tz);
|
||||
|
||||
if (strlen(java_home_dir) >= (PATH_MAX - 15)) {
|
||||
jio_fprintf(stderr, "java.home longer than maximum path length \n");
|
||||
/* Open tzmappings file, with buffer overrun check */
|
||||
if ((strlen(java_home_dir) + 15) > PATH_MAX) {
|
||||
jio_fprintf(stderr, "Path %s/lib/tzmappings exceeds maximum path length\n", java_home_dir);
|
||||
goto tzerr;
|
||||
}
|
||||
|
||||
strncpy(mapfilename, java_home_dir, PATH_MAX);
|
||||
strcpy(mapfilename, java_home_dir);
|
||||
strcat(mapfilename, "/lib/tzmappings");
|
||||
|
||||
if ((tzmapf = fopen(mapfilename, "r")) == NULL) {
|
||||
jio_fprintf(stderr, "can't open %s\n", mapfilename);
|
||||
goto tzerr;
|
||||
@ -848,7 +705,7 @@ mapPlatformToJavaTimezone(const char *java_home_dir, const char *tz) {
|
||||
}
|
||||
|
||||
*p++ = '\0';
|
||||
if ((result = strncmp(temp_tz, sol, temp_tz_len)) == 0) {
|
||||
if ((result = strncmp(tz_buf, sol, tz_len)) == 0) {
|
||||
/*
|
||||
* If this is the current platform zone ID,
|
||||
* take the Java time zone ID (2nd field).
|
||||
@ -874,11 +731,150 @@ mapPlatformToJavaTimezone(const char *java_home_dir, const char *tz) {
|
||||
(void) fclose(tzmapf);
|
||||
|
||||
tzerr:
|
||||
if (tz_buf != NULL ) {
|
||||
free((void *) tz_buf);
|
||||
}
|
||||
|
||||
if (javatz == NULL) {
|
||||
return getGMTOffsetID();
|
||||
}
|
||||
|
||||
return javatz;
|
||||
}
|
||||
|
||||
#endif /* defined(_AIX) */
|
||||
|
||||
/*
|
||||
* findJavaTZ_md() maps platform time zone ID to Java time zone ID
|
||||
* using <java_home>/lib/tzmappings. If the TZ value is not found, it
|
||||
* trys some libc implementation dependent mappings. If it still
|
||||
* can't map to a Java time zone ID, it falls back to the GMT+/-hh:mm
|
||||
* form.
|
||||
*/
|
||||
/*ARGSUSED1*/
|
||||
char *
|
||||
findJavaTZ_md(const char *java_home_dir)
|
||||
{
|
||||
char *tz;
|
||||
char *javatz = NULL;
|
||||
char *freetz = NULL;
|
||||
|
||||
tz = getenv("TZ");
|
||||
|
||||
if (tz == NULL || *tz == '\0') {
|
||||
tz = getPlatformTimeZoneID();
|
||||
freetz = tz;
|
||||
}
|
||||
|
||||
if (tz != NULL) {
|
||||
/* Ignore preceding ':' */
|
||||
if (*tz == ':') {
|
||||
tz++;
|
||||
}
|
||||
#if defined(__linux__)
|
||||
/* Ignore "posix/" prefix on Linux. */
|
||||
if (strncmp(tz, "posix/", 6) == 0) {
|
||||
tz += 6;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_AIX)
|
||||
/* On AIX do the platform to Java mapping. */
|
||||
javatz = mapPlatformToJavaTimezone(java_home_dir, tz);
|
||||
if (freetz != NULL) {
|
||||
free((void *) freetz);
|
||||
}
|
||||
#else
|
||||
#if defined(__solaris__)
|
||||
/* Solaris might use localtime, so handle it here. */
|
||||
if (strcmp(tz, "localtime") == 0) {
|
||||
javatz = getSolarisDefaultZoneID();
|
||||
if (freetz != NULL) {
|
||||
free((void *) freetz);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (freetz == NULL) {
|
||||
/* strdup if we are still working on getenv result. */
|
||||
javatz = strdup(tz);
|
||||
} else if (freetz != tz) {
|
||||
/* strdup and free the old buffer, if we moved the pointer. */
|
||||
javatz = strdup(tz);
|
||||
free((void *) freetz);
|
||||
} else {
|
||||
/* we are good if we already work on a freshly allocated buffer. */
|
||||
javatz = tz;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return javatz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a GMT-offset-based zone ID. (e.g., "GMT-08:00")
|
||||
*/
|
||||
|
||||
#if defined(MACOSX)
|
||||
|
||||
char *
|
||||
getGMTOffsetID()
|
||||
{
|
||||
time_t offset;
|
||||
char sign, buf[32];
|
||||
struct tm *local_tm;
|
||||
time_t clock;
|
||||
time_t currenttime;
|
||||
|
||||
clock = time(NULL);
|
||||
tzset();
|
||||
local_tm = localtime(&clock);
|
||||
if (local_tm->tm_gmtoff >= 0) {
|
||||
offset = (time_t) local_tm->tm_gmtoff;
|
||||
sign = '+';
|
||||
} else {
|
||||
offset = (time_t) -local_tm->tm_gmtoff;
|
||||
sign = '-';
|
||||
}
|
||||
sprintf(buf, (const char *)"GMT%c%02d:%02d",
|
||||
sign, (int)(offset/3600), (int)((offset%3600)/60));
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
char *
|
||||
getGMTOffsetID()
|
||||
{
|
||||
time_t offset;
|
||||
char sign, buf[32];
|
||||
#if defined(__solaris__)
|
||||
struct tm localtm;
|
||||
time_t currenttime;
|
||||
|
||||
currenttime = time(NULL);
|
||||
if (localtime_r(¤ttime, &localtm) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
offset = localtm.tm_isdst ? altzone : timezone;
|
||||
#else
|
||||
offset = timezone;
|
||||
#endif
|
||||
|
||||
if (offset == 0) {
|
||||
return strdup("GMT");
|
||||
}
|
||||
|
||||
/* Note that the time offset direction is opposite. */
|
||||
if (offset > 0) {
|
||||
sign = '-';
|
||||
} else {
|
||||
offset = -offset;
|
||||
sign = '+';
|
||||
}
|
||||
sprintf(buf, (const char *)"GMT%c%02d:%02d",
|
||||
sign, (int)(offset/3600), (int)((offset%3600)/60));
|
||||
return strdup(buf);
|
||||
}
|
||||
#endif /* MACOSX */
|
||||
|
||||
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#ifdef __solaris__
|
||||
#include <unistd.h>
|
||||
#include <stropts.h>
|
||||
|
||||
#ifndef BSD_COMP
|
||||
#define BSD_COMP
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "jvm.h"
|
||||
#include "jni_util.h"
|
||||
#include "net_util.h"
|
||||
|
||||
#include "java_net_AbstractPlainDatagramSocketImpl.h"
|
||||
|
||||
static jfieldID IO_fd_fdID;
|
||||
|
||||
static jfieldID apdsi_fdID;
|
||||
|
||||
|
||||
/*
|
||||
* Class: java_net_AbstractPlainDatagramSocketImpl
|
||||
* Method: init
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_net_AbstractPlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) {
|
||||
|
||||
apdsi_fdID = (*env)->GetFieldID(env, cls, "fd",
|
||||
"Ljava/io/FileDescriptor;");
|
||||
CHECK_NULL(apdsi_fdID);
|
||||
|
||||
IO_fd_fdID = NET_GetFileDescriptorID(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_AbstractPlainDatagramSocketImpl
|
||||
* Method: dataAvailable
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_java_net_AbstractPlainDatagramSocketImpl_dataAvailable
|
||||
(JNIEnv *env, jobject this) {
|
||||
int fd, retval;
|
||||
|
||||
jobject fdObj = (*env)->GetObjectField(env, this, apdsi_fdID);
|
||||
|
||||
if (IS_NULL(fdObj)) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
|
||||
"Socket closed");
|
||||
return -1;
|
||||
}
|
||||
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
|
||||
|
||||
if (ioctl(fd, FIONREAD, &retval) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,6 +32,12 @@
|
||||
|
||||
#ifdef __solaris__
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stropts.h>
|
||||
|
||||
#ifndef BSD_COMP
|
||||
#define BSD_COMP
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
#include <unistd.h>
|
||||
@ -52,6 +58,8 @@
|
||||
#endif
|
||||
#endif // __linux__
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#ifndef IPTOS_TOS_MASK
|
||||
#define IPTOS_TOS_MASK 0x1e
|
||||
#endif
|
||||
@ -2240,3 +2248,28 @@ Java_java_net_PlainDatagramSocketImpl_leave(JNIEnv *env, jobject this,
|
||||
{
|
||||
mcast_join_leave(env, this, iaObj, niObj, JNI_FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_PlainDatagramSocketImpl
|
||||
* Method: dataAvailable
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_java_net_PlainDatagramSocketImpl_dataAvailable(JNIEnv *env, jobject this)
|
||||
{
|
||||
int fd, retval;
|
||||
|
||||
jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
|
||||
|
||||
if (IS_NULL(fdObj)) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
|
||||
"Socket closed");
|
||||
return -1;
|
||||
}
|
||||
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
|
||||
|
||||
if (ioctl(fd, FIONREAD, &retval) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -118,6 +118,8 @@ Java_sun_net_sdp_SdpSupport_convert0(JNIEnv *env, jclass cls, int fd)
|
||||
RESTARTABLE(dup2(s, fd), res);
|
||||
if (res < 0)
|
||||
JNU_ThrowIOExceptionWithLastError(env, "dup2");
|
||||
RESTARTABLE(close(s), res);
|
||||
res = close(s);
|
||||
if (res < 0 && !(*env)->ExceptionOccurred(env))
|
||||
JNU_ThrowIOExceptionWithLastError(env, "close");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -45,7 +45,7 @@ import java.security.PrivilegedAction;
|
||||
|
||||
class DefaultDatagramSocketImplFactory
|
||||
{
|
||||
static Class<?> prefixImplClass = null;
|
||||
private final static Class<?> prefixImplClass;
|
||||
|
||||
/* the windows version. */
|
||||
private static float version;
|
||||
@ -54,16 +54,19 @@ class DefaultDatagramSocketImplFactory
|
||||
private static boolean preferIPv4Stack = false;
|
||||
|
||||
/* If the version supports a dual stack TCP implementation */
|
||||
private static boolean useDualStackImpl = false;
|
||||
private final static boolean useDualStackImpl;
|
||||
|
||||
/* sun.net.useExclusiveBind */
|
||||
private static String exclBindProp;
|
||||
|
||||
/* True if exclusive binding is on for Windows */
|
||||
private static boolean exclusiveBind = true;
|
||||
|
||||
private final static boolean exclusiveBind;
|
||||
|
||||
static {
|
||||
Class<?> prefixImplClassLocal = null;
|
||||
boolean useDualStackImplLocal = false;
|
||||
boolean exclusiveBindLocal = true;
|
||||
|
||||
// Determine Windows Version.
|
||||
java.security.AccessController.doPrivileged(
|
||||
new PrivilegedAction<Object>() {
|
||||
@ -78,7 +81,7 @@ class DefaultDatagramSocketImplFactory
|
||||
"java.net.preferIPv4Stack"));
|
||||
exclBindProp = System.getProperty(
|
||||
"sun.net.useExclusiveBind");
|
||||
} catch (NumberFormatException e ) {
|
||||
} catch (NumberFormatException e) {
|
||||
assert false : e;
|
||||
}
|
||||
return null; // nothing to return
|
||||
@ -87,14 +90,14 @@ class DefaultDatagramSocketImplFactory
|
||||
|
||||
// (version >= 6.0) implies Vista or greater.
|
||||
if (version >= 6.0 && !preferIPv4Stack) {
|
||||
useDualStackImpl = true;
|
||||
useDualStackImplLocal = true;
|
||||
}
|
||||
if (exclBindProp != null) {
|
||||
// sun.net.useExclusiveBind is true
|
||||
exclusiveBind = exclBindProp.length() == 0 ? true
|
||||
exclusiveBindLocal = exclBindProp.length() == 0 ? true
|
||||
: Boolean.parseBoolean(exclBindProp);
|
||||
} else if (version < 6.0) {
|
||||
exclusiveBind = false;
|
||||
exclusiveBindLocal = false;
|
||||
}
|
||||
|
||||
// impl.prefix
|
||||
@ -103,12 +106,16 @@ class DefaultDatagramSocketImplFactory
|
||||
prefix = AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction("impl.prefix", null));
|
||||
if (prefix != null)
|
||||
prefixImplClass = Class.forName("java.net."+prefix+"DatagramSocketImpl");
|
||||
prefixImplClassLocal = Class.forName("java.net."+prefix+"DatagramSocketImpl");
|
||||
} catch (Exception e) {
|
||||
System.err.println("Can't find class: java.net." +
|
||||
prefix +
|
||||
"DatagramSocketImpl: check impl.prefix property");
|
||||
}
|
||||
|
||||
prefixImplClass = prefixImplClassLocal;
|
||||
useDualStackImpl = useDualStackImplLocal;
|
||||
exclusiveBind = exclusiveBindLocal;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,12 +133,10 @@ class DefaultDatagramSocketImplFactory
|
||||
throw new SocketException("can't instantiate DatagramSocketImpl");
|
||||
}
|
||||
} else {
|
||||
if (isMulticast)
|
||||
exclusiveBind = false;
|
||||
if (useDualStackImpl && !isMulticast)
|
||||
return new DualStackPlainDatagramSocketImpl(exclusiveBind);
|
||||
else
|
||||
return new TwoStacksPlainDatagramSocketImpl(exclusiveBind);
|
||||
return new TwoStacksPlainDatagramSocketImpl(exclusiveBind && !isMulticast);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -292,4 +292,6 @@ class DualStackPlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
|
||||
int optionValue) throws SocketException;
|
||||
|
||||
private static native int socketGetIntOption(int fd, int cmd) throws SocketException;
|
||||
|
||||
native int dataAvailable();
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -207,6 +207,8 @@ class TwoStacksPlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
|
||||
|
||||
protected native void disconnect0(int family);
|
||||
|
||||
native int dataAvailable();
|
||||
|
||||
/**
|
||||
* Perform class load-time initializations.
|
||||
*/
|
||||
|
||||
@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
#include "jvm.h"
|
||||
#include "jni_util.h"
|
||||
#include "net_util.h"
|
||||
|
||||
#include "java_net_AbstractPlainDatagramSocketImpl.h"
|
||||
|
||||
static jfieldID IO_fd_fdID = NULL;
|
||||
static jfieldID apdsi_fdID = NULL;
|
||||
|
||||
static jfieldID apdsi_fd1ID = NULL;
|
||||
static jclass two_stacks_clazz = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Class: java_net_AbstractPlainDatagramSocketImpl
|
||||
* Method: init
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_net_AbstractPlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) {
|
||||
|
||||
apdsi_fdID = (*env)->GetFieldID(env, cls, "fd",
|
||||
"Ljava/io/FileDescriptor;");
|
||||
CHECK_NULL(apdsi_fdID);
|
||||
IO_fd_fdID = NET_GetFileDescriptorID(env);
|
||||
CHECK_NULL(IO_fd_fdID);
|
||||
|
||||
two_stacks_clazz = (*env)->FindClass(env, "java/net/TwoStacksPlainDatagramSocketImpl");
|
||||
CHECK_NULL(two_stacks_clazz);
|
||||
|
||||
/* Handle both TwoStacks and DualStack here */
|
||||
|
||||
if (JNU_Equals(env, cls, two_stacks_clazz)) {
|
||||
/* fd1 present only in TwoStack.. */
|
||||
apdsi_fd1ID = (*env)->GetFieldID(env, cls, "fd1",
|
||||
"Ljava/io/FileDescriptor;");
|
||||
CHECK_NULL(apdsi_fd1ID);
|
||||
}
|
||||
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_AbstractPlainDatagramSocketImpl
|
||||
* Method: dataAvailable
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_java_net_AbstractPlainDatagramSocketImpl_dataAvailable
|
||||
(JNIEnv *env, jobject this) {
|
||||
SOCKET fd;
|
||||
SOCKET fd1;
|
||||
int rv = -1, rv1 = -1;
|
||||
jobject fdObj = (*env)->GetObjectField(env, this, apdsi_fdID);
|
||||
|
||||
if (!IS_NULL(fdObj)) {
|
||||
int retval = 0;
|
||||
fd = (SOCKET)(*env)->GetIntField(env, fdObj, IO_fd_fdID);
|
||||
rv = ioctlsocket(fd, FIONREAD, &retval);
|
||||
if (retval > 0) {
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
if (!IS_NULL(apdsi_fd1ID)) {
|
||||
/* TwoStacks */
|
||||
jobject fd1Obj = (*env)->GetObjectField(env, this, apdsi_fd1ID);
|
||||
if (!IS_NULL(fd1Obj)) {
|
||||
int retval = 0;
|
||||
fd1 = (SOCKET)(*env)->GetIntField(env, fd1Obj, IO_fd_fdID);
|
||||
rv1 = ioctlsocket(fd1, FIONREAD, &retval);
|
||||
if (retval > 0) {
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rv < 0 && rv1 < 0) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
|
||||
"Socket closed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -70,6 +70,9 @@ static jboolean purgeOutstandingICMP(JNIEnv *env, jint fd)
|
||||
return got_icmp;
|
||||
}
|
||||
|
||||
static jfieldID IO_fd_fdID = NULL;
|
||||
static jfieldID pdsi_fdID = NULL;
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainDatagramSocketImpl
|
||||
* Method: initIDs
|
||||
@ -78,6 +81,13 @@ static jboolean purgeOutstandingICMP(JNIEnv *env, jint fd)
|
||||
JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_initIDs
|
||||
(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
pdsi_fdID = (*env)->GetFieldID(env, clazz, "fd",
|
||||
"Ljava/io/FileDescriptor;");
|
||||
CHECK_NULL(pdsi_fdID);
|
||||
IO_fd_fdID = NET_GetFileDescriptorID(env);
|
||||
CHECK_NULL(IO_fd_fdID);
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
|
||||
initInetAddressIDs(env);
|
||||
}
|
||||
|
||||
@ -503,3 +513,32 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketGetI
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainDatagramSocketImpl
|
||||
* Method: dataAvailable
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_dataAvailable
|
||||
(JNIEnv *env, jobject this) {
|
||||
SOCKET fd;
|
||||
int rv = -1;
|
||||
jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
|
||||
|
||||
if (!IS_NULL(fdObj)) {
|
||||
int retval = 0;
|
||||
fd = (SOCKET)(*env)->GetIntField(env, fdObj, IO_fd_fdID);
|
||||
rv = ioctlsocket(fd, FIONREAD, &retval);
|
||||
if (retval > 0) {
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
if (rv < 0) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
|
||||
"Socket closed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -2563,3 +2563,44 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_leave(JNIEnv *env, jobject this,
|
||||
{
|
||||
mcast_join_leave (env, this, iaObj, niObj, JNI_FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_TwoStacksPlainDatagramSocketImpl
|
||||
* Method: dataAvailable
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_java_net_TwoStacksPlainDatagramSocketImpl_dataAvailable
|
||||
(JNIEnv *env, jobject this) {
|
||||
SOCKET fd;
|
||||
SOCKET fd1;
|
||||
int rv = -1, rv1 = -1;
|
||||
jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
|
||||
jobject fd1Obj;
|
||||
|
||||
if (!IS_NULL(fdObj)) {
|
||||
int retval = 0;
|
||||
fd = (SOCKET)(*env)->GetIntField(env, fdObj, IO_fd_fdID);
|
||||
rv = ioctlsocket(fd, FIONREAD, &retval);
|
||||
if (retval > 0) {
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID);
|
||||
if (!IS_NULL(fd1Obj)) {
|
||||
int retval = 0;
|
||||
fd1 = (SOCKET)(*env)->GetIntField(env, fd1Obj, IO_fd_fdID);
|
||||
rv1 = ioctlsocket(fd1, FIONREAD, &retval);
|
||||
if (retval > 0) {
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
if (rv < 0 && rv1 < 0) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
|
||||
"Socket closed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -76,7 +76,6 @@ class HotspotCompilation
|
||||
private LongCounter lastInvalidatedType;
|
||||
|
||||
private class CompilerThreadInfo {
|
||||
int index;
|
||||
String name;
|
||||
StringCounter method;
|
||||
LongCounter type;
|
||||
@ -90,14 +89,6 @@ class HotspotCompilation
|
||||
this.compiles = (LongCounter) lookup(basename + "compiles");
|
||||
this.time = (LongCounter) lookup(basename + "time");
|
||||
}
|
||||
CompilerThreadInfo(String bname) {
|
||||
String basename = bname + ".";
|
||||
this.name = bname;
|
||||
this.method = (StringCounter) lookup(basename + "method");
|
||||
this.type = (LongCounter) lookup(basename + "type");
|
||||
this.compiles = (LongCounter) lookup(basename + "compiles");
|
||||
this.time = (LongCounter) lookup(basename + "time");
|
||||
}
|
||||
|
||||
CompilerThreadStat getCompilerThreadStat() {
|
||||
MethodInfo minfo = new MethodInfo(method.stringValue(),
|
||||
@ -109,7 +100,7 @@ class HotspotCompilation
|
||||
minfo);
|
||||
}
|
||||
}
|
||||
private CompilerThreadInfo[] threads;
|
||||
private List<CompilerThreadInfo> threads;
|
||||
private int numActiveThreads; // number of active compiler threads
|
||||
|
||||
private Map<String, Counter> counters;
|
||||
@ -158,18 +149,12 @@ class HotspotCompilation
|
||||
numActiveThreads = (int) compilerThreads.longValue();
|
||||
|
||||
// Allocate CompilerThreadInfo for compilerThread and adaptorThread
|
||||
threads = new CompilerThreadInfo[numActiveThreads+1];
|
||||
threads = new ArrayList<CompilerThreadInfo>();
|
||||
|
||||
// AdaptorThread has index 0
|
||||
if (counters.containsKey(SUN_CI + "adapterThread.compiles")) {
|
||||
threads[0] = new CompilerThreadInfo("adapterThread", 0);
|
||||
numActiveThreads++;
|
||||
} else {
|
||||
threads[0] = null;
|
||||
}
|
||||
|
||||
for (int i = 1; i < threads.length; i++) {
|
||||
threads[i] = new CompilerThreadInfo("compilerThread", i-1);
|
||||
for (int i = 0; i < numActiveThreads; i++) {
|
||||
if (counters.containsKey(SUN_CI + "compilerThread." + i + ".method")) {
|
||||
threads.add(new CompilerThreadInfo("compilerThread", i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,15 +182,10 @@ class HotspotCompilation
|
||||
return nmethodSize.longValue();
|
||||
}
|
||||
|
||||
public java.util.List<CompilerThreadStat> getCompilerThreadStats() {
|
||||
List<CompilerThreadStat> list = new ArrayList<>(threads.length);
|
||||
int i = 0;
|
||||
if (threads[0] == null) {
|
||||
// no adaptor thread
|
||||
i = 1;
|
||||
}
|
||||
for (; i < threads.length; i++) {
|
||||
list.add(threads[i].getCompilerThreadStat());
|
||||
public List<CompilerThreadStat> getCompilerThreadStats() {
|
||||
List<CompilerThreadStat> list = new ArrayList<>(threads.size());
|
||||
for (CompilerThreadInfo info : threads) {
|
||||
list.add(info.getCompilerThreadStat());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -25,18 +25,12 @@
|
||||
|
||||
package sun.security.provider.certpath.ldap;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.net.URI;
|
||||
import java.util.*;
|
||||
|
||||
import java.security.*;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.*;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
import java.util.*;
|
||||
import sun.security.util.Cache;
|
||||
import sun.security.util.Debug;
|
||||
import sun.security.x509.X500Name;
|
||||
|
||||
/**
|
||||
* A <code>CertStore</code> that retrieves <code>Certificates</code> and
|
||||
@ -93,8 +87,6 @@ public final class LDAPCertStore extends CertStoreSpi {
|
||||
|
||||
private static final Debug debug = Debug.getInstance("certpath");
|
||||
|
||||
private final static boolean DEBUG = false;
|
||||
|
||||
private String ldapDN;
|
||||
|
||||
private LDAPCertStoreImpl impl;
|
||||
@ -108,7 +100,7 @@ public final class LDAPCertStore extends CertStoreSpi {
|
||||
String dn = null;
|
||||
if (params == null) {
|
||||
throw new InvalidAlgorithmParameterException(
|
||||
"parameters required for LDAP Certore");
|
||||
"Parameters required for LDAP certstore");
|
||||
}
|
||||
if (params instanceof LDAPCertStoreParameters) {
|
||||
LDAPCertStoreParameters p = (LDAPCertStoreParameters) params;
|
||||
@ -119,7 +111,9 @@ public final class LDAPCertStore extends CertStoreSpi {
|
||||
URI u = p.getURI();
|
||||
if (!u.getScheme().equalsIgnoreCase("ldap")) {
|
||||
throw new InvalidAlgorithmParameterException(
|
||||
"Only LDAP URIs are supported for LDAP Certore");
|
||||
"Unsupported scheme '" + u.getScheme()
|
||||
+ "', only LDAP URIs are supported "
|
||||
+ "for LDAP certstore");
|
||||
}
|
||||
// Use the same default values as in LDAPCertStoreParameters
|
||||
// if unspecified in URI
|
||||
@ -137,8 +131,9 @@ public final class LDAPCertStore extends CertStoreSpi {
|
||||
}
|
||||
} else {
|
||||
throw new InvalidAlgorithmParameterException(
|
||||
"parameters must be either LDAPCertStoreParameters or " +
|
||||
"URICertStoreParameters");
|
||||
"Parameters must be either LDAPCertStoreParameters or "
|
||||
+ "URICertStoreParameters, but instance of "
|
||||
+ params.getClass().getName() + " passed");
|
||||
}
|
||||
|
||||
Key k = new Key(serverName, port);
|
||||
@ -236,6 +231,7 @@ public final class LDAPCertStore extends CertStoreSpi {
|
||||
* match the specified selector
|
||||
* @throws CertStoreException if an exception occurs
|
||||
*/
|
||||
@Override
|
||||
public synchronized Collection<X509Certificate> engineGetCertificates
|
||||
(CertSelector selector) throws CertStoreException {
|
||||
if (debug != null) {
|
||||
@ -245,7 +241,9 @@ public final class LDAPCertStore extends CertStoreSpi {
|
||||
if (selector == null) {
|
||||
selector = new X509CertSelector();
|
||||
} else if (!(selector instanceof X509CertSelector)) {
|
||||
throw new CertStoreException("need X509CertSelector to find certs");
|
||||
throw new CertStoreException("Need X509CertSelector to find certs, "
|
||||
+ "but instance of " + selector.getClass().getName()
|
||||
+ " passed");
|
||||
}
|
||||
return impl.getCertificates((X509CertSelector) selector, ldapDN);
|
||||
}
|
||||
@ -271,6 +269,7 @@ public final class LDAPCertStore extends CertStoreSpi {
|
||||
* match the specified selector
|
||||
* @throws CertStoreException if an exception occurs
|
||||
*/
|
||||
@Override
|
||||
public synchronized Collection<X509CRL> engineGetCRLs(CRLSelector selector)
|
||||
throws CertStoreException {
|
||||
if (debug != null) {
|
||||
@ -281,7 +280,9 @@ public final class LDAPCertStore extends CertStoreSpi {
|
||||
if (selector == null) {
|
||||
selector = new X509CRLSelector();
|
||||
} else if (!(selector instanceof X509CRLSelector)) {
|
||||
throw new CertStoreException("need X509CRLSelector to find CRLs");
|
||||
throw new CertStoreException("Need X509CRLSelector to find CRLs, "
|
||||
+ "but instance of " + selector.getClass().getName()
|
||||
+ " passed");
|
||||
}
|
||||
return impl.getCRLs((X509CRLSelector) selector, ldapDN);
|
||||
}
|
||||
|
||||
@ -133,9 +133,6 @@ java/beans/Introspector/8132566/OverrideUserDefPropertyInfoTest.java generic-all
|
||||
# 8029891
|
||||
java/lang/ClassLoader/deadlock/GetResource.java generic-all
|
||||
|
||||
# 8133552
|
||||
java/lang/ProcessHandle/InfoTest.java generic-all
|
||||
|
||||
############################################################################
|
||||
|
||||
# jdk_instrument
|
||||
@ -363,10 +360,6 @@ com/sun/jdi/GetLocalVariables4Test.sh windows-all
|
||||
# 8062512
|
||||
java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java generic-all
|
||||
|
||||
# 8029453
|
||||
java/util/concurrent/locks/ReentrantLock/TimeoutLockLoops.java linux-all
|
||||
|
||||
|
||||
############################################################################
|
||||
|
||||
# jdk_instrument
|
||||
|
||||
@ -203,8 +203,10 @@ public class InfoTest {
|
||||
"commandLine() should start with: " + expectedPath +
|
||||
" but starts with " + commandLineCmdPath);
|
||||
|
||||
Assert.assertTrue(commandLine.contains(command.get()),
|
||||
"commandLine() must contain the command: " + command.get());
|
||||
List<String> allArgs = p1.getArgs();
|
||||
for (int i = 0; i < allArgs.size(); i++) {
|
||||
for (int i = 1; i < allArgs.size(); i++) {
|
||||
Assert.assertTrue(commandLine.contains(allArgs.get(i)),
|
||||
"commandLine() must contain argument: " + allArgs.get(i));
|
||||
}
|
||||
@ -255,10 +257,15 @@ public class InfoTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
p1.waitFor(Utils.adjustTimeout(5), TimeUnit.SECONDS);
|
||||
p1.sendAction("exit");
|
||||
Assert.assertTrue(p1.waitFor(Utils.adjustTimeout(30L), TimeUnit.SECONDS),
|
||||
"timeout waiting for process to terminate");
|
||||
} catch (IOException | InterruptedException ie) {
|
||||
ie.printStackTrace(System.out);
|
||||
Assert.fail("unexpected exception", ie);
|
||||
} finally {
|
||||
// Destroy any children that still exist
|
||||
ProcessUtil.destroyProcessTree(ProcessHandle.current());
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,8 +275,9 @@ public class InfoTest {
|
||||
@Test
|
||||
public static void test3() {
|
||||
try {
|
||||
for (int sleepTime : Arrays.asList(1, 2)) {
|
||||
for (long sleepTime : Arrays.asList(Utils.adjustTimeout(30), Utils.adjustTimeout(32))) {
|
||||
Process p = spawn("sleep", String.valueOf(sleepTime));
|
||||
|
||||
ProcessHandle.Info info = p.info();
|
||||
System.out.printf(" info: %s%n", info);
|
||||
|
||||
@ -295,7 +303,9 @@ public class InfoTest {
|
||||
Assert.assertEquals(args[0], String.valueOf(sleepTime));
|
||||
}
|
||||
}
|
||||
Assert.assertTrue(p.waitFor(15, TimeUnit.SECONDS));
|
||||
p.destroy();
|
||||
Assert.assertTrue(p.waitFor(Utils.adjustTimeout(30), TimeUnit.SECONDS),
|
||||
"timeout waiting for process to terminate");
|
||||
}
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
|
||||
114
jdk/test/java/net/MulticastSocket/MultiDead.java
Normal file
114
jdk/test/java/net/MulticastSocket/MultiDead.java
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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 8072466
|
||||
* @summary Deadlock when initializing MulticastSocket and DatagramSocket
|
||||
* @library /lib/testlibrary
|
||||
* @build jdk.testlibrary.*
|
||||
* @run main/othervm MultiDead
|
||||
*/
|
||||
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.MulticastSocket;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import jdk.testlibrary.JDKToolLauncher;
|
||||
|
||||
public class MultiDead {
|
||||
private static final int THREAD_PAIR_COUNT = 4;
|
||||
private static final int CHILDREN_COUNT = 20;
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
if (args.length == 0 || args[0].equals("parent")) {
|
||||
parentProcess();
|
||||
}
|
||||
|
||||
if (args.length > 0 && args[0].equals("child")) {
|
||||
childProcess();
|
||||
}
|
||||
}
|
||||
|
||||
private static void parentProcess() throws Throwable {
|
||||
JDKToolLauncher launcher = JDKToolLauncher
|
||||
.createUsingTestJDK("java")
|
||||
.addToolArg("MultiDead")
|
||||
.addToolArg("child");
|
||||
ProcessBuilder pb = new ProcessBuilder(launcher.getCommand());
|
||||
|
||||
AtomicReference<Process> child = new AtomicReference<>();
|
||||
AtomicBoolean stopFlag = new AtomicBoolean(false);
|
||||
|
||||
Thread th = new Thread(() -> {
|
||||
for (int i = 0; i < CHILDREN_COUNT; ++i) {
|
||||
System.out.println("child #" + (i + 1) + " of " +
|
||||
CHILDREN_COUNT);
|
||||
try {
|
||||
child.set(pb.start());
|
||||
child.get().waitFor();
|
||||
if (stopFlag.get()) {
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
th.start();
|
||||
th.join(CHILDREN_COUNT * 1000); // 1 sec for a child to complete
|
||||
stopFlag.set(true);
|
||||
if (th.isAlive()) {
|
||||
if (child.get() != null) {
|
||||
child.get().destroyForcibly();
|
||||
}
|
||||
throw new RuntimeException("Failed to complete on time.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void childProcess() {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
for (int i = 0; i < THREAD_PAIR_COUNT; ++i) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
latch.await();
|
||||
try (MulticastSocket a = new MulticastSocket(6000)) {
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}).start();
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
latch.await();
|
||||
try (DatagramSocket b = new DatagramSocket(6000)) {
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
@ -35,7 +35,6 @@
|
||||
* @test
|
||||
* @bug 4486658 5031862
|
||||
* @run main TimeoutLockLoops
|
||||
* @key intermittent
|
||||
* @summary Checks for responsiveness of locks to timeouts.
|
||||
* Runs under the assumption that ITERS computations require more than
|
||||
* TIMEOUT msecs to complete, which seems to be a safe assumption for
|
||||
|
||||
146
jdk/test/sun/security/krb5/auto/KrbTicket.java
Normal file
146
jdk/test/sun/security/krb5/auto/KrbTicket.java
Normal file
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.security.auth.RefreshFailedException;
|
||||
import javax.security.auth.Subject;
|
||||
import javax.security.auth.kerberos.KerberosTicket;
|
||||
import javax.security.auth.login.LoginContext;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6857795 8075299
|
||||
* @summary Checks Kerberos ticket properties
|
||||
* @run main/othervm KrbTicket
|
||||
*/
|
||||
public class KrbTicket {
|
||||
|
||||
private static final String REALM = "TEST.REALM";
|
||||
private static final String HOST = "localhost";
|
||||
private static final String USER = "TESTER";
|
||||
private static final String USER_PRINCIPAL = USER + "@" + REALM;
|
||||
private static final String PASSWORD = "password";
|
||||
private static final String KRBTGT_PRINCIPAL = "krbtgt/" + REALM;
|
||||
private static final String KRB5_CONF_FILENAME = "krb5.conf";
|
||||
private static final String JAAS_CONF = "jaas.conf";
|
||||
private static final long TICKET_LIFTETIME = 5 * 60 * 1000; // 5 mins
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// define principals
|
||||
Map<String, String> principals = new HashMap<>();
|
||||
principals.put(USER_PRINCIPAL, PASSWORD);
|
||||
principals.put(KRBTGT_PRINCIPAL, null);
|
||||
|
||||
System.setProperty("java.security.krb5.conf", KRB5_CONF_FILENAME);
|
||||
|
||||
// start a local KDC instance
|
||||
KDC kdc = KDC.startKDC(HOST, null, REALM, principals, null, null);
|
||||
KDC.saveConfig(KRB5_CONF_FILENAME, kdc,
|
||||
"forwardable = true", "proxiable = true");
|
||||
|
||||
// create JAAS config
|
||||
Files.write(Paths.get(JAAS_CONF), Arrays.asList(
|
||||
"Client {",
|
||||
" com.sun.security.auth.module.Krb5LoginModule required;",
|
||||
"};"
|
||||
));
|
||||
System.setProperty("java.security.auth.login.config", JAAS_CONF);
|
||||
System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
|
||||
|
||||
long startTime = Instant.now().getEpochSecond() * 1000;
|
||||
|
||||
LoginContext lc = new LoginContext("Client",
|
||||
new Helper.UserPasswordHandler(USER, PASSWORD));
|
||||
lc.login();
|
||||
|
||||
Subject subject = lc.getSubject();
|
||||
System.out.println("subject: " + subject);
|
||||
|
||||
Set creds = subject.getPrivateCredentials(
|
||||
KerberosTicket.class);
|
||||
|
||||
if (creds.size() > 1) {
|
||||
throw new RuntimeException("Multiple credintials found");
|
||||
}
|
||||
|
||||
Object o = creds.iterator().next();
|
||||
if (!(o instanceof KerberosTicket)) {
|
||||
throw new RuntimeException("Instance of KerberosTicket expected");
|
||||
}
|
||||
KerberosTicket krbTkt = (KerberosTicket) o;
|
||||
|
||||
System.out.println("forwardable = " + krbTkt.isForwardable());
|
||||
System.out.println("proxiable = " + krbTkt.isProxiable());
|
||||
System.out.println("renewable = " + krbTkt.isRenewable());
|
||||
System.out.println("current = " + krbTkt.isCurrent());
|
||||
|
||||
if (!krbTkt.isForwardable()) {
|
||||
throw new RuntimeException("Forwardable ticket expected");
|
||||
}
|
||||
|
||||
if (!krbTkt.isProxiable()) {
|
||||
throw new RuntimeException("Proxiable ticket expected");
|
||||
}
|
||||
|
||||
if (!krbTkt.isCurrent()) {
|
||||
throw new RuntimeException("Ticket is not current");
|
||||
}
|
||||
|
||||
if (krbTkt.isRenewable()) {
|
||||
throw new RuntimeException("Not renewable ticket expected");
|
||||
}
|
||||
try {
|
||||
krbTkt.refresh();
|
||||
throw new RuntimeException(
|
||||
"Expected RefreshFailedException not thrown");
|
||||
} catch(RefreshFailedException e) {
|
||||
System.out.println("Expected exception: " + e);
|
||||
}
|
||||
|
||||
if (!checkTime(krbTkt, startTime)) {
|
||||
throw new RuntimeException("Wrong ticket life time");
|
||||
}
|
||||
|
||||
krbTkt.destroy();
|
||||
if (!krbTkt.isDestroyed()) {
|
||||
throw new RuntimeException("Ticket not destroyed");
|
||||
}
|
||||
|
||||
System.out.println("Test passed");
|
||||
}
|
||||
|
||||
private static boolean checkTime(KerberosTicket krbTkt, long startTime) {
|
||||
long ticketEndTime = krbTkt.getEndTime().getTime();
|
||||
long roughLifeTime = ticketEndTime - startTime;
|
||||
System.out.println("start time = " + startTime);
|
||||
System.out.println("end time = " + ticketEndTime);
|
||||
System.out.println("rough life time = " + roughLifeTime);
|
||||
return roughLifeTime >= TICKET_LIFTETIME;
|
||||
}
|
||||
}
|
||||
188
jdk/test/sun/security/krb5/auto/tools/KinitConfPlusProps.java
Normal file
188
jdk/test/sun/security/krb5/auto/tools/KinitConfPlusProps.java
Normal file
@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.File;
|
||||
import java.net.PortUnreachableException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import jdk.testlibrary.ProcessTools;
|
||||
import jdk.testlibrary.OutputAnalyzer;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6857795 8075299
|
||||
* @summary Checks if kinit uses both krb5 conf file and system properties
|
||||
* @requires os.family == "windows"
|
||||
* @library /lib/testlibrary
|
||||
* @library /sun/security/krb5/auto
|
||||
* @run main/othervm KinitConfPlusProps
|
||||
*/
|
||||
public class KinitConfPlusProps {
|
||||
|
||||
private static final String KINIT = System.getProperty("java.home")
|
||||
+ File.separator + "bin" + File.separator + "kinit";
|
||||
private static final String KLIST = System.getProperty("java.home")
|
||||
+ File.separator + "bin" + File.separator + "klist";
|
||||
private static final String REALM = "REALM";
|
||||
private static final String ANOTHER_REALM = "ANOTHER.REALM";
|
||||
private static final String HOST = "localhost";
|
||||
private static final String CC_FILENAME = "krb5cc_test";
|
||||
private static final String USER = "TESTER";
|
||||
private static final String USER_PRINCIPAL = USER + "@" + REALM;
|
||||
private static final String KRBTGT_PRINCIPAL = "krbtgt/" + REALM;
|
||||
private static final String KEYTAB_FILE = "test.keytab";
|
||||
private static final String KRB5_CONF_FILENAME = "krb5.conf";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// define principals
|
||||
Map<String, String> principals = new HashMap<>();
|
||||
principals.put(USER_PRINCIPAL, null);
|
||||
principals.put(KRBTGT_PRINCIPAL, null);
|
||||
|
||||
System.setProperty("java.security.krb5.conf", KRB5_CONF_FILENAME);
|
||||
|
||||
// start a local KDC instance
|
||||
KDC kdc = KDC.startKDC(HOST, null, REALM, principals, KEYTAB_FILE,
|
||||
KDC.KtabMode.APPEND);
|
||||
KDC.saveConfig(KRB5_CONF_FILENAME, kdc,
|
||||
"forwardable = true", "proxiable = true");
|
||||
|
||||
boolean success = true;
|
||||
|
||||
/*
|
||||
* kinit should fail since java.security.krb5.kdc
|
||||
* and java.security.krb5.realm properties override correct values
|
||||
* in krb5 conf file
|
||||
*/
|
||||
String[] command = {KINIT, "-k",
|
||||
"-J-Djava.security.krb5.realm=" + REALM,
|
||||
"-J-Djava.security.krb5.kdc=" + HOST, // without port
|
||||
"-J-Djava.security.krb5.conf=" + KRB5_CONF_FILENAME,
|
||||
"-t", KEYTAB_FILE,
|
||||
"-c", CC_FILENAME,
|
||||
USER
|
||||
};
|
||||
|
||||
try {
|
||||
OutputAnalyzer out = ProcessTools.executeCommand(command);
|
||||
out.shouldHaveExitValue(-1);
|
||||
out.shouldContain(PortUnreachableException.class.getName());
|
||||
} catch(Throwable e) {
|
||||
System.out.println("Unexpected exception: " + e);
|
||||
e.printStackTrace(System.out);
|
||||
success = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* kinit should succeed
|
||||
* since realm should be picked up from principal name
|
||||
*/
|
||||
command = new String[] {KINIT, "-k",
|
||||
"-J-Djava.security.krb5.realm=" + ANOTHER_REALM,
|
||||
"-J-Djava.security.krb5.kdc=" + HOST,
|
||||
"-J-Djava.security.krb5.conf=" + KRB5_CONF_FILENAME,
|
||||
"-t", KEYTAB_FILE,
|
||||
"-c", CC_FILENAME,
|
||||
USER_PRINCIPAL
|
||||
};
|
||||
|
||||
try {
|
||||
OutputAnalyzer out = ProcessTools.executeCommand(command);
|
||||
out.shouldHaveExitValue(0);
|
||||
out.shouldContain(CC_FILENAME);
|
||||
} catch(Throwable e) {
|
||||
System.out.println("Unexpected exception: " + e);
|
||||
e.printStackTrace(System.out);
|
||||
success = false;
|
||||
}
|
||||
|
||||
success &= checkTicketFlags();
|
||||
|
||||
/*
|
||||
* kinit should succeed
|
||||
* since realm should be picked up from principal name,
|
||||
* and other data should come from krb5 conf file
|
||||
*/
|
||||
command = new String[] {KINIT, "-k",
|
||||
"-J-Djava.security.krb5.conf=" + KRB5_CONF_FILENAME,
|
||||
"-t", KEYTAB_FILE,
|
||||
"-c", CC_FILENAME,
|
||||
USER_PRINCIPAL
|
||||
};
|
||||
|
||||
try {
|
||||
OutputAnalyzer out = ProcessTools.executeCommand(command);
|
||||
out.shouldHaveExitValue(0);
|
||||
out.shouldContain(CC_FILENAME);
|
||||
} catch(Throwable e) {
|
||||
System.out.println("Unexpected exception: " + e);
|
||||
e.printStackTrace(System.out);
|
||||
success = false;
|
||||
}
|
||||
|
||||
success &= checkTicketFlags();
|
||||
|
||||
// kinit should succeed even if a principal name doesn't have realm
|
||||
command = new String[] {KINIT, "-k",
|
||||
"-J-Djava.security.krb5.conf=" + KRB5_CONF_FILENAME,
|
||||
"-t", KEYTAB_FILE,
|
||||
"-c", CC_FILENAME,
|
||||
USER
|
||||
};
|
||||
|
||||
try {
|
||||
OutputAnalyzer out = ProcessTools.executeCommand(command);
|
||||
out.shouldHaveExitValue(0);
|
||||
out.shouldContain(CC_FILENAME);
|
||||
} catch(Throwable e) {
|
||||
System.out.println("Unexpected exception: " + e);
|
||||
e.printStackTrace(System.out);
|
||||
success = false;
|
||||
}
|
||||
|
||||
success &= checkTicketFlags();
|
||||
|
||||
if (!success) {
|
||||
throw new RuntimeException("At least one test case failed");
|
||||
}
|
||||
System.out.println("Test passed");
|
||||
}
|
||||
|
||||
// check if a ticket has forwardable and proxiable flags
|
||||
private static boolean checkTicketFlags() {
|
||||
String[] command = new String[] {KLIST, "-f", "-c", CC_FILENAME};
|
||||
|
||||
try {
|
||||
OutputAnalyzer out = ProcessTools.executeCommand(command);
|
||||
out.shouldHaveExitValue(0);
|
||||
out.shouldContain("FORWARDABLE");
|
||||
out.shouldContain("PROXIABLE");
|
||||
} catch(Throwable e) {
|
||||
System.out.println("Unexpected exception: " + e);
|
||||
e.printStackTrace(System.out);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
130
jdk/test/sun/security/rsa/KeySizeTest.java
Normal file
130
jdk/test/sun/security/rsa/KeySizeTest.java
Normal file
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.security.KeyFactory;
|
||||
import java.security.KeyPair;
|
||||
import java.security.KeyPairGenerator;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.security.interfaces.RSAKey;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.security.spec.RSAPrivateKeySpec;
|
||||
import java.security.spec.RSAPublicKeySpec;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8044199
|
||||
* @summary test if the private and public key size are the same as what is set
|
||||
* through KeyPairGenerator.
|
||||
* @run main KeySizeTest 512 10
|
||||
* @run main KeySizeTest 768 10
|
||||
* @run main KeySizeTest 1024 10
|
||||
* @run main KeySizeTest 2048 5
|
||||
* @run main KeySizeTest 4096 1
|
||||
*/
|
||||
public class KeySizeTest {
|
||||
|
||||
/**
|
||||
* ALGORITHM name, fixed as RSA.
|
||||
*/
|
||||
private static final String KEYALG = "RSA";
|
||||
|
||||
/**
|
||||
* JDK default RSA Provider.
|
||||
*/
|
||||
private static final String PROVIDER_NAME = "SunRsaSign";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
int iKeyPairSize = Integer.parseInt(args[0]);
|
||||
int maxLoopCnt = Integer.parseInt(args[1]);
|
||||
|
||||
int failCount = 0;
|
||||
KeyPairGenerator keyPairGen
|
||||
= KeyPairGenerator.getInstance(KEYALG, PROVIDER_NAME);
|
||||
keyPairGen.initialize(iKeyPairSize);
|
||||
// Generate RSA keypair
|
||||
KeyPair keyPair = keyPairGen.generateKeyPair();
|
||||
|
||||
// Get priavte and public keys
|
||||
PrivateKey privateKey = keyPair.getPrivate();
|
||||
PublicKey publicKey = keyPair.getPublic();
|
||||
try {
|
||||
if (!sizeTest(keyPair)) {
|
||||
failCount++;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
failCount++;
|
||||
}
|
||||
|
||||
for (int iCnt = 0; iCnt < maxLoopCnt; iCnt++) {
|
||||
|
||||
// Get keysize (modulus) of keys
|
||||
KeyFactory keyFact = KeyFactory.getInstance(KEYALG, PROVIDER_NAME);
|
||||
|
||||
// Comparing binary length.
|
||||
RSAPrivateKeySpec privateKeySpec
|
||||
= (RSAPrivateKeySpec) keyFact.getKeySpec(privateKey,
|
||||
RSAPrivateKeySpec.class);
|
||||
int iPrivateKeySize = privateKeySpec.getModulus().bitLength();
|
||||
|
||||
RSAPublicKeySpec publicKeySpec
|
||||
= (RSAPublicKeySpec) keyFact.getKeySpec(publicKey,
|
||||
RSAPublicKeySpec.class);
|
||||
int iPublicKeySize = publicKeySpec.getModulus().bitLength();
|
||||
|
||||
if ((iKeyPairSize != iPublicKeySize) || (iKeyPairSize != iPrivateKeySize)) {
|
||||
System.err.println("iKeyPairSize : " + iKeyPairSize);
|
||||
System.err.println("Generated a " + iPrivateKeySize
|
||||
+ " bit RSA private key");
|
||||
System.err.println("Generated a " + iPublicKeySize
|
||||
+ " bit RSA public key");
|
||||
failCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (failCount > 0) {
|
||||
throw new RuntimeException("There are " + failCount + " tests failed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param kpair test key pair.
|
||||
* @return true if test passed. false if test failed.
|
||||
*/
|
||||
private static boolean sizeTest(KeyPair kpair) {
|
||||
RSAPrivateKey priv = (RSAPrivateKey) kpair.getPrivate();
|
||||
RSAPublicKey pub = (RSAPublicKey) kpair.getPublic();
|
||||
|
||||
// test the getModulus method
|
||||
if ((priv instanceof RSAKey) && (pub instanceof RSAKey)) {
|
||||
if (!priv.getModulus().equals(pub.getModulus())) {
|
||||
System.err.println("priv.getModulus() = " + priv.getModulus());
|
||||
System.err.println("pub.getModulus() = " + pub.getModulus());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
108
jdk/test/sun/security/rsa/PrivateKeyEqualityTest.java
Normal file
108
jdk/test/sun/security/rsa/PrivateKeyEqualityTest.java
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.security.KeyFactory;
|
||||
import java.security.KeyPairGenerator;
|
||||
import java.security.KeyPair;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.interfaces.RSAPrivateCrtKey;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.RSAPrivateKeySpec;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.RSAPrivateCrtKeySpec;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8044199 4666485
|
||||
* @summary Equality checking for RSAPrivateKey by SunRsaSign provider.
|
||||
*/
|
||||
public class PrivateKeyEqualityTest {
|
||||
/**
|
||||
* ALGORITHM name, fixed as RSA.
|
||||
*/
|
||||
private static final String KEYALG = "RSA";
|
||||
|
||||
/**
|
||||
* JDK default RSA Provider.
|
||||
*/
|
||||
private static final String PROVIDER_NAME = "SunRsaSign";
|
||||
|
||||
public static void main(String[] args) throws NoSuchAlgorithmException,
|
||||
NoSuchProviderException, InvalidKeySpecException {
|
||||
// Generate the first key.
|
||||
KeyPairGenerator generator
|
||||
= KeyPairGenerator.getInstance(KEYALG, PROVIDER_NAME);
|
||||
KeyPair keyPair = generator.generateKeyPair();
|
||||
RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) keyPair.getPrivate();
|
||||
if (!(rsaPrivateKey instanceof RSAPrivateCrtKey)) {
|
||||
System.err.println("rsaPrivateKey class : " + rsaPrivateKey.getClass().getName());
|
||||
throw new RuntimeException("rsaPrivateKey is not a RSAPrivateCrtKey instance");
|
||||
}
|
||||
|
||||
// Generate the second key.
|
||||
KeyFactory factory = KeyFactory.getInstance(KEYALG, PROVIDER_NAME);
|
||||
RSAPrivateKeySpec rsaPrivateKeySpec = new RSAPrivateKeySpec(
|
||||
rsaPrivateKey.getModulus(), rsaPrivateKey.getPrivateExponent());
|
||||
RSAPrivateKey rsaPrivateKey2 = (RSAPrivateKey) factory.generatePrivate(
|
||||
rsaPrivateKeySpec);
|
||||
|
||||
// Generate the third key.
|
||||
PKCS8EncodedKeySpec encodedKeySpec = new PKCS8EncodedKeySpec(
|
||||
rsaPrivateKey.getEncoded());
|
||||
RSAPrivateKey rsaPrivateKey3 = (RSAPrivateKey) factory.generatePrivate(
|
||||
encodedKeySpec);
|
||||
|
||||
// Check for equality.
|
||||
if (rsaPrivateKey.equals(rsaPrivateKey2)) {
|
||||
throw new RuntimeException("rsaPrivateKey should not equal to rsaPrivateKey2");
|
||||
}
|
||||
if (!rsaPrivateKey3.equals(rsaPrivateKey)) {
|
||||
throw new RuntimeException("rsaPrivateKey3 should equal to rsaPrivateKey");
|
||||
}
|
||||
if (rsaPrivateKey3.equals(rsaPrivateKey2)) {
|
||||
throw new RuntimeException("rsaPrivateKey3 should not equal to rsaPrivateKey2");
|
||||
}
|
||||
if (rsaPrivateKey2.equals(rsaPrivateKey3)) {
|
||||
throw new RuntimeException("rsaPrivateKey2 should not equal to rsaPrivateKey3");
|
||||
}
|
||||
|
||||
// Generate the fourth key.
|
||||
RSAPrivateCrtKey rsaPrivateCrtKey = (RSAPrivateCrtKey)rsaPrivateKey;
|
||||
RSAPrivateCrtKeySpec rsaPrivateCrtKeySpec = new RSAPrivateCrtKeySpec(
|
||||
rsaPrivateCrtKey.getModulus(),
|
||||
rsaPrivateCrtKey.getPublicExponent(),
|
||||
rsaPrivateCrtKey.getPrivateExponent(),
|
||||
rsaPrivateCrtKey.getPrimeP(),
|
||||
rsaPrivateCrtKey.getPrimeQ(),
|
||||
rsaPrivateCrtKey.getPrimeExponentP(),
|
||||
rsaPrivateCrtKey.getPrimeExponentQ(),
|
||||
rsaPrivateCrtKey.getCrtCoefficient()
|
||||
);
|
||||
RSAPrivateCrtKey rsaPrivateKey4 = (RSAPrivateCrtKey) factory.generatePrivate(
|
||||
rsaPrivateCrtKeySpec);
|
||||
if (!rsaPrivateKey.equals(rsaPrivateKey4)) {
|
||||
throw new RuntimeException("rsaPrivateKey should equal to rsaPrivateKey4");
|
||||
}
|
||||
}
|
||||
}
|
||||
209
jdk/test/sun/security/rsa/SignatureTest.java
Normal file
209
jdk/test/sun/security/rsa/SignatureTest.java
Normal file
@ -0,0 +1,209 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.security.InvalidKeyException;
|
||||
import java.security.Key;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.KeyPair;
|
||||
import java.security.KeyPairGenerator;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.security.Signature;
|
||||
import java.security.SignatureException;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.RSAPrivateKeySpec;
|
||||
import java.security.spec.RSAPublicKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.Arrays;
|
||||
import static javax.crypto.Cipher.PRIVATE_KEY;
|
||||
import static javax.crypto.Cipher.PUBLIC_KEY;
|
||||
import jdk.testlibrary.RandomFactory;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8044199
|
||||
* @summary Create a signature for RSA and get its signed data. re-initiate
|
||||
* the signature with the public key. The signature can be verified
|
||||
* by acquired signed data.
|
||||
* @key randomness
|
||||
* @library ../../../lib/testlibrary
|
||||
* @run main SignatureTest MD2withRSA 512
|
||||
* @run main SignatureTest MD5withRSA 512
|
||||
* @run main SignatureTest SHA1withRSA 512
|
||||
* @run main SignatureTest SHA256withRSA 512
|
||||
* @run main SignatureTest MD2withRSA 768
|
||||
* @run main SignatureTest MD5withRSA 768
|
||||
* @run main SignatureTest SHA1withRSA 768
|
||||
* @run main SignatureTest SHA256withRSA 768
|
||||
* @run main SignatureTest MD2withRSA 1024
|
||||
* @run main SignatureTest MD5withRSA 1024
|
||||
* @run main SignatureTest SHA1withRSA 1024
|
||||
* @run main SignatureTest SHA256withRSA 1024
|
||||
* @run main SignatureTest MD2withRSA 2048
|
||||
* @run main SignatureTest MD5withRSA 2048
|
||||
* @run main SignatureTest SHA1withRSA 2048
|
||||
* @run main SignatureTest SHA256withRSA 2048
|
||||
* @run main/timeout=240 SignatureTest MD2withRSA 4096
|
||||
* @run main/timeout=240 SignatureTest MD5withRSA 4096
|
||||
* @run main/timeout=240 SignatureTest SHA1withRSA 4096
|
||||
* @run main/timeout=240 SignatureTest SHA256withRSA 4096
|
||||
* @run main/timeout=240 SignatureTest MD2withRSA 5120
|
||||
* @run main/timeout=240 SignatureTest MD5withRSA 5120
|
||||
* @run main/timeout=240 SignatureTest SHA1withRSA 5120
|
||||
* @run main/timeout=240 SignatureTest SHA256withRSA 5120
|
||||
* @run main/timeout=240 SignatureTest MD2withRSA 6144
|
||||
* @run main/timeout=240 SignatureTest MD5withRSA 6144
|
||||
* @run main/timeout=240 SignatureTest SHA1withRSA 6144
|
||||
* @run main/timeout=240 SignatureTest SHA256withRSA 6144
|
||||
*/
|
||||
public class SignatureTest {
|
||||
/**
|
||||
* ALGORITHM name, fixed as RSA.
|
||||
*/
|
||||
private static final String KEYALG = "RSA";
|
||||
|
||||
/**
|
||||
* JDK default RSA Provider.
|
||||
*/
|
||||
private static final String PROVIDER = "SunRsaSign";
|
||||
|
||||
/**
|
||||
* How much times signature updated.
|
||||
*/
|
||||
private static final int UPDATE_TIMES_FIFTY = 50;
|
||||
|
||||
/**
|
||||
* How much times signature initial updated.
|
||||
*/
|
||||
private static final int UPDATE_TIMES_HUNDRED = 100;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String testAlg = args[0];
|
||||
int testSize = Integer.parseInt(args[1]);
|
||||
|
||||
byte[] data = new byte[100];
|
||||
RandomFactory.getRandom().nextBytes(data);
|
||||
|
||||
// create a key pair
|
||||
KeyPair kpair = generateKeys(KEYALG, testSize);
|
||||
Key[] privs = manipulateKey(PRIVATE_KEY, kpair.getPrivate());
|
||||
Key[] pubs = manipulateKey(PUBLIC_KEY, kpair.getPublic());
|
||||
// For signature algorithm, create and verify a signature
|
||||
|
||||
Arrays.stream(privs).forEach(priv
|
||||
-> Arrays.stream(pubs).forEach(pub -> {
|
||||
try {
|
||||
checkSignature(data, (PublicKey) pub, (PrivateKey) priv,
|
||||
testAlg);
|
||||
} catch (NoSuchAlgorithmException | InvalidKeyException
|
||||
| SignatureException | NoSuchProviderException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
private static KeyPair generateKeys(String keyalg, int size)
|
||||
throws NoSuchAlgorithmException {
|
||||
KeyPairGenerator kpg = KeyPairGenerator.getInstance(keyalg);
|
||||
kpg.initialize(size);
|
||||
return kpg.generateKeyPair();
|
||||
}
|
||||
|
||||
private static Key[] manipulateKey(int type, Key key)
|
||||
throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException {
|
||||
KeyFactory kf = KeyFactory.getInstance(KEYALG, PROVIDER);
|
||||
|
||||
switch (type) {
|
||||
case PUBLIC_KEY:
|
||||
try {
|
||||
kf.getKeySpec(key, RSAPrivateKeySpec.class);
|
||||
throw new RuntimeException("Expected InvalidKeySpecException "
|
||||
+ "not thrown");
|
||||
} catch (InvalidKeySpecException expected) {
|
||||
}
|
||||
|
||||
return new Key[]{
|
||||
kf.generatePublic(kf.getKeySpec(key, RSAPublicKeySpec.class)),
|
||||
kf.generatePublic(new X509EncodedKeySpec(key.getEncoded())),
|
||||
kf.generatePublic(new RSAPublicKeySpec(
|
||||
((RSAPublicKey) key).getModulus(),
|
||||
((RSAPublicKey) key).getPublicExponent()))
|
||||
};
|
||||
case PRIVATE_KEY:
|
||||
try {
|
||||
kf.getKeySpec(key, RSAPublicKeySpec.class);
|
||||
throw new RuntimeException("Expected InvalidKeySpecException"
|
||||
+ " not thrown");
|
||||
} catch (InvalidKeySpecException expected) {
|
||||
}
|
||||
return new Key[]{
|
||||
kf.generatePrivate(kf.getKeySpec(key,
|
||||
RSAPrivateKeySpec.class)),
|
||||
kf.generatePrivate(new PKCS8EncodedKeySpec(
|
||||
key.getEncoded())),
|
||||
kf.generatePrivate(new RSAPrivateKeySpec(((RSAPrivateKey) key).getModulus(),
|
||||
((RSAPrivateKey) key).getPrivateExponent()))
|
||||
};
|
||||
}
|
||||
throw new RuntimeException("We shouldn't reach here");
|
||||
}
|
||||
|
||||
private static void checkSignature(byte[] data, PublicKey pub,
|
||||
PrivateKey priv, String sigalg) throws NoSuchAlgorithmException,
|
||||
InvalidKeyException, SignatureException, NoSuchProviderException {
|
||||
Signature sig = Signature.getInstance(sigalg, PROVIDER);
|
||||
sig.initSign(priv);
|
||||
for (int i = 0; i < UPDATE_TIMES_HUNDRED; i++) {
|
||||
sig.update(data);
|
||||
}
|
||||
byte[] signedData = sig.sign();
|
||||
|
||||
// Make sure signature verifies with original data
|
||||
sig.initVerify(pub);
|
||||
for (int i = 0; i < UPDATE_TIMES_HUNDRED; i++) {
|
||||
sig.update(data);
|
||||
}
|
||||
if (!sig.verify(signedData)) {
|
||||
throw new RuntimeException("Failed to verify " + sigalg
|
||||
+ " signature");
|
||||
}
|
||||
|
||||
// Make sure signature does NOT verify when the original data
|
||||
// has changed
|
||||
sig.initVerify(pub);
|
||||
for (int i = 0; i < UPDATE_TIMES_FIFTY; i++) {
|
||||
sig.update(data);
|
||||
}
|
||||
|
||||
if (sig.verify(signedData)) {
|
||||
throw new RuntimeException("Failed to detect bad " + sigalg
|
||||
+ " signature");
|
||||
}
|
||||
}
|
||||
}
|
||||
119
jdk/test/sun/security/rsa/SpecTest.java
Normal file
119
jdk/test/sun/security/rsa/SpecTest.java
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.math.BigInteger;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.KeyPair;
|
||||
import java.security.KeyPairGenerator;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.interfaces.RSAKey;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.security.spec.RSAKeyGenParameterSpec;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8044199
|
||||
* @summary Check same KeyPair's private key and public key have same modulus.
|
||||
* also check public key's public exponent equals to given spec's public
|
||||
* exponent.
|
||||
* @run main SpecTest 512
|
||||
* @run main SpecTest 768
|
||||
* @run main SpecTest 1024
|
||||
* @run main SpecTest 2048
|
||||
* @run main/timeout=240 SpecTest 4096
|
||||
* @run main/timeout=240 SpecTest 5120
|
||||
*/
|
||||
public class SpecTest {
|
||||
/**
|
||||
* ALGORITHM name, fixed as RSA.
|
||||
*/
|
||||
private static final String KEYALG = "RSA";
|
||||
|
||||
/**
|
||||
* JDK default RSA Provider.
|
||||
*/
|
||||
private static final String PROVIDER = "SunRsaSign";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param kpair test key pair
|
||||
* @param pubExponent expected public exponent.
|
||||
* @return true if test passed. false if test failed.
|
||||
*/
|
||||
private static boolean specTest(KeyPair kpair, BigInteger pubExponent) {
|
||||
boolean passed = true;
|
||||
RSAPrivateKey priv = (RSAPrivateKey) kpair.getPrivate();
|
||||
RSAPublicKey pub = (RSAPublicKey) kpair.getPublic();
|
||||
|
||||
// test the getModulus method
|
||||
if ((priv instanceof RSAKey) && (pub instanceof RSAKey)) {
|
||||
if (!priv.getModulus().equals(pub.getModulus())) {
|
||||
System.err.println("priv.getModulus() = " + priv.getModulus());
|
||||
System.err.println("pub.getModulus() = " + pub.getModulus());
|
||||
passed = false;
|
||||
}
|
||||
|
||||
if (!pubExponent.equals(pub.getPublicExponent())) {
|
||||
System.err.println("pubExponent = " + pubExponent);
|
||||
System.err.println("pub.getPublicExponent() = "
|
||||
+ pub.getPublicExponent());
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int failCount = 0;
|
||||
|
||||
// Test key size.
|
||||
int size = Integer.parseInt(args[0]);
|
||||
|
||||
try {
|
||||
KeyPairGenerator kpg1 = KeyPairGenerator.getInstance(KEYALG, PROVIDER);
|
||||
kpg1.initialize(new RSAKeyGenParameterSpec(size,
|
||||
RSAKeyGenParameterSpec.F4));
|
||||
if (!specTest(kpg1.generateKeyPair(),
|
||||
RSAKeyGenParameterSpec.F4)) {
|
||||
failCount++;
|
||||
}
|
||||
|
||||
KeyPairGenerator kpg2 = KeyPairGenerator.getInstance(KEYALG, PROVIDER);
|
||||
kpg2.initialize(new RSAKeyGenParameterSpec(size,
|
||||
RSAKeyGenParameterSpec.F0));
|
||||
if (!specTest(kpg2.generateKeyPair(), RSAKeyGenParameterSpec.F0)) {
|
||||
failCount++;
|
||||
}
|
||||
} catch (NoSuchAlgorithmException | NoSuchProviderException
|
||||
| InvalidAlgorithmParameterException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
failCount++;
|
||||
}
|
||||
|
||||
if (failCount != 0) {
|
||||
throw new RuntimeException("There are " + failCount
|
||||
+ " tests failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
247
jdk/test/sun/security/x509/URICertStore/ExtensionsWithLDAP.java
Normal file
247
jdk/test/sun/security/x509/URICertStore/ExtensionsWithLDAP.java
Normal file
@ -0,0 +1,247 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringBufferInputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.CertPath;
|
||||
import java.security.cert.CertPathValidator;
|
||||
import java.security.cert.CertPathValidatorException;
|
||||
import java.security.cert.PKIXParameters;
|
||||
import java.security.cert.TrustAnchor;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import sun.net.spi.nameservice.NameService;
|
||||
import sun.net.spi.nameservice.NameServiceDescriptor;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8134708
|
||||
* @summary Check if LDAP resources from CRLDP and AIA extensions can be loaded
|
||||
* @run main/othervm ExtensionsWithLDAP
|
||||
*/
|
||||
public class ExtensionsWithLDAP {
|
||||
|
||||
/*
|
||||
* Certificate:
|
||||
* Data:
|
||||
* Version: 3 (0x2)
|
||||
* Serial Number: 11174053930990688938 (0x9b1236d8f9c1daaa)
|
||||
* Signature Algorithm: sha512WithRSAEncryption
|
||||
* Issuer: CN=Root
|
||||
* Validity
|
||||
* Not Before: Sep 1 18:03:59 2015 GMT
|
||||
* Not After : Jan 17 18:03:59 2043 GMT
|
||||
* Subject: CN=Root
|
||||
*/
|
||||
private static final String CA_CERT = ""
|
||||
+ "-----BEGIN CERTIFICATE-----\n"
|
||||
+ "MIIC8TCCAdmgAwIBAgIJAJsSNtj5wdqqMA0GCSqGSIb3DQEBDQUAMA8xDTALBgNV\n"
|
||||
+ "BAMMBFJvb3QwHhcNMTUwOTAxMTgwMzU5WhcNNDMwMTE3MTgwMzU5WjAPMQ0wCwYD\n"
|
||||
+ "VQQDDARSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvj892vPm\n"
|
||||
+ "bB++x9QqqyBveP+ZqQ2B1stV7vh5JmDnOTevkZUOcemp3SXu/esNLSbpL+fARYXH\n"
|
||||
+ "V5ubnrfip6RbvcxPfVIIDJrRTLIIsU6W7M6/LJLbLkEVGy4ZV4IHkOw9W2O92rcv\n"
|
||||
+ "BkoqhzZnOTGR6uT3rRcKx4RevEKBKhZO+OPPf//lnckOybmYL7t7yQrajzHro76b\n"
|
||||
+ "QTXYjAUq/DKhglXfC7vF/JzlAvG2IunGmIfjGcnuDo/9X3Bxef/q5TxCS35fvb7t\n"
|
||||
+ "svC+g2QhTcBkQh4uNW2jSjlTIVp1uErCfP5aCjLaez5mqmb1hxPIlcvsNR23HwU6\n"
|
||||
+ "bQO7z7NBo9Do6QIDAQABo1AwTjAdBgNVHQ4EFgQUmLZNOBBkqdYoElyxklPYHmAb\n"
|
||||
+ "QXIwHwYDVR0jBBgwFoAUmLZNOBBkqdYoElyxklPYHmAbQXIwDAYDVR0TBAUwAwEB\n"
|
||||
+ "/zANBgkqhkiG9w0BAQ0FAAOCAQEAYV4fOhDi5q7+XNXCxO8Eil2frR9jqdP4LaQp\n"
|
||||
+ "3L0evW0gvPX68s2WmkPWzIu4TJcpdGFQqxyQFSXuKBXjthyiln77QItGTHWeafES\n"
|
||||
+ "q5ESrKdSaJZq1bTIrrReCIP74f+fY/F4Tnb3dCqzaljXfzpdbeRsIW6gF71xcOUQ\n"
|
||||
+ "nnPEjGVPLUegN+Wn/jQpeLxxIB7FmNXncdRUfMfZ43xVSKuMCy1UUYqJqTa/pXZj\n"
|
||||
+ "jCMeRPThRjRqHlJ69jStfWUQATbLyj9KN09rUaJxzmUSt61UqJi7sjcGySaCjAJc\n"
|
||||
+ "IcCdVmX/DmRLsdv8W36O3MgrvpT1zR3kaAlv2d8HppnBqcL3xg==\n"
|
||||
+ "-----END CERTIFICATE-----";
|
||||
|
||||
/*
|
||||
* Certificate:
|
||||
* Data:
|
||||
* Version: 3 (0x2)
|
||||
* Serial Number: 7 (0x7)
|
||||
* Signature Algorithm: sha512WithRSAEncryption
|
||||
* Issuer: CN=Root
|
||||
* Validity
|
||||
* Not Before: Sep 1 18:03:59 2015 GMT
|
||||
* Not After : Jan 17 18:03:59 2043 GMT
|
||||
* Subject: CN=EE
|
||||
* ...
|
||||
* X509v3 extensions:
|
||||
* X509v3 CRL Distribution Points:
|
||||
* Full Name:
|
||||
* URI:ldap://ldap.host.for.crldp/main.crl
|
||||
* Authority Information Access:
|
||||
* CA Issuers - URI:ldap://ldap.host.for.aia/dc=Root?cACertificate
|
||||
*/
|
||||
private static final String EE_CERT = ""
|
||||
+ "-----BEGIN CERTIFICATE-----\n"
|
||||
+ "MIIDHTCCAgWgAwIBAgIBBzANBgkqhkiG9w0BAQ0FADAPMQ0wCwYDVQQDDARSb290\n"
|
||||
+ "MB4XDTE1MDkwMTE4MDM1OVoXDTQzMDExNzE4MDM1OVowDTELMAkGA1UEAwwCRUUw\n"
|
||||
+ "ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCpyz97liuWPDYcLH9TX8Bi\n"
|
||||
+ "T78olCmAfmevvch6ncXUVuCzbdaKuKXwn4EVbDszsVJLoK5zdtP+X3iDhutj+IgK\n"
|
||||
+ "mLhuczF3M9VIcWr+JJUyTH4+3h/RT8cjCDZOmk9iXkb5ifruVsLqzb9g+Vp140Oz\n"
|
||||
+ "7leikne7KmclHvTfvFd0WDI7Gb9vo4f5rT717BXJ/n+M6pNk8DLpLiEu6eziYvXR\n"
|
||||
+ "v5x+t5Go3x0eCXdaxEQUf2j876Wfr2qHRJK7lDfFe1DDsMg/KpKGiILYZ+g2qtVM\n"
|
||||
+ "ZSxtp5BZEtfB5qV/IE5kWO+mCIAGpXSZIdbERR6pZUq8GLEe1T9e+sO6H24w2F19\n"
|
||||
+ "AgMBAAGjgYUwgYIwNAYDVR0fBC0wKzApoCegJYYjbGRhcDovL2xkYXAuaG9zdC5m\n"
|
||||
+ "b3IuY3JsZHAvbWFpbi5jcmwwSgYIKwYBBQUHAQEEPjA8MDoGCCsGAQUFBzAChi5s\n"
|
||||
+ "ZGFwOi8vbGRhcC5ob3N0LmZvci5haWEvZGM9Um9vdD9jQUNlcnRpZmljYXRlMA0G\n"
|
||||
+ "CSqGSIb3DQEBDQUAA4IBAQBWDfZHpuUx0yn5d3+BuztFqoks1MkGdk+USlH0TB1/\n"
|
||||
+ "gWWBd+4S4PCKlpSur0gj2rMW4fP5HQfNlHci8JV8/bG4KuKRAXW56dg1818Hl3pc\n"
|
||||
+ "iIrUSRn8uUjH3p9qb+Rb/u3mmVQRyJjN2t/zceNsO8/+Dd808OB9aEwGs8lMT0nn\n"
|
||||
+ "ZYaaAqYz1GIY/Ecyx1vfEZEQ1ljo6i/r70C3igbypBUShxSiGsleiVTLOGNA+MN1\n"
|
||||
+ "/a/Qh0bkaQyTGqK3bwvzzMeQVqWu2EWTBD/PmND5ExkpRICdv8LBVXfLnpoBr4lL\n"
|
||||
+ "hnxn9+e0Ah+t8dS5EKfn44w5bI5PCu2bqxs6RCTxNjcY\n"
|
||||
+ "-----END CERTIFICATE-----";
|
||||
|
||||
|
||||
private static final String LDAP_HOST_CRLDP = "ldap.host.for.crldp";
|
||||
private static final String LDAP_HOST_AIA = "ldap.host.for.aia";
|
||||
|
||||
// a date within the certificates validity period
|
||||
static final Date validationDate;
|
||||
static {
|
||||
try {
|
||||
validationDate = DateFormat.getDateInstance(
|
||||
DateFormat.MEDIUM, Locale.US).parse("Sep 02, 2015");
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException("Couldn't parse date", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// enable CRLDP and AIA extensions
|
||||
System.setProperty("com.sun.security.enableCRLDP", "true");
|
||||
System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
|
||||
|
||||
// register a local name service
|
||||
System.setProperty("sun.net.spi.nameservice.provider.1", "ns,localdns");
|
||||
|
||||
X509Certificate trustedCert = loadCertificate(CA_CERT);
|
||||
X509Certificate eeCert = loadCertificate(EE_CERT);
|
||||
|
||||
Set<TrustAnchor> trustedCertsSet = new HashSet<>();
|
||||
trustedCertsSet.add(new TrustAnchor(trustedCert, null));
|
||||
|
||||
CertPath cp = (CertPath) CertificateFactory.getInstance("X509")
|
||||
.generateCertPath(Arrays.asList(eeCert));
|
||||
|
||||
PKIXParameters params = new PKIXParameters(trustedCertsSet);
|
||||
params.setDate(validationDate);
|
||||
|
||||
// certpath validator should try to parse CRLDP and AIA extensions,
|
||||
// and load CRLs/certs which they point to
|
||||
// if a local name service catched requests for resolving host names
|
||||
// which extensions contain, then it means that certpath validator
|
||||
// tried to load CRLs/certs which they point to
|
||||
try {
|
||||
CertPathValidator.getInstance("PKIX").validate(cp, params);
|
||||
throw new RuntimeException("CertPathValidatorException not thrown");
|
||||
} catch (CertPathValidatorException cpve) {
|
||||
System.out.println("Expected exception: " + cpve);
|
||||
}
|
||||
|
||||
// check if it tried to resolve a host name from CRLDP extension
|
||||
if (!LocalNameService.requestedHosts.contains(LDAP_HOST_CRLDP)) {
|
||||
throw new RuntimeException(
|
||||
"A hostname from CRLDP extension not requested");
|
||||
}
|
||||
|
||||
// check if it tried to resolve a host name from AIA extension
|
||||
if (!LocalNameService.requestedHosts.contains(LDAP_HOST_AIA)) {
|
||||
throw new RuntimeException(
|
||||
"A hostname from AIA extension not requested");
|
||||
}
|
||||
|
||||
System.out.println("Test passed");
|
||||
}
|
||||
|
||||
// load a X509 certificate
|
||||
public static X509Certificate loadCertificate(String s)
|
||||
throws IOException, CertificateException {
|
||||
|
||||
try (StringBufferInputStream is = new StringBufferInputStream(s)) {
|
||||
return (X509Certificate) CertificateFactory.getInstance("X509")
|
||||
.generateCertificate(is);
|
||||
}
|
||||
}
|
||||
|
||||
// a local name service which log requested host names
|
||||
public static class LocalNameService implements NameServiceDescriptor {
|
||||
|
||||
static final List<String> requestedHosts = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public NameService createNameService() throws Exception {
|
||||
System.out.println("LocalNameService: createNameService() called");
|
||||
NameService ns = new NameService() {
|
||||
|
||||
@Override
|
||||
public InetAddress[] lookupAllHostAddr(String host)
|
||||
throws UnknownHostException {
|
||||
|
||||
System.out.println("LocalNameService: "
|
||||
+ "NameService.lookupAllHostAddr(): " + host);
|
||||
|
||||
requestedHosts.add(host);
|
||||
|
||||
throw new UnknownHostException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHostByAddr(byte[] addr)
|
||||
throws UnknownHostException {
|
||||
System.out.println("LocalNameService: "
|
||||
+ "NameService.getHostByAddr(): "
|
||||
+ Arrays.toString(addr));
|
||||
throw new UnknownHostException("No reverse lookup");
|
||||
}
|
||||
};
|
||||
return ns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderName() {
|
||||
return "localdns";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "ns";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
ExtensionsWithLDAP$LocalNameService
|
||||
@ -25,6 +25,7 @@
|
||||
*@test
|
||||
*@bug 6377794
|
||||
*@summary Test case for tzdata2005r support for 9 locales
|
||||
*@run main/othervm -Djava.locale.providers=JRE,SPI Bug6377794
|
||||
*/
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
66
jdk/test/sun/util/resources/cldr/Bug8134384.java
Normal file
66
jdk/test/sun/util/resources/cldr/Bug8134384.java
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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 8134384
|
||||
* @summary Tests CLDR TimeZoneNames has English names for all tzids
|
||||
* @run main/othervm -Djava.locale.providers=CLDR Bug8134384
|
||||
*/
|
||||
|
||||
import java.text.*;
|
||||
import java.time.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Bug8134384 {
|
||||
public static void main(String [] args) {
|
||||
TimeZone original = TimeZone.getDefault();
|
||||
|
||||
try {
|
||||
for (String tz : TimeZone.getAvailableIDs() ) {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone(tz));
|
||||
// Summer solstice
|
||||
String date1 = Date.from(Instant.parse("2015-06-21T00:00:00.00Z")).toString();
|
||||
testParse(Locale.ENGLISH, date1, tz);
|
||||
testParse(Locale.US, date1, tz);
|
||||
testParse(Locale.ROOT, date1, tz);
|
||||
// Winter solstice
|
||||
String date2 = Date.from(Instant.parse("2015-12-22T00:00:00.00Z")).toString();
|
||||
testParse(Locale.ENGLISH, date2, tz);
|
||||
testParse(Locale.US, date2, tz);
|
||||
testParse(Locale.ROOT, date2, tz);
|
||||
}
|
||||
} finally {
|
||||
TimeZone.setDefault(original);
|
||||
}
|
||||
}
|
||||
|
||||
private static void testParse(Locale locale, String date, String tz) {
|
||||
try {
|
||||
new SimpleDateFormat("EEE MMM d hh:mm:ss z yyyy", locale).parse(date);
|
||||
System.out.println(String.format(Locale.ENGLISH, "OK parsing '%s' in locale '%s', tz: %s", date, locale, tz));
|
||||
} catch (ParseException pe) {
|
||||
throw new RuntimeException(String.format(Locale.ENGLISH, "ERROR parsing '%s' in locale '%s', tz: %s: %s", date, locale, tz, pe.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,3 +323,4 @@ dc35e315436d21eab68ef44909922fb3424917f3 jdk9-b71
|
||||
7fd155b7041c8aba7084f03e2fd1d6f74cceda75 jdk9-b78
|
||||
eaab8a16dcfb807acacdb6d133f3ecd502667a8c jdk9-b79
|
||||
c5671e662392df372b2005b75afa6cfdc0eebce7 jdk9-b80
|
||||
ead8b7192f00417185f0e64d0cb332f0f8ad4ae1 jdk9-b81
|
||||
|
||||
@ -1436,6 +1436,7 @@ public class Resolve {
|
||||
}
|
||||
Assert.check(!sym.kind.isResolutionError());
|
||||
try {
|
||||
types.noWarnings.clear();
|
||||
Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes,
|
||||
allowBoxing, useVarargs, types.noWarnings);
|
||||
currentResolutionContext.addApplicableCandidate(sym, mt);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,38 +23,40 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.sjavac.server;
|
||||
package com.sun.tools.sjavac;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.FilterWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* <p><b>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
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class CompilationResult implements Serializable {
|
||||
public class AutoFlushWriter extends FilterWriter {
|
||||
|
||||
static final long serialVersionUID = 46739181113L;
|
||||
|
||||
// Return code constants
|
||||
public final static int ERROR_FATAL = -1;
|
||||
|
||||
public String stdout;
|
||||
public String stderr;
|
||||
public int returnCode;
|
||||
|
||||
public CompilationResult(int returnCode) {
|
||||
this(returnCode, "", "");
|
||||
public AutoFlushWriter(Writer out) {
|
||||
super(out);
|
||||
}
|
||||
|
||||
public CompilationResult(int returnCode, String stdout, String stderr) {
|
||||
this.returnCode = returnCode;
|
||||
this.stdout = stdout;
|
||||
this.stderr = stderr;
|
||||
@Override
|
||||
public void write(int c) throws IOException {
|
||||
super.write(c);
|
||||
if (c == '\n' || c == '\r')
|
||||
flush();
|
||||
}
|
||||
|
||||
public void setReturnCode(int returnCode) {
|
||||
this.returnCode = returnCode;
|
||||
@Override
|
||||
public void write(String str, int off, int len) throws IOException {
|
||||
super.write(str, off, len);
|
||||
if (str.contains("\n") || str.contains("\r"))
|
||||
flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(char[] cbuf, int off, int len) throws IOException {
|
||||
super.write(cbuf, off, len);
|
||||
for (char c : cbuf) {
|
||||
if (c == '\n' || c == '\r') {
|
||||
flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -31,7 +31,6 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Writer;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
@ -78,8 +77,8 @@ public class CleanProperties implements Transformer {
|
||||
int debugLevel,
|
||||
boolean incremental,
|
||||
int numCores,
|
||||
PrintStream out,
|
||||
PrintStream err) {
|
||||
Writer out,
|
||||
Writer err) {
|
||||
boolean rc = true;
|
||||
for (String pkgName : pkgSrcs.keySet()) {
|
||||
String pkgNameF = pkgName.replace('.',File.separatorChar);
|
||||
|
||||
@ -26,14 +26,22 @@
|
||||
package com.sun.tools.sjavac;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import com.sun.tools.sjavac.comp.CompilationService;
|
||||
import com.sun.tools.sjavac.options.Options;
|
||||
@ -83,8 +91,8 @@ public class CompileJavaPackages implements Transformer {
|
||||
int debugLevel,
|
||||
boolean incremental,
|
||||
int numCores,
|
||||
final PrintStream out,
|
||||
final PrintStream err) {
|
||||
final Writer out,
|
||||
final Writer err) {
|
||||
|
||||
Log.debug("Performing CompileJavaPackages transform...");
|
||||
|
||||
@ -200,102 +208,83 @@ public class CompileJavaPackages implements Transformer {
|
||||
}
|
||||
}
|
||||
|
||||
// The return values for each chunked compile.
|
||||
final CompilationSubResult[] rn = new CompilationSubResult[numCompiles];
|
||||
// The requets, might or might not run as a background thread.
|
||||
final Thread[] requests = new Thread[numCompiles];
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
for (int i=0; i<numCompiles; ++i) {
|
||||
final int ii = i;
|
||||
final CompileChunk cc = compileChunks[i];
|
||||
// Prepare compilation calls
|
||||
List<Callable<CompilationSubResult>> compilationCalls = new ArrayList<>();
|
||||
final Object lock = new Object();
|
||||
for (int i = 0; i < numCompiles; i++) {
|
||||
CompileChunk cc = compileChunks[i];
|
||||
if (cc.srcs.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Pass the num_cores and the id (appended with the chunk number) to the server.
|
||||
Object lock = new Object();
|
||||
requests[i] = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
rn[ii] = sjavac.compile("n/a",
|
||||
id + "-" + ii,
|
||||
args.prepJavacArgs(),
|
||||
Collections.<File>emptyList(),
|
||||
cc.srcs,
|
||||
visibleSources);
|
||||
// In the code below we have to keep in mind that two
|
||||
// different compilation results may include results for
|
||||
// the same package.
|
||||
synchronized (lock) {
|
||||
|
||||
for (String pkg : rn[ii].packageArtifacts.keySet()) {
|
||||
Set<URI> pkgArtifacts = rn[ii].packageArtifacts.get(pkg);
|
||||
packageArtifacts.merge(pkg, pkgArtifacts, Util::union);
|
||||
}
|
||||
|
||||
for (String pkg : rn[ii].packageDependencies.keySet()) {
|
||||
packageDependencies.putIfAbsent(pkg, new HashMap<>());
|
||||
packageDependencies.get(pkg).putAll(rn[ii].packageDependencies.get(pkg));
|
||||
}
|
||||
|
||||
for (String pkg : rn[ii].packageCpDependencies.keySet()) {
|
||||
packageCpDependencies.putIfAbsent(pkg, new HashMap<>());
|
||||
packageCpDependencies.get(pkg).putAll(rn[ii].packageCpDependencies.get(pkg));
|
||||
}
|
||||
|
||||
for (String pkg : rn[ii].packagePubapis.keySet()) {
|
||||
packagePubapis.merge(pkg, rn[ii].packagePubapis.get(pkg), PubApi::mergeTypes);
|
||||
}
|
||||
|
||||
for (String pkg : rn[ii].dependencyPubapis.keySet()) {
|
||||
dependencyPubapis.merge(pkg, rn[ii].dependencyPubapis.get(pkg), PubApi::mergeTypes);
|
||||
}
|
||||
}
|
||||
String chunkId = id + "-" + String.valueOf(i);
|
||||
compilationCalls.add(() -> {
|
||||
CompilationSubResult result = sjavac.compile("n/a",
|
||||
chunkId,
|
||||
args.prepJavacArgs(),
|
||||
Collections.<File>emptyList(),
|
||||
cc.srcs,
|
||||
visibleSources);
|
||||
synchronized (lock) {
|
||||
safeWrite(result.stdout, out);
|
||||
safeWrite(result.stderr, err);
|
||||
}
|
||||
};
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
if (cc.srcs.size() > 0) {
|
||||
String numdeps = "";
|
||||
if (cc.numDependents > 0) numdeps = "(with "+cc.numDependents+" dependents) ";
|
||||
if (!incremental || cc.numPackages > 16) {
|
||||
String info = "("+cc.pkgFromTos+")";
|
||||
if (info.equals("( to )")) {
|
||||
info = "";
|
||||
}
|
||||
Log.info("Compiling "+cc.srcs.size()+" files "+numdeps+"in "+cc.numPackages+" packages "+info);
|
||||
} else {
|
||||
Log.info("Compiling "+cc.pkgNames+numdeps);
|
||||
}
|
||||
if (concurrentCompiles) {
|
||||
requests[ii].start();
|
||||
}
|
||||
else {
|
||||
requests[ii].run();
|
||||
// If there was an error, then stop early when running single threaded.
|
||||
if (rn[i].returnCode != 0) {
|
||||
Log.info(rn[i].stdout);
|
||||
Log.error(rn[i].stderr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Perform compilations and collect results
|
||||
List<CompilationSubResult> subResults = new ArrayList<>();
|
||||
List<Future<CompilationSubResult>> futs = new ArrayList<>();
|
||||
ExecutorService exec = Executors.newFixedThreadPool(concurrentCompiles ? compilationCalls.size() : 1);
|
||||
for (Callable<CompilationSubResult> compilationCall : compilationCalls) {
|
||||
futs.add(exec.submit(compilationCall));
|
||||
}
|
||||
for (Future<CompilationSubResult> fut : futs) {
|
||||
try {
|
||||
subResults.add(fut.get());
|
||||
} catch (ExecutionException ee) {
|
||||
Log.error("Compilation failed: " + ee.getMessage());
|
||||
} catch (InterruptedException ee) {
|
||||
Log.error("Compilation interrupted: " + ee.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
if (concurrentCompiles) {
|
||||
// If there are background threads for the concurrent compiles, then join them.
|
||||
for (int i=0; i<numCompiles; ++i) {
|
||||
try { requests[i].join(); } catch (InterruptedException e) { }
|
||||
exec.shutdownNow();
|
||||
|
||||
// Process each sub result
|
||||
for (CompilationSubResult subResult : subResults) {
|
||||
for (String pkg : subResult.packageArtifacts.keySet()) {
|
||||
Set<URI> pkgArtifacts = subResult.packageArtifacts.get(pkg);
|
||||
packageArtifacts.merge(pkg, pkgArtifacts, Util::union);
|
||||
}
|
||||
|
||||
for (String pkg : subResult.packageDependencies.keySet()) {
|
||||
packageDependencies.putIfAbsent(pkg, new HashMap<>());
|
||||
packageDependencies.get(pkg).putAll(subResult.packageDependencies.get(pkg));
|
||||
}
|
||||
|
||||
for (String pkg : subResult.packageCpDependencies.keySet()) {
|
||||
packageCpDependencies.putIfAbsent(pkg, new HashMap<>());
|
||||
packageCpDependencies.get(pkg).putAll(subResult.packageCpDependencies.get(pkg));
|
||||
}
|
||||
|
||||
for (String pkg : subResult.packagePubapis.keySet()) {
|
||||
packagePubapis.merge(pkg, subResult.packagePubapis.get(pkg), PubApi::mergeTypes);
|
||||
}
|
||||
|
||||
for (String pkg : subResult.dependencyPubapis.keySet()) {
|
||||
dependencyPubapis.merge(pkg, subResult.dependencyPubapis.get(pkg), PubApi::mergeTypes);
|
||||
}
|
||||
|
||||
// Check the return values.
|
||||
if (subResult.returnCode != 0) {
|
||||
rc = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check the return values.
|
||||
for (int i=0; i<numCompiles; ++i) {
|
||||
if (compileChunks[i].srcs.size() > 0) {
|
||||
if (rn[i].returnCode != 0) {
|
||||
Log.info(rn[i].stdout);
|
||||
Log.error(rn[i].stderr);
|
||||
rc = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
long duration = System.currentTimeMillis() - start;
|
||||
long minutes = duration/60000;
|
||||
long seconds = (duration-minutes*60000)/1000;
|
||||
@ -304,6 +293,16 @@ public class CompileJavaPackages implements Transformer {
|
||||
return rc;
|
||||
}
|
||||
|
||||
private void safeWrite(String str, Writer w) {
|
||||
if (str.length() > 0) {
|
||||
try {
|
||||
w.write(str);
|
||||
} catch (IOException e) {
|
||||
Log.error("Could not print compilation output.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Split up the sources into compile chunks. If old package dependents information
|
||||
* is available, sort the order of the chunks into the most dependent first!
|
||||
|
||||
@ -85,8 +85,8 @@ public class CompileProperties implements Transformer {
|
||||
int debugLevel,
|
||||
boolean incremental,
|
||||
int numCores,
|
||||
PrintStream out,
|
||||
PrintStream err) {
|
||||
Writer out,
|
||||
Writer err) {
|
||||
boolean rc = true;
|
||||
for (String pkgName : pkgSrcs.keySet()) {
|
||||
String pkgNameF = Util.toFileSystemPath(pkgName);
|
||||
|
||||
@ -31,7 +31,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Writer;
|
||||
import java.net.URI;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -72,8 +72,8 @@ public class CopyFile implements Transformer {
|
||||
int debugLevel,
|
||||
boolean incremental,
|
||||
int numCores,
|
||||
PrintStream out,
|
||||
PrintStream err)
|
||||
Writer out,
|
||||
Writer err)
|
||||
{
|
||||
boolean rc = true;
|
||||
String dest_filename;
|
||||
|
||||
@ -31,7 +31,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Writer;
|
||||
import java.net.URI;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -131,12 +131,12 @@ public class JavacState {
|
||||
private CompileJavaPackages compileJavaPackages = new CompileJavaPackages();
|
||||
|
||||
// Where to send stdout and stderr.
|
||||
private PrintStream out, err;
|
||||
private Writer out, err;
|
||||
|
||||
// Command line options.
|
||||
private Options options;
|
||||
|
||||
JavacState(Options op, boolean removeJavacState, PrintStream o, PrintStream e) {
|
||||
JavacState(Options op, boolean removeJavacState, Writer o, Writer e) {
|
||||
options = op;
|
||||
out = o;
|
||||
err = e;
|
||||
@ -311,7 +311,7 @@ public class JavacState {
|
||||
/**
|
||||
* Load a javac_state file.
|
||||
*/
|
||||
public static JavacState load(Options options, PrintStream out, PrintStream err) {
|
||||
public static JavacState load(Options options, Writer out, Writer err) {
|
||||
JavacState db = new JavacState(options, false, out, err);
|
||||
Module lastModule = null;
|
||||
Package lastPackage = null;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,8 @@
|
||||
|
||||
package com.sun.tools.sjavac;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Utility class only for sjavac logging.
|
||||
@ -37,7 +38,7 @@ import java.io.PrintStream;
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class Log {
|
||||
private static PrintStream out, err;
|
||||
private static PrintWriter out, err;
|
||||
|
||||
public final static int WARN = 1;
|
||||
public final static int INFO = 2;
|
||||
@ -71,9 +72,9 @@ public class Log {
|
||||
err.println(msg);
|
||||
}
|
||||
|
||||
static public void initializeLog(PrintStream o, PrintStream e) {
|
||||
out = o;
|
||||
err = e;
|
||||
static public void initializeLog(Writer o, Writer e) {
|
||||
out = new PrintWriter(o);
|
||||
err = new PrintWriter(e);
|
||||
}
|
||||
|
||||
static public void setLogLevel(String l) {
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
package com.sun.tools.sjavac;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.Writer;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -97,8 +97,8 @@ public interface Transformer {
|
||||
int debugLevel,
|
||||
boolean incremental,
|
||||
int numCores,
|
||||
PrintStream out,
|
||||
PrintStream err);
|
||||
Writer out,
|
||||
Writer err);
|
||||
|
||||
void setExtra(String e);
|
||||
void setExtra(Options args);
|
||||
|
||||
@ -25,13 +25,14 @@
|
||||
|
||||
package com.sun.tools.sjavac.client;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import com.sun.tools.sjavac.AutoFlushWriter;
|
||||
import com.sun.tools.sjavac.Log;
|
||||
import com.sun.tools.sjavac.Util;
|
||||
import com.sun.tools.sjavac.comp.SjavacImpl;
|
||||
import com.sun.tools.sjavac.options.Options;
|
||||
import com.sun.tools.sjavac.server.CompilationResult;
|
||||
import com.sun.tools.sjavac.server.Sjavac;
|
||||
|
||||
/**
|
||||
@ -43,10 +44,12 @@ import com.sun.tools.sjavac.server.Sjavac;
|
||||
public class ClientMain {
|
||||
|
||||
public static int run(String[] args) {
|
||||
return run(args, System.out, System.err);
|
||||
return run(args,
|
||||
new AutoFlushWriter(new OutputStreamWriter(System.out)),
|
||||
new AutoFlushWriter(new OutputStreamWriter(System.err)));
|
||||
}
|
||||
|
||||
public static int run(String[] args, PrintStream out, PrintStream err) {
|
||||
public static int run(String[] args, Writer out, Writer err) {
|
||||
|
||||
Log.initializeLog(out, err);
|
||||
|
||||
@ -78,14 +81,11 @@ public class ClientMain {
|
||||
sjavac = new SjavacImpl();
|
||||
}
|
||||
|
||||
CompilationResult cr = sjavac.compile(args);
|
||||
|
||||
out.print(cr.stdout);
|
||||
err.print(cr.stderr);
|
||||
int rc = sjavac.compile(args, out, err);
|
||||
|
||||
if (!background)
|
||||
sjavac.shutdown();
|
||||
|
||||
return cr.returnCode;
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,11 +25,14 @@
|
||||
|
||||
package com.sun.tools.sjavac.client;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
@ -43,7 +46,6 @@ import com.sun.tools.sjavac.Util;
|
||||
import com.sun.tools.sjavac.options.OptionHelper;
|
||||
import com.sun.tools.sjavac.options.Options;
|
||||
import com.sun.tools.sjavac.server.CompilationSubResult;
|
||||
import com.sun.tools.sjavac.server.CompilationResult;
|
||||
import com.sun.tools.sjavac.server.PortFile;
|
||||
import com.sun.tools.sjavac.server.Sjavac;
|
||||
import com.sun.tools.sjavac.server.SjavacServer;
|
||||
@ -119,29 +121,47 @@ public class SjavacClient implements Sjavac {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilationResult compile(String[] args) {
|
||||
CompilationResult result;
|
||||
public int compile(String[] args, Writer stdout, Writer stderr) {
|
||||
int result = -1;
|
||||
try (Socket socket = tryConnect()) {
|
||||
// The ObjectInputStream constructor will block until the
|
||||
// corresponding ObjectOutputStream has written and flushed the
|
||||
// header, so it is important that the ObjectOutputStreams on server
|
||||
// and client are opened before the ObjectInputStreams.
|
||||
ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
|
||||
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
|
||||
oos.writeObject(id);
|
||||
oos.writeObject(SjavacServer.CMD_COMPILE);
|
||||
oos.writeObject(args);
|
||||
oos.flush();
|
||||
result = (CompilationResult) ois.readObject();
|
||||
} catch (IOException | ClassNotFoundException ex) {
|
||||
Log.error("[CLIENT] Exception caught: " + ex);
|
||||
result = new CompilationResult(CompilationSubResult.ERROR_FATAL);
|
||||
result.stderr = Util.getStackTrace(ex);
|
||||
PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
// Send args array to server
|
||||
out.println(args.length);
|
||||
for (String arg : args)
|
||||
out.println(arg);
|
||||
out.flush();
|
||||
|
||||
// Read server response line by line
|
||||
String line;
|
||||
while (null != (line = in.readLine())) {
|
||||
String[] typeAndContent = line.split(":", 2);
|
||||
String type = typeAndContent[0];
|
||||
String content = typeAndContent[1];
|
||||
switch (type) {
|
||||
case SjavacServer.LINE_TYPE_STDOUT:
|
||||
stdout.write(content);
|
||||
stdout.write('\n');
|
||||
break;
|
||||
case SjavacServer.LINE_TYPE_STDERR:
|
||||
stderr.write(content);
|
||||
stderr.write('\n');
|
||||
break;
|
||||
case SjavacServer.LINE_TYPE_RC:
|
||||
result = Integer.parseInt(content);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
Log.error("[CLIENT] Exception caught: " + ioe);
|
||||
result = CompilationSubResult.ERROR_FATAL;
|
||||
ioe.printStackTrace(new PrintWriter(stderr));
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt(); // Restore interrupt
|
||||
Log.error("[CLIENT] compile interrupted.");
|
||||
result = new CompilationResult(CompilationSubResult.ERROR_FATAL);
|
||||
result.stderr = Util.getStackTrace(ie);
|
||||
result = CompilationSubResult.ERROR_FATAL;
|
||||
ie.printStackTrace(new PrintWriter(stderr));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -24,13 +24,13 @@
|
||||
*/
|
||||
package com.sun.tools.sjavac.comp;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.sun.tools.sjavac.Log;
|
||||
import com.sun.tools.sjavac.server.CompilationResult;
|
||||
import com.sun.tools.sjavac.server.Sjavac;
|
||||
|
||||
/**
|
||||
@ -54,10 +54,10 @@ public class PooledSjavac implements Sjavac {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilationResult compile(String[] args) {
|
||||
public int compile(String[] args, Writer out, Writer err) {
|
||||
try {
|
||||
return pool.submit(() -> {
|
||||
return delegate.compile(args);
|
||||
return delegate.compile(args, out, err);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@ -24,12 +24,9 @@
|
||||
*/
|
||||
package com.sun.tools.sjavac.comp;
|
||||
|
||||
import static com.sun.tools.sjavac.server.CompilationResult.ERROR_FATAL;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
@ -49,7 +46,6 @@ import com.sun.tools.sjavac.Transformer;
|
||||
import com.sun.tools.sjavac.Util;
|
||||
import com.sun.tools.sjavac.options.Options;
|
||||
import com.sun.tools.sjavac.options.SourceLocation;
|
||||
import com.sun.tools.sjavac.server.CompilationResult;
|
||||
import com.sun.tools.sjavac.server.Sjavac;
|
||||
|
||||
/**
|
||||
@ -64,39 +60,33 @@ import com.sun.tools.sjavac.server.Sjavac;
|
||||
public class SjavacImpl implements Sjavac {
|
||||
|
||||
@Override
|
||||
public CompilationResult compile(String[] args) {
|
||||
|
||||
ByteArrayOutputStream outBaos = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream errBaos = new ByteArrayOutputStream();
|
||||
PrintStream out = new PrintStream(outBaos);
|
||||
PrintStream err = new PrintStream(errBaos);
|
||||
|
||||
public int compile(String[] args, Writer out, Writer err) {
|
||||
Options options;
|
||||
try {
|
||||
options = Options.parseArgs(args);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.error(e.getMessage());
|
||||
return new CompilationResult(ERROR_FATAL);
|
||||
return RC_FATAL;
|
||||
}
|
||||
|
||||
Log.setLogLevel(options.getLogLevel());
|
||||
|
||||
if (!validateOptions(options))
|
||||
return new CompilationResult(ERROR_FATAL);
|
||||
return RC_FATAL;
|
||||
|
||||
if (!createIfMissing(options.getDestDir()))
|
||||
return new CompilationResult(ERROR_FATAL);
|
||||
return RC_FATAL;
|
||||
|
||||
if (!createIfMissing(options.getStateDir()))
|
||||
return new CompilationResult(ERROR_FATAL);
|
||||
return RC_FATAL;
|
||||
|
||||
Path gensrc = options.getGenSrcDir();
|
||||
if (gensrc != null && !createIfMissing(gensrc))
|
||||
return new CompilationResult(ERROR_FATAL);
|
||||
return RC_FATAL;
|
||||
|
||||
Path hdrdir = options.getHeaderDir();
|
||||
if (hdrdir != null && !createIfMissing(hdrdir))
|
||||
return new CompilationResult(ERROR_FATAL);
|
||||
return RC_FATAL;
|
||||
|
||||
// Load the prev build state database.
|
||||
JavacState javac_state = JavacState.load(options, out, err);
|
||||
@ -132,9 +122,7 @@ public class SjavacImpl implements Sjavac {
|
||||
|
||||
if (sources.isEmpty()) {
|
||||
Log.error("Found nothing to compile!");
|
||||
return new CompilationResult(CompilationResult.ERROR_FATAL,
|
||||
new String(outBaos.toByteArray(), UTF_8),
|
||||
new String(errBaos.toByteArray(), UTF_8));
|
||||
return RC_FATAL;
|
||||
}
|
||||
|
||||
|
||||
@ -251,19 +239,13 @@ public class SjavacImpl implements Sjavac {
|
||||
javac_state.removeSuperfluousArtifacts(recently_compiled);
|
||||
}
|
||||
|
||||
return new CompilationResult(rc[0] ? 0 : ERROR_FATAL,
|
||||
new String(outBaos.toByteArray(), UTF_8),
|
||||
new String(errBaos.toByteArray(), UTF_8));
|
||||
return rc[0] ? RC_OK : RC_FATAL;
|
||||
} catch (ProblemException e) {
|
||||
Log.error(e.getMessage());
|
||||
return new CompilationResult(ERROR_FATAL,
|
||||
new String(outBaos.toByteArray(), UTF_8),
|
||||
new String(errBaos.toByteArray(), UTF_8));
|
||||
return RC_FATAL;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(err);
|
||||
return new CompilationResult(ERROR_FATAL,
|
||||
new String(outBaos.toByteArray(), UTF_8),
|
||||
new String(errBaos.toByteArray(), UTF_8));
|
||||
e.printStackTrace(new PrintWriter(err));
|
||||
return RC_FATAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
*/
|
||||
package com.sun.tools.sjavac.server;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
@ -60,10 +61,10 @@ public class IdleResetSjavac implements Sjavac {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilationResult compile(String[] args) {
|
||||
public int compile(String[] args, Writer out, Writer err) {
|
||||
startCall();
|
||||
try {
|
||||
return delegate.compile(args);
|
||||
return delegate.compile(args, out, err);
|
||||
} finally {
|
||||
endCall();
|
||||
}
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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 com.sun.tools.sjavac.server;
|
||||
|
||||
import java.io.FilterWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Inserts {@literal prefix} in front of each line written.
|
||||
*
|
||||
* A line is considered to be terminated by any one of a line feed, a carriage
|
||||
* return, or a carriage return followed immediately by a line feed.
|
||||
*/
|
||||
public class LinePrefixFilterWriter extends FilterWriter {
|
||||
|
||||
private final String prefix;
|
||||
private boolean atBeginningOfLine = true;
|
||||
private char lastChar = '\0';
|
||||
|
||||
protected LinePrefixFilterWriter(Writer out, String prefix) {
|
||||
super(out);
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(String str, int off, int len) throws IOException {
|
||||
for (int i = 0; i < len; i++) {
|
||||
write(str.charAt(off + i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(char[] cbuf, int off, int len) throws IOException {
|
||||
for (int i = 0; i < len; i++) {
|
||||
write(cbuf[off + i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int c) throws IOException {
|
||||
if (lastChar == '\r' && c == '\n') {
|
||||
// Second character of CR+LF sequence.
|
||||
// Do nothing. We already started a new line on last character.
|
||||
} else {
|
||||
if (atBeginningOfLine) {
|
||||
super.write(prefix, 0, prefix.length());
|
||||
}
|
||||
super.write(c);
|
||||
atBeginningOfLine = c == '\r' || c == '\n';
|
||||
}
|
||||
lastChar = (char) c;
|
||||
}
|
||||
}
|
||||
@ -24,15 +24,21 @@
|
||||
*/
|
||||
package com.sun.tools.sjavac.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import static com.sun.tools.sjavac.server.SjavacServer.LINE_TYPE_RC;
|
||||
import static com.sun.tools.sjavac.server.SjavacServer.LINE_TYPE_STDERR;
|
||||
import static com.sun.tools.sjavac.server.SjavacServer.LINE_TYPE_STDOUT;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.Socket;
|
||||
|
||||
import com.sun.tools.sjavac.AutoFlushWriter;
|
||||
import com.sun.tools.sjavac.Log;
|
||||
|
||||
|
||||
/**
|
||||
* A RequestHandler handles requests performed over a socket. Specifically it
|
||||
* - Reads the command string specifying which method is to be invoked
|
||||
@ -61,15 +67,26 @@ public class RequestHandler implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try (ObjectOutputStream oout = new ObjectOutputStream(socket.getOutputStream());
|
||||
ObjectInputStream oin = new ObjectInputStream(socket.getInputStream())) {
|
||||
String id = (String) oin.readObject();
|
||||
String cmd = (String) oin.readObject();
|
||||
Log.info("Handling request, id: " + id + " cmd: " + cmd);
|
||||
switch (cmd) {
|
||||
case SjavacServer.CMD_COMPILE: handleCompileRequest(oin, oout); break;
|
||||
default: Log.error("Unknown command: " + cmd);
|
||||
try (BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
PrintWriter out = new PrintWriter(socket.getOutputStream(), true)) {
|
||||
|
||||
// Read argument array
|
||||
int n = Integer.parseInt(in.readLine());
|
||||
String[] args = new String[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
args[i] = in.readLine();
|
||||
}
|
||||
|
||||
// Perform compilation
|
||||
Writer stdout = new LinePrefixFilterWriter(new AutoFlushWriter(out), LINE_TYPE_STDOUT + ":");
|
||||
Writer stderr = new LinePrefixFilterWriter(new AutoFlushWriter(out), LINE_TYPE_STDERR + ":");
|
||||
int rc = sjavac.compile(args, stdout, stderr);
|
||||
stdout.flush();
|
||||
stderr.flush();
|
||||
|
||||
// Send return code back to client
|
||||
out.println(LINE_TYPE_RC + ":" + rc);
|
||||
|
||||
} catch (Exception ex) {
|
||||
// Not much to be done at this point. The client side request
|
||||
// code will most likely throw an IOException and the
|
||||
@ -79,21 +96,4 @@ public class RequestHandler implements Runnable {
|
||||
Log.error(sw.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCompileRequest(ObjectInputStream oin,
|
||||
ObjectOutputStream oout) throws IOException {
|
||||
try {
|
||||
// Read request arguments
|
||||
String[] args = (String[]) oin.readObject();
|
||||
|
||||
// Perform compilation
|
||||
CompilationResult cr = sjavac.compile(args);
|
||||
|
||||
// Write request response
|
||||
oout.writeObject(cr);
|
||||
oout.flush();
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
throw new IOException(cnfe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
package com.sun.tools.sjavac.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
import com.sun.tools.sjavac.Log;
|
||||
|
||||
@ -38,7 +39,8 @@ import com.sun.tools.sjavac.Log;
|
||||
public class ServerMain {
|
||||
public static int run(String[] args) {
|
||||
|
||||
Log.initializeLog(System.out, System.err);
|
||||
Log.initializeLog(new OutputStreamWriter(System.out),
|
||||
new OutputStreamWriter(System.err));
|
||||
|
||||
// Any options other than --startserver?
|
||||
if (args.length > 1) {
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
*/
|
||||
package com.sun.tools.sjavac.server;
|
||||
|
||||
import java.io.Writer;
|
||||
|
||||
|
||||
/**
|
||||
* Interface of the SjavacImpl, the sjavac client and all wrappers such as
|
||||
@ -35,6 +37,10 @@ package com.sun.tools.sjavac.server;
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public interface Sjavac {
|
||||
CompilationResult compile(String[] args);
|
||||
|
||||
final static int RC_FATAL = -1;
|
||||
final static int RC_OK = 0;
|
||||
|
||||
int compile(String[] args, Writer stdout, Writer stderr);
|
||||
void shutdown();
|
||||
}
|
||||
|
||||
@ -53,8 +53,10 @@ import com.sun.tools.sjavac.comp.SjavacImpl;
|
||||
*/
|
||||
public class SjavacServer implements Terminable {
|
||||
|
||||
// Used in protocol to indicate which method to invoke
|
||||
public final static String CMD_COMPILE = "compile";
|
||||
// Used in protocol to tell the content of each line
|
||||
public final static String LINE_TYPE_RC = "RC";
|
||||
public final static String LINE_TYPE_STDOUT = "STDOUT";
|
||||
public final static String LINE_TYPE_STDERR = "STDERR";
|
||||
|
||||
final private String portfilename;
|
||||
final private String logfile;
|
||||
|
||||
@ -31,8 +31,12 @@ import com.sun.source.util.TaskEvent.Kind;
|
||||
import com.sun.source.util.TaskListener;
|
||||
import com.sun.source.util.TreeScanner;
|
||||
import com.sun.tools.javac.api.MultiTaskListener;
|
||||
import com.sun.tools.javac.code.Kinds;
|
||||
import com.sun.tools.javac.code.Symbol;
|
||||
import com.sun.tools.javac.code.Symtab;
|
||||
import com.sun.tools.javac.code.Type;
|
||||
import com.sun.tools.javac.code.Type.ClassType;
|
||||
import com.sun.tools.javac.code.TypeTag;
|
||||
import com.sun.tools.javac.code.Types;
|
||||
import com.sun.tools.javac.comp.Check;
|
||||
import com.sun.tools.javac.comp.CompileStates;
|
||||
@ -93,23 +97,46 @@ class ReusableContext extends Context implements TaskListener {
|
||||
|
||||
//find if any of the roots have redefined java.* classes
|
||||
Symtab syms = Symtab.instance(this);
|
||||
new TreeScanner<Void, Void>() {
|
||||
@Override
|
||||
public Void visitClass(ClassTree node, Void aVoid) {
|
||||
Symbol sym = ((JCClassDecl)node).sym;
|
||||
if (sym != null) {
|
||||
syms.classes.remove(sym.flatName());
|
||||
if (sym.flatName().toString().startsWith("java.")) {
|
||||
polluted = true;
|
||||
}
|
||||
}
|
||||
return super.visitClass(node, aVoid);
|
||||
}
|
||||
}.scan(roots, null);
|
||||
pollutionScanner.scan(roots, syms);
|
||||
roots.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This scanner detects as to whether the shared context has been polluted. This happens
|
||||
* whenever a compiled program redefines a core class (in 'java.*' package) or when
|
||||
* (typically because of cyclic inheritance) the symbol kind of a core class has been touched.
|
||||
*/
|
||||
TreeScanner<Void, Symtab> pollutionScanner = new TreeScanner<Void, Symtab>() {
|
||||
@Override
|
||||
public Void visitClass(ClassTree node, Symtab syms) {
|
||||
Symbol sym = ((JCClassDecl)node).sym;
|
||||
if (sym != null) {
|
||||
syms.classes.remove(sym.flatName());
|
||||
Type sup = supertype(sym);
|
||||
if (isCoreClass(sym) ||
|
||||
(sup != null && isCoreClass(sup.tsym) && sup.tsym.kind != Kinds.Kind.TYP)) {
|
||||
polluted = true;
|
||||
}
|
||||
}
|
||||
return super.visitClass(node, syms);
|
||||
}
|
||||
|
||||
private boolean isCoreClass(Symbol s) {
|
||||
return s.flatName().toString().startsWith("java.");
|
||||
}
|
||||
|
||||
private Type supertype(Symbol s) {
|
||||
if (s.type == null ||
|
||||
!s.type.hasTag(TypeTag.CLASS)) {
|
||||
return null;
|
||||
} else {
|
||||
ClassType ct = (ClassType)s.type;
|
||||
return ct.supertype_field;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void finished(TaskEvent e) {
|
||||
if (e.getKind() == Kind.PARSE) {
|
||||
|
||||
@ -56,6 +56,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
@ -76,6 +77,7 @@ import javax.lang.model.element.TypeParameterElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.JavaFileObject.Kind;
|
||||
@ -88,7 +90,6 @@ import com.sun.tools.classfile.ConstantPoolException;
|
||||
import com.sun.tools.javac.api.JavacTaskImpl;
|
||||
import com.sun.tools.javac.code.Symbol.CompletionFailure;
|
||||
import com.sun.tools.javac.platform.PlatformProvider;
|
||||
import com.sun.tools.javac.util.ServiceLoader;
|
||||
|
||||
/**To generate the hash values for version N, invoke this class like:
|
||||
*
|
||||
@ -243,7 +244,11 @@ public class ElementStructureTest {
|
||||
}
|
||||
|
||||
void run(Writer output, String version) throws Exception {
|
||||
JavacTaskImpl task = (JavacTaskImpl) ToolProvider.getSystemJavaCompiler().getTask(null, null, null, Arrays.asList("-release", version), null, Arrays.asList(new ToolBox.JavaSource("Test", "")));
|
||||
List<String> options = Arrays.asList("-release", version, "-classpath", "");
|
||||
List<ToolBox.JavaSource> files = Arrays.asList(new ToolBox.JavaSource("Test", ""));
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
JavacTaskImpl task = (JavacTaskImpl) compiler.getTask(null, null, null, options, null, files);
|
||||
|
||||
task.parse();
|
||||
|
||||
JavaFileManager fm = task.getContext().get(JavaFileManager.class);
|
||||
|
||||
@ -29,9 +29,9 @@
|
||||
* @build Wrapper
|
||||
* @run main Wrapper IdleShutdown
|
||||
*/
|
||||
import java.io.Writer;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import com.sun.tools.sjavac.server.CompilationResult;
|
||||
import com.sun.tools.sjavac.server.IdleResetSjavac;
|
||||
import com.sun.tools.sjavac.server.Sjavac;
|
||||
import com.sun.tools.sjavac.server.Terminable;
|
||||
@ -65,11 +65,11 @@ public class IdleShutdown {
|
||||
// Use Sjavac object and wait less than TIMEOUT_MS in between calls
|
||||
Thread.sleep(TIMEOUT_MS - 1000);
|
||||
log("Compiling");
|
||||
service.compile(new String[0]);
|
||||
service.compile(new String[0], null, null);
|
||||
|
||||
Thread.sleep(TIMEOUT_MS - 1000);
|
||||
log("Compiling");
|
||||
service.compile(new String[0]);
|
||||
service.compile(new String[0], null, null);
|
||||
|
||||
if (timeoutTimestamp.get() != -1)
|
||||
throw new AssertionError("Premature timeout detected.");
|
||||
@ -103,13 +103,13 @@ public class IdleShutdown {
|
||||
public void shutdown() {
|
||||
}
|
||||
@Override
|
||||
public CompilationResult compile(String[] args) {
|
||||
public int compile(String[] args, Writer out, Writer err) {
|
||||
// Attempt to trigger idle timeout during a call by sleeping
|
||||
try {
|
||||
Thread.sleep(TIMEOUT_MS + 1000);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,11 +30,11 @@
|
||||
* @build Wrapper
|
||||
* @run main Wrapper PooledExecution
|
||||
*/
|
||||
import java.io.Writer;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.sun.tools.sjavac.comp.PooledSjavac;
|
||||
import com.sun.tools.sjavac.server.CompilationResult;
|
||||
import com.sun.tools.sjavac.server.Sjavac;
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ public class PooledExecution {
|
||||
for (int i = 0; i < NUM_REQUESTS; i++) {
|
||||
tasks[i] = new Thread() {
|
||||
public void run() {
|
||||
service.compile(new String[0]);
|
||||
service.compile(new String[0], null, null);
|
||||
tasksFinished.incrementAndGet();
|
||||
}
|
||||
};
|
||||
@ -109,7 +109,7 @@ public class PooledExecution {
|
||||
AtomicInteger activeRequests = new AtomicInteger(0);
|
||||
|
||||
@Override
|
||||
public CompilationResult compile(String[] args) {
|
||||
public int compile(String[] args, Writer out, Writer err) {
|
||||
leftToStart.countDown();
|
||||
int numActiveRequests = activeRequests.incrementAndGet();
|
||||
System.out.printf("Left to start: %2d / Currently active: %2d%n",
|
||||
@ -123,7 +123,7 @@ public class PooledExecution {
|
||||
}
|
||||
activeRequests.decrementAndGet();
|
||||
System.out.println("Task completed");
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -534,8 +534,7 @@ define SetupModuleCompilation
|
||||
## Service types are required in the classpath when compiing module-info
|
||||
$1_CLASSPATH := $$($1_CLASSPATH) $$(addprefix $(JDK_OUTPUTDIR)/modules/,jdk.hotspot.agent)
|
||||
endif
|
||||
$1_CLASSPATH := $$(subst $$(SPACE),$$(PATH_SEP),$$($1_CLASSPATH))
|
||||
$1_JAVAC_FLAGS := -bootclasspath $(EMPTY_DIR) -extdirs $(EMPTY_DIR) -endorseddirs $(EMPTY_DIR) -classpath "$$($1_CLASSPATH)" $$($1_ADD_JAVAC_FLAGS)
|
||||
$1_JAVAC_FLAGS := -bootclasspath $(EMPTY_DIR) -extdirs $(EMPTY_DIR) -endorseddirs $(EMPTY_DIR) $$($1_ADD_JAVAC_FLAGS)
|
||||
|
||||
$$(eval $$(call SetupJavaCompilation,$1, \
|
||||
SETUP := $$(if $$($1_SETUP), $$($1_SETUP), GENERATE_JDKBYTECODE), \
|
||||
@ -543,6 +542,7 @@ define SetupModuleCompilation
|
||||
INCLUDES := $(JDK_USER_DEFINED_FILTER),\
|
||||
BIN := $$(if $$($1_BIN), $$($1_BIN), $(JDK_OUTPUTDIR)/modules/$1), \
|
||||
HEADERS := $(SUPPORT_OUTPUTDIR)/headers/$1, \
|
||||
CLASSPATH := $$($1_CLASSPATH), \
|
||||
ADD_JAVAC_FLAGS := $$($1_ADD_JAVAC_FLAGS) $$($1_JAVAC_FLAGS)))
|
||||
|
||||
$1: $$($1) $$($1_COPY_EXTRA)
|
||||
|
||||
@ -50,7 +50,7 @@ ifeq ($(HAS_SPEC),)
|
||||
include $(topdir)/make/Help.gmk
|
||||
|
||||
# Targets provided by Init.gmk.
|
||||
ALL_INIT_TARGETS := print-modules print-targets reconfigure
|
||||
ALL_INIT_TARGETS := print-modules print-targets print-configuration reconfigure
|
||||
|
||||
# CALLED_TARGETS is the list of targets that the user provided,
|
||||
# or "default" if unspecified.
|
||||
@ -228,6 +228,9 @@ else # HAS_SPEC=true
|
||||
$(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \
|
||||
NO_RECIPES=true print-targets )
|
||||
|
||||
print-configuration:
|
||||
$(ECHO) $(CONFIGURE_COMMAND_LINE)
|
||||
|
||||
reconfigure:
|
||||
ifneq ($(CONFIGURE_COMMAND_LINE), )
|
||||
$(ECHO) "Re-running configure using arguments '$(CONFIGURE_COMMAND_LINE)'"
|
||||
|
||||
@ -403,6 +403,7 @@ endef
|
||||
# SRC:=one or more directories to search for sources. The order of the source roots
|
||||
# is significant. The first found file of a certain name has priority.
|
||||
# BIN:=store classes here
|
||||
# CLASSPATH:=a list of additional entries to set as classpath to javac
|
||||
# INCLUDES:=myapp.foo means will only compile java files in myapp.foo or any of its sub-packages.
|
||||
# EXCLUDES:=myapp.foo means will do not compile java files in myapp.foo or any of its sub-packages.
|
||||
# COPY:=.prp means copy all prp files to the corresponding package in BIN.
|
||||
@ -428,6 +429,9 @@ define SetupJavaCompilationBody
|
||||
$1_JVM := $$($$($1_SETUP)_JVM)
|
||||
$1_JAVAC := $$($$($1_SETUP)_JAVAC)
|
||||
$1_FLAGS := $$($$($1_SETUP)_FLAGS) $(JAVAC_FLAGS) $$($1_ADD_JAVAC_FLAGS)
|
||||
ifneq ($$($1_CLASSPATH), )
|
||||
$1_FLAGS += -cp $$(call PathList, $$($1_CLASSPATH))
|
||||
endif
|
||||
ifeq ($$($1_JAVAC),)
|
||||
$$(error The Java compilation $1 refers to a non-existant java compiler setup $$($1_SETUP))
|
||||
endif
|
||||
@ -482,7 +486,7 @@ define SetupJavaCompilationBody
|
||||
$$(addprefix -i ,$$(addsuffix /*,$$($1_INCLUDES))) \
|
||||
$$(addprefix -xf *,$$(strip $$($1_EXCLUDE_FILES) $$($1_SJAVAC_EXCLUDE_FILES))) \
|
||||
$$(addprefix -if *,$$(strip $$($1_INCLUDE_FILES))) \
|
||||
-src "$$(subst $$(SPACE),$$(PATH_SEP),$$(strip $$($1_SRC)))"
|
||||
-src $$(call PathList, $$($1_SRC))
|
||||
|
||||
# All files below META-INF are always copied.
|
||||
$1_ALL_COPIES := $$(filter $$(addsuffix /META-INF%,$$($1_SRC)),$$($1_ALL_SRCS))
|
||||
|
||||
@ -41,6 +41,29 @@ endif
|
||||
# next make invocation.
|
||||
.DELETE_ON_ERROR:
|
||||
|
||||
################################################################################
|
||||
# Definitions for special characters
|
||||
################################################################################
|
||||
|
||||
# When calling macros, the spaces between arguments are
|
||||
# often semantically important! Sometimes we need to subst
|
||||
# spaces and commas, therefore we need the following macros.
|
||||
X:=
|
||||
SPACE:=$(X) $(X)
|
||||
COMMA:=,
|
||||
DOLLAR:=$$
|
||||
HASH:=\#
|
||||
LEFT_PAREN:=(
|
||||
RIGHT_PAREN:=)
|
||||
SQUOTE:='
|
||||
#'
|
||||
DQUOTE:="
|
||||
#"
|
||||
define NEWLINE
|
||||
|
||||
|
||||
endef
|
||||
|
||||
##############################
|
||||
# Functions
|
||||
##############################
|
||||
@ -779,6 +802,14 @@ else
|
||||
$(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
# Return a string suitable for use after a -classpath option. It will correct and safe to use
|
||||
# on all platforms. Arguments are given as space separate classpath entries.
|
||||
# param 1 : A space separated list of classpath entries
|
||||
# The surrounding strip is needed to keep additional whitespace out
|
||||
PathList = \
|
||||
"$(subst $(SPACE),$(PATH_SEP),$(strip $1))"
|
||||
|
||||
################################################################################
|
||||
|
||||
# Hook to include the corresponding custom file, if present.
|
||||
|
||||
@ -624,28 +624,7 @@ define SetupNativeCompilationBody
|
||||
$1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \
|
||||
$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map
|
||||
|
||||
else ifeq ($(OPENJDK_TARGET_OS), solaris)
|
||||
$1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
|
||||
# Setup the command line creating debuginfo files, to be run after linking.
|
||||
# It cannot be run separately since it updates the original target file
|
||||
#
|
||||
# gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
|
||||
# Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from
|
||||
# empty section headers until a fixed $(OBJCOPY) is available.
|
||||
# An empty section header has sh_addr == 0 and sh_size == 0.
|
||||
# This problem has only been seen on Solaris X64, but we call this tool
|
||||
# on all Solaris builds just in case.
|
||||
#
|
||||
# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
|
||||
# Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
|
||||
$1_CREATE_DEBUGINFO_CMDS := \
|
||||
$(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$($1_TARGET) $$(NEWLINE) \
|
||||
$(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
|
||||
$(CD) $$($1_OUTPUT_DIR) && \
|
||||
$(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$($1_DEBUGINFO_FILES) $$($1_TARGET)
|
||||
$1_DEBUGINFO_EXTRA_DEPS := $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK)
|
||||
|
||||
else ifeq ($(OPENJDK_TARGET_OS), linux)
|
||||
else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
|
||||
$1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
|
||||
# Setup the command line creating debuginfo files, to be run after linking.
|
||||
# It cannot be run separately since it updates the original target file
|
||||
@ -653,7 +632,6 @@ define SetupNativeCompilationBody
|
||||
$(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
|
||||
$(CD) $$($1_OUTPUT_DIR) && \
|
||||
$(OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
|
||||
|
||||
endif # No MacOS X support
|
||||
|
||||
# This dependency dance ensures that debug info files get rebuilt
|
||||
@ -694,7 +672,7 @@ define SetupNativeCompilationBody
|
||||
$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
|
||||
|
||||
$$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) \
|
||||
$$($1_DEBUGINFO_EXTRA_DEPS) $$($1_VARDEPS_FILE)
|
||||
$$($1_VARDEPS_FILE)
|
||||
$(ECHO) $(LOG_INFO) "Linking $$($1_BASENAME)"
|
||||
$(call LogFailures, $$($1_OBJECT_DIR)/$1_link.log, $1_link, \
|
||||
$$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
|
||||
@ -735,7 +713,7 @@ define SetupNativeCompilationBody
|
||||
$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
|
||||
|
||||
$$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_MANIFEST) \
|
||||
$$($1_DEBUGINFO_EXTRA_DEPS) $$($1_VARDEPS_FILE)
|
||||
$$($1_VARDEPS_FILE)
|
||||
$(ECHO) $(LOG_INFO) "Linking executable $$($1_BASENAME)"
|
||||
$(call LogFailures, $$($1_OBJECT_DIR)/$1_link.log, $1_link, \
|
||||
$$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
|
||||
|
||||
@ -78,7 +78,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \
|
||||
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
|
||||
SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
|
||||
|
||||
JDK_BOOTCLASSPATH := $(subst $(SPACE),$(PATH_SEP),\
|
||||
JDK_BOOTCLASSPATH := $(call PathList, \
|
||||
$(filter-out $(JDK_OUTPUTDIR)/modules/_%, $(wildcard $(JDK_OUTPUTDIR)/modules/*)))
|
||||
|
||||
# After the jdk is built, we want to build demos using only the recently
|
||||
@ -88,7 +88,7 @@ JDK_BOOTCLASSPATH := $(subst $(SPACE),$(PATH_SEP),\
|
||||
$(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE, \
|
||||
JVM := $(JAVA_SMALL), \
|
||||
JAVAC := $(NEW_JAVAC), \
|
||||
FLAGS := -bootclasspath "$(JDK_BOOTCLASSPATH)" $(DISABLE_WARNINGS), \
|
||||
FLAGS := -bootclasspath $(JDK_BOOTCLASSPATH) $(DISABLE_WARNINGS), \
|
||||
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
|
||||
SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
|
||||
|
||||
|
||||
@ -32,8 +32,6 @@ endif
|
||||
|
||||
|
||||
include NativeCompilation.gmk
|
||||
# FIXME: This is a bad fix currently needed due to JDK-8064808 not being resolved.
|
||||
include $(JDK_TOPDIR)/make/Tools.gmk
|
||||
|
||||
# Setup make rules for creating a set of native test files (libraries or
|
||||
# executables). This will locate native files matching a certain pattern,
|
||||
|
||||
@ -314,3 +314,4 @@ ab231613d7206431ba31917a02e7cedd70e88e70 jdk9-b76
|
||||
6f634e84387e97b2421d5e776e46935784156d1c jdk9-b78
|
||||
9b3eca69b88b2d1bebce92d58280ae66fc0b6091 jdk9-b79
|
||||
61b401b23fc28208930977d46b690423911173c6 jdk9-b80
|
||||
42d8ed4651b62572b39e6fed3fafcb7ee93f9dc2 jdk9-b81
|
||||
|
||||
@ -54,10 +54,9 @@ import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_FIEL
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_NEWMAP;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_NEWMAP_DESC;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_TYPE;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTIONIMPL_MAKEFUNCTION;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTIONIMPL_MAKEFUNCTION_DESC;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTIONIMPL_MAKEFUNCTION_SPECS_DESC;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTIONIMPL_TYPE;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_CREATEBUILTIN;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_CREATEBUILTIN_DESC;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_CREATEBUILTIN_SPECS_DESC;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETARITY;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETARITY_DESC;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_TYPE;
|
||||
@ -282,9 +281,9 @@ public class ClassGenerator {
|
||||
assert specs != null;
|
||||
if (!specs.isEmpty()) {
|
||||
mi.memberInfoArray(className, specs);
|
||||
mi.invokeStatic(SCRIPTFUNCTIONIMPL_TYPE, SCRIPTFUNCTIONIMPL_MAKEFUNCTION, SCRIPTFUNCTIONIMPL_MAKEFUNCTION_SPECS_DESC);
|
||||
mi.invokeStatic(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_CREATEBUILTIN, SCRIPTFUNCTION_CREATEBUILTIN_SPECS_DESC);
|
||||
} else {
|
||||
mi.invokeStatic(SCRIPTFUNCTIONIMPL_TYPE, SCRIPTFUNCTIONIMPL_MAKEFUNCTION, SCRIPTFUNCTIONIMPL_MAKEFUNCTION_DESC);
|
||||
mi.invokeStatic(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_CREATEBUILTIN, SCRIPTFUNCTION_CREATEBUILTIN_DESC);
|
||||
}
|
||||
|
||||
if (arityFound) {
|
||||
|
||||
@ -38,9 +38,8 @@ import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_FIEL
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROTOTYPEOBJECT_SETCONSTRUCTOR;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROTOTYPEOBJECT_SETCONSTRUCTOR_DESC;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROTOTYPEOBJECT_TYPE;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTIONIMPL_INIT_DESC3;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTIONIMPL_INIT_DESC4;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTIONIMPL_TYPE;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_INIT_DESC3;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_INIT_DESC4;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETARITY;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETARITY_DESC;
|
||||
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTION_SETPROTOTYPE;
|
||||
@ -76,7 +75,7 @@ public class ConstructorGenerator extends ClassGenerator {
|
||||
|
||||
byte[] getClassBytes() {
|
||||
// new class extending from ScriptObject
|
||||
final String superClass = (constructor != null)? SCRIPTFUNCTIONIMPL_TYPE : SCRIPTOBJECT_TYPE;
|
||||
final String superClass = (constructor != null)? SCRIPTFUNCTION_TYPE : SCRIPTOBJECT_TYPE;
|
||||
cw.visit(V1_7, ACC_FINAL, className, null, superClass, null);
|
||||
if (memberCount > 0) {
|
||||
// add fields
|
||||
@ -182,8 +181,8 @@ public class ConstructorGenerator extends ClassGenerator {
|
||||
loadMap(mi);
|
||||
} else {
|
||||
// call Function.<init>
|
||||
superClass = SCRIPTFUNCTIONIMPL_TYPE;
|
||||
superDesc = (memberCount > 0) ? SCRIPTFUNCTIONIMPL_INIT_DESC4 : SCRIPTFUNCTIONIMPL_INIT_DESC3;
|
||||
superClass = SCRIPTFUNCTION_TYPE;
|
||||
superDesc = (memberCount > 0) ? SCRIPTFUNCTION_INIT_DESC4 : SCRIPTFUNCTION_INIT_DESC3;
|
||||
mi.loadLiteral(constructor.getName());
|
||||
mi.visitLdcInsn(new Handle(H_INVOKESTATIC, scriptClassInfo.getJavaName(), constructor.getJavaName(), constructor.getJavaDesc()));
|
||||
loadMap(mi);
|
||||
|
||||
@ -31,10 +31,9 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import jdk.internal.org.objectweb.asm.Type;
|
||||
import jdk.nashorn.internal.objects.PrototypeObject;
|
||||
import jdk.nashorn.internal.objects.ScriptFunctionImpl;
|
||||
import jdk.nashorn.internal.runtime.AccessorProperty;
|
||||
import jdk.nashorn.internal.runtime.PropertyMap;
|
||||
import jdk.nashorn.internal.runtime.PrototypeObject;
|
||||
import jdk.nashorn.internal.runtime.ScriptFunction;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
import jdk.nashorn.internal.runtime.Specialization;
|
||||
@ -88,7 +87,6 @@ public interface StringConstants {
|
||||
static final Type TYPE_PROPERTYMAP = Type.getType(PropertyMap.class);
|
||||
static final Type TYPE_PROTOTYPEOBJECT = Type.getType(PrototypeObject.class);
|
||||
static final Type TYPE_SCRIPTFUNCTION = Type.getType(ScriptFunction.class);
|
||||
static final Type TYPE_SCRIPTFUNCTIONIMPL = Type.getType(ScriptFunctionImpl.class);
|
||||
static final Type TYPE_SCRIPTOBJECT = Type.getType(ScriptObject.class);
|
||||
|
||||
static final String PROTOTYPE_SUFFIX = "$Prototype";
|
||||
@ -122,17 +120,14 @@ public interface StringConstants {
|
||||
static final String SCRIPTFUNCTION_SETARITY_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, Type.INT_TYPE);
|
||||
static final String SCRIPTFUNCTION_SETPROTOTYPE = "setPrototype";
|
||||
static final String SCRIPTFUNCTION_SETPROTOTYPE_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_OBJECT);
|
||||
|
||||
// ScriptFunctionImpl
|
||||
static final String SCRIPTFUNCTIONIMPL_TYPE = TYPE_SCRIPTFUNCTIONIMPL.getInternalName();
|
||||
static final String SCRIPTFUNCTIONIMPL_MAKEFUNCTION = "makeFunction";
|
||||
static final String SCRIPTFUNCTIONIMPL_MAKEFUNCTION_DESC =
|
||||
static final String SCRIPTFUNCTION_CREATEBUILTIN = "createBuiltin";
|
||||
static final String SCRIPTFUNCTION_CREATEBUILTIN_DESC =
|
||||
Type.getMethodDescriptor(TYPE_SCRIPTFUNCTION, TYPE_STRING, TYPE_METHODHANDLE);
|
||||
static final String SCRIPTFUNCTIONIMPL_MAKEFUNCTION_SPECS_DESC =
|
||||
static final String SCRIPTFUNCTION_CREATEBUILTIN_SPECS_DESC =
|
||||
Type.getMethodDescriptor(TYPE_SCRIPTFUNCTION, TYPE_STRING, TYPE_METHODHANDLE, TYPE_SPECIALIZATION_ARRAY);
|
||||
static final String SCRIPTFUNCTIONIMPL_INIT_DESC3 =
|
||||
static final String SCRIPTFUNCTION_INIT_DESC3 =
|
||||
Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_STRING, TYPE_METHODHANDLE, TYPE_SPECIALIZATION_ARRAY);
|
||||
static final String SCRIPTFUNCTIONIMPL_INIT_DESC4 =
|
||||
static final String SCRIPTFUNCTION_INIT_DESC4 =
|
||||
Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_STRING, TYPE_METHODHANDLE, TYPE_PROPERTYMAP, TYPE_SPECIALIZATION_ARRAY);
|
||||
|
||||
// ScriptObject
|
||||
|
||||
@ -31,7 +31,7 @@ include MakeBase.gmk
|
||||
include JavaCompilation.gmk
|
||||
include SetupJavaCompilers.gmk
|
||||
|
||||
JDK_CLASSES := $(subst $(SPACE),$(PATH_SEP),$(strip $(addprefix $(JDK_OUTPUTDIR)/modules/, \
|
||||
JDK_CLASSES := $(call PathList, $(strip $(addprefix $(JDK_OUTPUTDIR)/modules/, \
|
||||
java.base java.logging java.scripting)))
|
||||
|
||||
NASHORN_JAR := $(IMAGES_OUTPUTDIR)/nashorn.jar
|
||||
@ -48,7 +48,7 @@ endif
|
||||
$(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE_DEBUG, \
|
||||
JVM := $(JAVA), \
|
||||
JAVAC := $(NEW_JAVAC), \
|
||||
FLAGS := -g -source 8 -target 8 -bootclasspath "$(JDK_CLASSES)", \
|
||||
FLAGS := -g -source 8 -target 8 -bootclasspath $(JDK_CLASSES), \
|
||||
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
|
||||
SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
|
||||
|
||||
@ -86,7 +86,8 @@ $(NASGEN_RUN_FILE): $(BUILD_NASGEN)
|
||||
$(RM) -rf $(@D)/jdk $(@D)/netscape
|
||||
$(CP) -R -p $(SUPPORT_OUTPUTDIR)/special_classes/jdk.scripting.nashorn/classes/* $(@D)/
|
||||
$(FIXPATH) $(JAVA) \
|
||||
-Xbootclasspath/p:"$(BUILDTOOLS_OUTPUTDIR)/nasgen_classes$(PATH_SEP)$(SUPPORT_OUTPUTDIR)/special_classes/jdk.scripting.nashorn/classes" \
|
||||
-Xbootclasspath/p:$(call PathList, $(BUILDTOOLS_OUTPUTDIR)/nasgen_classes \
|
||||
$(SUPPORT_OUTPUTDIR)/special_classes/jdk.scripting.nashorn/classes) \
|
||||
jdk.nashorn.internal.tools.nasgen.Main $(@D) jdk.nashorn.internal.objects $(@D)
|
||||
$(TOUCH) $@
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user