This commit is contained in:
Lana Steuck 2015-12-18 09:55:44 -08:00
commit 62ec13944c
177 changed files with 2836 additions and 3222 deletions
jdk
make
src/java.base/share/classes
com/sun
java
jdk/internal/misc
sun

@ -309,7 +309,7 @@ define SetupBuildJvmtiDemoBody
ifeq ($$($1_TOOLCHAIN), TOOLCHAIN_LINK_CXX)
# For C++, we also need some special treatment.
$1_LDFLAGS := $(LDFLAGS_CXX_JDK)
$1_LDFLAGS := $$(LDFLAGS_CXX_JDK)
$1_LIBS := $(LIBCXX)
ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc)
@ -324,9 +324,9 @@ define SetupBuildJvmtiDemoBody
OPTIMIZATION := LOW, \
CFLAGS := $$($1_CFLAGS_INCLUDE) $$(CFLAGS_JDKLIB) $$(CFLAGS_DEBUG_SYMBOLS), \
CXXFLAGS := $$($1_CXXFLAGS), \
LDFLAGS := $(filter-out -incremental:no -opt:ref, $(LDFLAGS_JDKLIB)) \
LDFLAGS := $(filter-out -incremental:no -opt:ref, $$(LDFLAGS_JDKLIB)) \
$$($1_LDFLAGS), \
LDFLAGS_macosx := $(call SET_EXECUTABLE_ORIGIN), \
LDFLAGS_macosx := $$(call SET_EXECUTABLE_ORIGIN), \
LIBS := $$($1_LIBS), \
LIBS_solaris := -lc, \
VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \

@ -127,8 +127,7 @@ ifneq ($(BUILD_JEXEC_SRC), )
$(BUILD_JEXEC_INC), \
CFLAGS_linux := -fPIC, \
CFLAGS_solaris := -KPIC, \
LDFLAGS := $(LDFLAGS_JDKEXE) \
$(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)$(SHARED_LIBRARY_SUFFIX)), \
LDFLAGS := $(LDFLAGS_JDKEXE), \
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/jexec_obj, \
OUTPUT_DIR := $(BUILD_JEXEC_DST_DIR), \
DEBUG_SYMBOLS := true, \

@ -89,7 +89,6 @@ $(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE, \
MAPFILE := $(UNPACK_MAPFILE),\
LDFLAGS := $(UNPACKEXE_ZIPOBJS) \
$(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \
$(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX)) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS := $(UNPACKEXE_LIBS) $(LIBCXX), \
LIBS_solaris := -lc, \

@ -25,6 +25,12 @@
include NativeCompilation.gmk
# SetupNativeCompilation now supports debug symbols on macosx for hotspot.
# Disable it here for the jdk binaries until we decide to enable them.
ifeq ($(OPENJDK_TARGET_OS), macosx)
ENABLE_DEBUG_SYMBOLS := false
endif
# Prepare the find cache.
$(eval $(call FillCacheFind, $(JDK_TOPDIR)/src/java.base/share/native/launcher))
@ -180,15 +186,12 @@ define SetupBuildLauncherBody
CFLAGS_linux := -fPIC, \
CFLAGS_solaris := -KPIC -DHAVE_GETHRTIME, \
CFLAGS_windows := $$($1_CFLAGS_windows), \
LDFLAGS := $(LDFLAGS_JDKEXE) \
LDFLAGS := $$(LDFLAGS_JDKEXE) \
$$(ORIGIN_ARG) \
$$($1_LDFLAGS), \
LDFLAGS_linux := \
$(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)$(SHARED_LIBRARY_SUFFIX)) \
-L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base$(OPENJDK_TARGET_CPU_LIBDIR)/jli, \
LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_NAME,$1), \
LDFLAGS_solaris := $$($1_LDFLAGS_solaris) \
$(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)$(SHARED_LIBRARY_SUFFIX)) \
-L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base$(OPENJDK_TARGET_CPU_LIBDIR)/jli, \
MAPFILE := $$($1_MAPFILE), \
LIBS := $(JDKEXE_LIBS) $$($1_LIBS), \

@ -683,7 +683,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \
WARNINGS_AS_ERRORS_gcc := false, \
WARNINGS_AS_ERRORS_solstudio := false, \
MAPFILE := $(BUILD_LIBFONTMANAGER_MAPFILE), \
LDFLAGS := $(subst -Xlinker -z -Xlinker defs,,$(LDFLAGS_JDKLIB)) $(LDFLAGS_CXX_JDK) \
LDFLAGS := $(subst -Wl$(COMMA)-z$(COMMA)defs,,$(LDFLAGS_JDKLIB)) $(LDFLAGS_CXX_JDK) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
LDFLAGS_macosx := -undefined dynamic_lookup, \
@ -799,7 +799,7 @@ else # OPENJDK_TARGET_OS not windows
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
LDFLAGS_macosx := -Xlinker -rpath -Xlinker @loader_path, \
LDFLAGS_macosx := -Wl$(COMMA)-rpath$(COMMA)@loader_path, \
LIBS_unix := $(JAWT_LIBS) $(JDKLIB_LIBS), \
LIBS_solaris := $(X_LIBS) -lXrender, \
LIBS_macosx := -framework Cocoa, \
@ -1034,7 +1034,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx)
-I$(SUPPORT_OUTPUTDIR)/headers/java.desktop, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN) \
-Xlinker -rpath -Xlinker @loader_path \
-Wl$(COMMA)-rpath$(COMMA)@loader_path \
-L$(INSTALL_LIBRARIES_HERE), \
LIBS := -lawt -losxapp -lawt_lwawt \
-framework Cocoa \

@ -65,7 +65,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBINSTRUMENT, \
-L$(call FindLibDirForModule, java.base)/jli, \
LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/jli) \
-L$(call FindLibDirForModule, java.base)/jli, \
LDFLAGS_macosx := -Xlinker -all_load $(SUPPORT_OUTPUTDIR)/native/java.base/libjli_static.a, \
LDFLAGS_macosx := -Wl$(COMMA)-all_load, \
LDFLAGS_aix := -L$(SUPPORT_OUTPUTDIR)/native/java.base, \
LDFLAGS_windows := -export:Agent_OnAttach, \
LIBS := $(JDKLIB_LIBS), \
@ -74,7 +74,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBINSTRUMENT, \
LIBS_solaris := -ljli $(LIBDL), \
LIBS_aix := -liconv -ljli_static $(LIBDL), \
LIBS_macosx := -liconv -framework Cocoa -framework Security \
-framework ApplicationServices, \
-framework ApplicationServices \
$(SUPPORT_OUTPUTDIR)/native/java.base/libjli_static.a, \
LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib \
$(SUPPORT_OUTPUTDIR)/native/java.base/jli_static.lib, \
VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \

@ -46,6 +46,12 @@ else
endif
endif
# SetupNativeCompilation now supports debug symbols on macosx for hotspot.
# Disable it here for the jdk libraries until we decide to enable them.
ifeq ($(OPENJDK_TARGET_OS), macosx)
ENABLE_DEBUG_SYMBOLS := false
endif
################################################################################
# Find the default set of src dirs for a native library.
# Param 1 - module name

@ -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
@ -27,7 +27,6 @@
SUNWprivate_1.1 {
global:
Java_java_util_jar_JarFile_getMetaInfEntryNames;
Java_java_util_zip_Adler32_update;
Java_java_util_zip_Adler32_updateBytes;
Java_java_util_zip_Adler32_updateByteBuffer;
@ -48,25 +47,6 @@ SUNWprivate_1.1 {
Java_java_util_zip_Inflater_initIDs;
Java_java_util_zip_Inflater_reset;
Java_java_util_zip_Inflater_setDictionary;
Java_java_util_zip_ZipFile_close;
Java_java_util_zip_ZipFile_getCommentBytes;
Java_java_util_zip_ZipFile_freeEntry;
Java_java_util_zip_ZipFile_getEntry;
Java_java_util_zip_ZipFile_getEntryBytes;
Java_java_util_zip_ZipFile_getEntryCrc;
Java_java_util_zip_ZipFile_getEntryCSize;
Java_java_util_zip_ZipFile_getEntryFlag;
Java_java_util_zip_ZipFile_getEntryMethod;
Java_java_util_zip_ZipFile_getEntrySize;
Java_java_util_zip_ZipFile_getEntryTime;
Java_java_util_zip_ZipFile_getNextEntry;
Java_java_util_zip_ZipFile_getZipMessage;
Java_java_util_zip_ZipFile_getTotal;
Java_java_util_zip_ZipFile_initIDs;
Java_java_util_zip_ZipFile_open;
Java_java_util_zip_ZipFile_read;
Java_java_util_zip_ZipFile_startsWithLOC;
ZIP_Close;
ZIP_CRC32;
ZIP_FindEntry;

@ -16,30 +16,14 @@ text: .text%ZIP_InflateFully;
text: .text%ZIP_Lock;
text: .text%ZIP_Unlock;
text: .text%ZIP_FreeEntry;
text: .text%Java_java_util_zip_ZipFile_initIDs;
text: .text%Java_java_util_zip_ZipFile_open;
text: .text%Java_java_util_zip_ZipFile_getTotal;
text: .text%Java_java_util_zip_ZipFile_startsWithLOC;
text: .text%Java_java_util_zip_ZipFile_getEntry;
text: .text%Java_java_util_zip_ZipFile_freeEntry;
text: .text%Java_java_util_zip_ZipFile_getEntryTime;
text: .text%Java_java_util_zip_ZipFile_getEntryCrc;
text: .text%Java_java_util_zip_ZipFile_getEntryCSize;
text: .text%Java_java_util_zip_ZipFile_getEntrySize;
text: .text%Java_java_util_zip_ZipFile_getEntryFlag;
text: .text%Java_java_util_zip_ZipFile_getEntryMethod;
text: .text%Java_java_util_zip_ZipFile_getEntryBytes;
text: .text%Java_java_util_zip_Inflater_initIDs;
text: .text%Java_java_util_zip_Inflater_init;
text: .text%inflateInit2_;
text: .text%zcalloc;
text: .text%Java_java_util_zip_Inflater_inflateBytes;
text: .text%Java_java_util_zip_ZipFile_read;
text: .text%ZIP_Read;
text: .text%zcfree;
text: .text%Java_java_util_jar_JarFile_getMetaInfEntryNames;
text: .text%Java_java_util_zip_Inflater_reset;
text: .text%Java_java_util_zip_Inflater_end;
text: .text%inflateEnd;
text: .text%Java_java_util_zip_ZipFile_close;
text: .text%ZIP_Close;

@ -15,19 +15,6 @@ text: .text%ZIP_InflateFully;
text: .text%ZIP_Lock;
text: .text%ZIP_Unlock;
text: .text%ZIP_FreeEntry;
text: .text%Java_java_util_zip_ZipFile_initIDs;
text: .text%Java_java_util_zip_ZipFile_open;
text: .text%Java_java_util_zip_ZipFile_getTotal;
text: .text%Java_java_util_zip_ZipFile_startsWithLOC;
text: .text%Java_java_util_zip_ZipFile_getEntry;
text: .text%Java_java_util_zip_ZipFile_freeEntry;
text: .text%Java_java_util_zip_ZipFile_getEntryTime;
text: .text%Java_java_util_zip_ZipFile_getEntryCrc;
text: .text%Java_java_util_zip_ZipFile_getEntryCSize;
text: .text%Java_java_util_zip_ZipFile_getEntrySize;
text: .text%Java_java_util_zip_ZipFile_getEntryFlag;
text: .text%Java_java_util_zip_ZipFile_getEntryMethod;
text: .text%Java_java_util_zip_ZipFile_getEntryBytes;
text: .text%Java_java_util_zip_Inflater_initIDs;
text: .text%Java_java_util_zip_Inflater_init;
text: .text%inflateInit2_;
@ -35,7 +22,6 @@ text: .text%zcalloc;
text: .text%inflateReset;
text: .text%Java_java_util_zip_Inflater_inflateBytes;
text: .text%inflate;
text: .text%Java_java_util_zip_ZipFile_read;
text: .text%ZIP_Read;
text: .text%zcfree;
text: .text%Java_java_util_jar_JarFile_getMetaInfEntryNames;
@ -43,6 +29,5 @@ text: .text%ZIP_ReadEntry;
text: .text%InflateFully;
text: .text%inflateEnd;
text: .text%Java_java_util_zip_Inflater_reset;
text: .text%Java_java_util_zip_ZipFile_close;
text: .text%ZIP_Close;
text: .text%Java_java_util_zip_Inflater_end;

@ -16,34 +16,16 @@ text: .text%ZIP_InflateFully;
text: .text%ZIP_Lock;
text: .text%ZIP_Unlock;
text: .text%ZIP_FreeEntry;
text: .text%Java_java_util_zip_ZipFile_initIDs;
text: .text%Java_java_util_zip_ZipFile_open;
text: .text%Java_java_util_zip_ZipFile_getTotal;
text: .text%Java_java_util_zip_ZipFile_startsWithLOC;
text: .text%Java_java_util_zip_ZipFile_getEntry;
text: .text%Java_java_util_zip_ZipFile_freeEntry;
text: .text%Java_java_util_zip_ZipFile_getEntryTime;
text: .text%Java_java_util_zip_ZipFile_getEntryCrc;
text: .text%Java_java_util_zip_ZipFile_getEntryCSize;
text: .text%Java_java_util_zip_ZipFile_getEntrySize;
text: .text%Java_java_util_zip_ZipFile_getEntryFlag;
text: .text%Java_java_util_zip_ZipFile_getEntryMethod;
text: .text%Java_java_util_zip_ZipFile_getEntryBytes;
text: .text%Java_java_util_zip_Inflater_initIDs;
text: .text%Java_java_util_zip_Inflater_init;
text: .text%inflateInit2_;
text: .text%zcalloc;
text: .text%inflateReset;
text: .text%Java_java_util_zip_Inflater_inflateBytes;
text: .text%inflate;
text: .text%Java_java_util_zip_ZipFile_read;
text: .text%ZIP_Read;
text: .text%zcfree;
text: .text%Java_java_util_jar_JarFile_getMetaInfEntryNames;
text: .text%ZIP_ReadEntry;
text: .text%InflateFully;
text: .text%inflateEnd;
text: .text%Java_java_util_zip_Inflater_reset;
text: .text%Java_java_util_zip_ZipFile_close;
text: .text%ZIP_Close;
text: .text%Java_java_util_zip_Inflater_end;

@ -27,7 +27,7 @@ package com.sun.crypto.provider;
import java.io.*;
import sun.security.util.*;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import javax.crypto.spec.IvParameterSpec;

@ -30,7 +30,7 @@ import java.security.AlgorithmParametersSpi;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import javax.crypto.spec.GCMParameterSpec;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import sun.security.util.*;
/**

@ -31,7 +31,7 @@ import java.security.AlgorithmParametersSpi;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import javax.crypto.spec.PBEParameterSpec;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import sun.security.util.*;

@ -33,7 +33,7 @@ import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEParameterSpec;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import sun.security.util.*;
/**

@ -30,7 +30,7 @@ import java.security.AlgorithmParametersSpi;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import javax.crypto.spec.RC2ParameterSpec;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import sun.security.util.*;
/**

@ -118,7 +118,7 @@ class NTLM {
public void debug(byte[] bytes) {
if (DEBUG) {
try {
new sun.misc.HexDumpEncoder().encodeBuffer(bytes, System.out);
new sun.security.util.HexDumpEncoder().encodeBuffer(bytes, System.out);
} catch (IOException ioe) {
// Impossible
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2005, 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
@ -225,9 +225,12 @@ public class CharArrayReader extends Reader {
* Closes the stream and releases any system resources associated with
* it. Once the stream has been closed, further read(), ready(),
* mark(), reset(), or skip() invocations will throw an IOException.
* Closing a previously closed stream has no effect.
* Closing a previously closed stream has no effect. This method will block
* while there is another thread blocking on the reader.
*/
public void close() {
buf = null;
synchronized (lock) {
buf = null;
}
}
}

@ -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
@ -241,13 +241,16 @@ public class PushbackReader extends FilterReader {
* Closes the stream and releases any system resources associated with
* it. Once the stream has been closed, further read(),
* unread(), ready(), or skip() invocations will throw an IOException.
* Closing a previously closed stream has no effect.
* Closing a previously closed stream has no effect. This method will block
* while there is another thread blocking on the reader.
*
* @exception IOException If an I/O error occurs
*/
public void close() throws IOException {
super.close();
buf = null;
synchronized (lock) {
super.close();
buf = null;
}
}
/**

@ -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
@ -194,9 +194,12 @@ public class StringReader extends Reader {
* Closes the stream and releases any system resources associated with
* it. Once the stream has been closed, further read(),
* ready(), mark(), or reset() invocations will throw an IOException.
* Closing a previously closed stream has no effect.
* Closing a previously closed stream has no effect. This method will block
* while there is another thread blocking on the reader.
*/
public void close() {
str = null;
synchronized (lock) {
str = null;
}
}
}

@ -40,6 +40,11 @@ import java.lang.ref.*;
* maintained in the variable (e.g., User ID, Transaction ID) must be
* automatically transmitted to any child threads that are created.
*
* <p>Note: During the creation of a new {@link
* Thread#Thread(ThreadGroup,Runnable,String,long,boolean) thread}, it is
* possible to <i>opt out</i> of receiving initial values for inheritable
* thread-local variables.
*
* @author Josh Bloch and Doug Lea
* @see ThreadLocal
* @since 1.2

@ -304,8 +304,8 @@ public final class StackWalker {
}
/**
* Returns a {@code StackWalker} instance with the given {@ocde options} specifying
* the stack frame information it can access. If the given {@ocde options}
* Returns a {@code StackWalker} instance with the given {@code options} specifying
* the stack frame information it can access. If the given {@code options}
* is empty, this {@code StackWalker} is configured to skip all
* {@linkplain Option#SHOW_HIDDEN_FRAMES hidden frames} and no
* {@linkplain Option#RETAIN_CLASS_REFERENCE class reference} is retained.

@ -120,7 +120,8 @@ final class StringUTF16 {
public static byte[] toBytes(char[] value, int off, int len) {
byte[] val = newBytesFor(len);
for (int i = 0; i < len; i++) {
putChar(val, i, value[off++]);
putChar(val, i, value[off]);
off++;
}
return val;
}
@ -145,11 +146,14 @@ final class StringUTF16 {
@HotSpotIntrinsicCandidate
private static int compress(char[] src, int srcOff, byte[] dst, int dstOff, int len) {
for (int i = 0; i < len; i++) {
int c = src[srcOff++];
if (c >>> 8 != 0) {
return 0;
char c = src[srcOff];
if (c > 0xFF) {
len = 0;
break;
}
dst[dstOff++] = (byte)c;
dst[dstOff] = (byte)c;
srcOff++;
dstOff++;
}
return len;
}
@ -160,11 +164,14 @@ final class StringUTF16 {
// We need a range check here because 'getChar' has no checks
checkBoundsOffCount(srcOff, len, src.length);
for (int i = 0; i < len; i++) {
int c = getChar(src, srcOff++);
if (c >>> 8 != 0) {
return 0;
char c = getChar(src, srcOff);
if (c > 0xFF) {
len = 0;
break;
}
dst[dstOff++] = (byte)c;
dst[dstOff] = (byte)c;
srcOff++;
dstOff++;
}
return len;
}
@ -581,7 +588,7 @@ final class StringUTF16 {
bits |= cp;
putChar(result, i, cp);
}
if (bits >>> 8 != 0) {
if (bits > 0xFF) {
return new String(result, UTF16);
} else {
return newString(result, 0, len);
@ -678,7 +685,7 @@ final class StringUTF16 {
bits |= cp;
putChar(result, i, cp);
}
if (bits >>> 8 != 0) {
if (bits > 0xFF) {
return new String(result, UTF16);
} else {
return newString(result, 0, len);

@ -344,11 +344,11 @@ class Thread implements Runnable {
/**
* Initializes a Thread with the current AccessControlContext.
* @see #init(ThreadGroup,Runnable,String,long,AccessControlContext)
* @see #init(ThreadGroup,Runnable,String,long,AccessControlContext,boolean)
*/
private void init(ThreadGroup g, Runnable target, String name,
long stackSize) {
init(g, target, name, stackSize, null);
init(g, target, name, stackSize, null, true);
}
/**
@ -361,9 +361,12 @@ class Thread implements Runnable {
* zero to indicate that this parameter is to be ignored.
* @param acc the AccessControlContext to inherit, or
* AccessController.getContext() if null
* @param inheritThreadLocals if {@code true}, inherit initial values for
* inheritable thread-locals from the constructing thread
*/
private void init(ThreadGroup g, Runnable target, String name,
long stackSize, AccessControlContext acc) {
long stackSize, AccessControlContext acc,
boolean inheritThreadLocals) {
if (name == null) {
throw new NullPointerException("name cannot be null");
}
@ -414,7 +417,7 @@ class Thread implements Runnable {
acc != null ? acc : AccessController.getContext();
this.target = target;
setPriority(priority);
if (parent.inheritableThreadLocals != null)
if (inheritThreadLocals && parent.inheritableThreadLocals != null)
this.inheritableThreadLocals =
ThreadLocal.createInheritedMap(parent.inheritableThreadLocals);
/* Stash the specified stack size in case the VM cares */
@ -468,7 +471,7 @@ class Thread implements Runnable {
* This is not a public constructor.
*/
Thread(Runnable target, AccessControlContext acc) {
init(null, target, "Thread-" + nextThreadNum(), 0, acc);
init(null, target, "Thread-" + nextThreadNum(), 0, acc, true);
}
/**
@ -677,6 +680,62 @@ class Thread implements Runnable {
init(group, target, name, stackSize);
}
/**
* Allocates a new {@code Thread} object so that it has {@code target}
* as its run object, has the specified {@code name} as its name,
* belongs to the thread group referred to by {@code group}, has
* the specified {@code stackSize}, and inherits initial values for
* {@linkplain InheritableThreadLocal inheritable thread-local} variables
* if {@code inheritThreadLocals} is {@code true}.
*
* <p> This constructor is identical to {@link
* #Thread(ThreadGroup,Runnable,String,long)} with the added ability to
* suppress, or not, the inheriting of initial values for inheritable
* thread-local variables from the constructing thread. This allows for
* finer grain control over inheritable thread-locals. Care must be taken
* when passing a value of {@code false} for {@code inheritThreadLocals},
* as it may lead to unexpected behavior if the new thread executes code
* that expects a specific thread-local value to be inherited.
*
* <p> Specifying a value of {@code true} for the {@code inheritThreadLocals}
* parameter will cause this constructor to behave exactly like the
* {@code Thread(ThreadGroup, Runnable, String, long)} constructor.
*
* @param group
* the thread group. If {@code null} and there is a security
* manager, the group is determined by {@linkplain
* SecurityManager#getThreadGroup SecurityManager.getThreadGroup()}.
* If there is not a security manager or {@code
* SecurityManager.getThreadGroup()} returns {@code null}, the group
* is set to the current thread's thread group.
*
* @param target
* the object whose {@code run} method is invoked when this thread
* is started. If {@code null}, this thread's run method is invoked.
*
* @param name
* the name of the new thread
*
* @param stackSize
* the desired stack size for the new thread, or zero to indicate
* that this parameter is to be ignored
*
* @param inheritThreadLocals
* if {@code true}, inherit initial values for inheritable
* thread-locals from the constructing thread, otherwise no initial
* values are inherited
*
* @throws SecurityException
* if the current thread cannot create a thread in the specified
* thread group
*
* @since 9
*/
public Thread(ThreadGroup group, Runnable target, String name,
long stackSize, boolean inheritThreadLocals) {
init(group, target, name, stackSize, null, inheritThreadLocals);
}
/**
* Causes this thread to begin execution; the Java Virtual Machine
* calls the <code>run</code> method of this thread.

@ -29,7 +29,6 @@ import java.security.PrivilegedAction;
import java.security.AccessController;
import jdk.internal.misc.JavaLangAccess;
import jdk.internal.misc.SharedSecrets;
import sun.misc.ManagedLocalsThread;
import sun.misc.VM;
final class Finalizer extends FinalReference<Object> { /* Package-private; must be in
@ -131,7 +130,7 @@ final class Finalizer extends FinalReference<Object> { /* Package-private; must
for (ThreadGroup tgn = tg;
tgn != null;
tg = tgn, tgn = tg.getParent());
Thread sft = new ManagedLocalsThread(tg, proc, "Secondary finalizer");
Thread sft = new Thread(tg, proc, "Secondary finalizer", 0, false);
sft.start();
try {
sft.join();
@ -190,10 +189,10 @@ final class Finalizer extends FinalReference<Object> { /* Package-private; must
}}});
}
private static class FinalizerThread extends ManagedLocalsThread {
private static class FinalizerThread extends Thread {
private volatile boolean running;
FinalizerThread(ThreadGroup g) {
super(g, "Finalizer");
super(g, null, "Finalizer", 0, false);
}
public void run() {
// in case of recursive call to run()

@ -29,7 +29,6 @@ import sun.misc.Cleaner;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.JavaLangRefAccess;
import jdk.internal.misc.SharedSecrets;
import sun.misc.ManagedLocalsThread;
/**
* Abstract base class for reference objects. This class defines the
@ -128,7 +127,7 @@ public abstract class Reference<T> {
/* High-priority thread to enqueue pending References
*/
private static class ReferenceHandler extends ManagedLocalsThread {
private static class ReferenceHandler extends Thread {
private static void ensureClassInitialized(Class<?> clazz) {
try {
@ -147,7 +146,7 @@ public abstract class Reference<T> {
}
ReferenceHandler(ThreadGroup g, String name) {
super(g, name);
super(g, null, name, 0, false);
}
public void run() {

@ -42,4 +42,19 @@ public interface AnnotatedArrayType extends AnnotatedType {
* @see GenericArrayType#getGenericComponentType()
*/
AnnotatedType getAnnotatedGenericComponentType();
/**
* Returns the potentially annotated type that this type is a member of, if
* this type represents a nested type. For example, if this type is
* {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}.
*
* <p>Returns {@code null} for an {@code AnnotatedType} that is an instance
* of {@code AnnotatedArrayType}.
*
* @return {@code null}
*
* @since 1.9
*/
@Override
AnnotatedType getAnnotatedOwnerType();
}

@ -41,4 +41,26 @@ public interface AnnotatedParameterizedType extends AnnotatedType {
* @see ParameterizedType#getActualTypeArguments()
*/
AnnotatedType[] getAnnotatedActualTypeArguments();
/**
* Returns the potentially annotated type that this type is a member of, if
* this type represents a nested type. For example, if this type is
* {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}.
*
* <p>Returns {@code null} if this {@code AnnotatedType} represents a
* top-level type, or a local or anonymous class, or a primitive type, or
* void.
*
* @return an {@code AnnotatedType} object representing the potentially
* annotated type that this type is a member of, or {@code null}
* @throws TypeNotPresentException if the owner type
* refers to a non-existent type declaration
* @throws MalformedParameterizedTypeException if the owner type
* refers to a parameterized type that cannot be instantiated
* for any reason
*
* @since 1.9
*/
@Override
AnnotatedType getAnnotatedOwnerType();
}

@ -35,6 +35,37 @@ package java.lang.reflect;
*/
public interface AnnotatedType extends AnnotatedElement {
/**
* Returns the potentially annotated type that this type is a member of, if
* this type represents a nested type. For example, if this type is
* {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}.
*
* <p>Returns {@code null} if this {@code AnnotatedType} represents a
* top-level type, or a local or anonymous class, or a primitive type, or
* void.
*
* <p>Returns {@code null} if this {@code AnnotatedType} is an instance of
* {@code AnnotatedArrayType}, {@code AnnotatedTypeVariable}, or
* {@code AnnotatedWildcardType}.
*
* @implSpec
* This default implementation returns {@code null} and performs no other
* action.
*
* @return an {@code AnnotatedType} object representing the potentially
* annotated type that this type is a member of, or {@code null}
* @throws TypeNotPresentException if the owner type
* refers to a non-existent type declaration
* @throws MalformedParameterizedTypeException if the owner type
* refers to a parameterized type that cannot be instantiated
* for any reason
*
* @since 1.9
*/
default AnnotatedType getAnnotatedOwnerType() {
return null;
}
/**
* Returns the underlying type that this annotated type represents.
*

@ -43,4 +43,19 @@ public interface AnnotatedTypeVariable extends AnnotatedType {
* @see TypeVariable#getBounds()
*/
AnnotatedType[] getAnnotatedBounds();
/**
* Returns the potentially annotated type that this type is a member of, if
* this type represents a nested type. For example, if this type is
* {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}.
*
* <p>Returns {@code null} for an {@code AnnotatedType} that is an instance
* of {@code AnnotatedTypeVariable}.
*
* @return {@code null}
*
* @since 1.9
*/
@Override
AnnotatedType getAnnotatedOwnerType();
}

@ -54,4 +54,19 @@ public interface AnnotatedWildcardType extends AnnotatedType {
* @see WildcardType#getUpperBounds()
*/
AnnotatedType[] getAnnotatedUpperBounds();
/**
* Returns the potentially annotated type that this type is a member of, if
* this type represents a nested type. For example, if this type is
* {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}.
*
* <p>Returns {@code null} for an {@code AnnotatedType} that is an instance
* of {@code AnnotatedWildcardType}.
*
* @return {@code null}
*
* @since 1.9
*/
@Override
AnnotatedType getAnnotatedOwnerType();
}

@ -34,7 +34,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.BiFunction;
import sun.misc.ProxyGenerator;
import sun.misc.VM;
import sun.reflect.CallerSensitive;
import sun.reflect.Reflection;

@ -23,7 +23,7 @@
* questions.
*/
package sun.misc;
package java.lang.reflect;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
@ -53,7 +53,7 @@ import sun.security.action.GetBooleanAction;
* @author Peter Jones
* @since 1.3
*/
public class ProxyGenerator {
class ProxyGenerator {
/*
* In the comments below, "JVMS" refers to The Java Virtual Machine
* Specification Second Edition and "JLS" refers to the original
@ -314,13 +314,13 @@ public class ProxyGenerator {
private static final boolean saveGeneratedFiles =
java.security.AccessController.doPrivileged(
new GetBooleanAction(
"sun.misc.ProxyGenerator.saveGeneratedFiles")).booleanValue();
"jdk.proxy.ProxyGenerator.saveGeneratedFiles")).booleanValue();
/**
* Generate a public proxy class given a name and a list of proxy interfaces.
*/
public static byte[] generateProxyClass(final String name,
Class<?>[] interfaces) {
static byte[] generateProxyClass(final String name,
Class<?>[] interfaces) {
return generateProxyClass(name, interfaces, (ACC_PUBLIC | ACC_FINAL | ACC_SUPER));
}
@ -331,9 +331,9 @@ public class ProxyGenerator {
* @param interfaces proxy interfaces
* @param accessFlags access flags of the proxy class
*/
public static byte[] generateProxyClass(final String name,
Class<?>[] interfaces,
int accessFlags)
static byte[] generateProxyClass(final String name,
Class<?>[] interfaces,
int accessFlags)
{
ProxyGenerator gen = new ProxyGenerator(name, interfaces, accessFlags);
final byte[] classFile = gen.generateClassFile();

@ -27,7 +27,7 @@ package java.security.cert;
import java.io.IOException;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import sun.security.util.DerValue;
/**

@ -31,7 +31,7 @@ import java.security.PublicKey;
import java.util.*;
import javax.security.auth.x500.X500Principal;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import sun.security.util.Debug;
import sun.security.util.DerInputStream;
import sun.security.util.DerValue;

@ -1856,6 +1856,7 @@ public class SimpleDateFormat extends DateFormat {
if (patternCharIndex == PATTERN_HOUR_OF_DAY1 ||
patternCharIndex == PATTERN_HOUR1 ||
(patternCharIndex == PATTERN_MONTH && count <= 2) ||
(patternCharIndex == PATTERN_MONTH_STANDALONE && count <= 2) ||
patternCharIndex == PATTERN_YEAR ||
patternCharIndex == PATTERN_WEEK_YEAR) {
// It would be good to unify this with the obeyCount logic below,
@ -1976,6 +1977,20 @@ public class SimpleDateFormat extends DateFormat {
}
break parsing;
case PATTERN_MONTH_STANDALONE: // 'L'
if (count <= 2) {
// Don't want to parse the month if it is a string
// while pattern uses numeric style: L or LL
//[we computed 'value' above.]
calb.set(Calendar.MONTH, value - 1);
return pos.index;
}
Map<String, Integer> maps = getDisplayNamesMap(field, locale);
if ((index = matchString(text, start, field, maps, calb)) > 0) {
return index;
}
break parsing;
case PATTERN_HOUR_OF_DAY1: // 'k' 1-based. eg, 23:59 + 1 hour =>> 24:59
if (!isLenient()) {
// Validate the hour value in non-lenient

@ -996,6 +996,24 @@ public final class Duration
return create(toBigDecimalSeconds().divide(BigDecimal.valueOf(divisor), RoundingMode.DOWN));
}
/**
* Returns number of whole times a specified Duration occurs within this Duration.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param divisor the value to divide the duration by, positive or negative, not null
* @return number of whole times, rounded toward zero, a specified
* {@code Duration} occurs within this Duration, may be negative
* @throws ArithmeticException if the divisor is zero, or if numeric overflow occurs
* @since 9
*/
public long dividedBy(Duration divisor) {
Objects.requireNonNull(divisor, "divisor");
BigDecimal dividendBigD = toBigDecimalSeconds();
BigDecimal divisorBigD = divisor.toBigDecimalSeconds();
return dividendBigD.divideToIntegralValue(divisorBigD).longValueExact();
}
/**
* Converts this duration to the total length in seconds and
* fractional nanoseconds expressed as a {@code BigDecimal}.

@ -304,9 +304,28 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
* Each of these fields are initialized to contain an instance of the
* appropriate view the first time this view is requested. The views are
* stateless, so there's no reason to create more than one of each.
*
* <p>Since there is no synchronization performed while accessing these fields,
* it is expected that java.util.Map view classes using these fields have
* no non-final fields (or any fields at all except for outer-this). Adhering
* to this rule would make the races on these fields benign.
*
* <p>It is also imperative that implementations read the field only once,
* as in:
*
* <pre> {@code
* public Set<K> keySet() {
* Set<K> ks = keySet; // single racy read
* if (ks == null) {
* ks = new KeySet();
* keySet = ks;
* }
* return ks;
* }
*}</pre>
*/
transient volatile Set<K> keySet;
transient volatile Collection<V> values;
transient Set<K> keySet;
transient Collection<V> values;
/**
* {@inheritDoc}
@ -325,8 +344,9 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
* method will not all return the same set.
*/
public Set<K> keySet() {
if (keySet == null) {
keySet = new AbstractSet<K>() {
Set<K> ks = keySet;
if (ks == null) {
ks = new AbstractSet<K>() {
public Iterator<K> iterator() {
return new Iterator<K>() {
private Iterator<Entry<K,V>> i = entrySet().iterator();
@ -361,8 +381,9 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
return AbstractMap.this.containsKey(k);
}
};
keySet = ks;
}
return keySet;
return ks;
}
/**
@ -382,8 +403,9 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
* method will not all return the same collection.
*/
public Collection<V> values() {
if (values == null) {
values = new AbstractCollection<V>() {
Collection<V> vals = values;
if (vals == null) {
vals = new AbstractCollection<V>() {
public Iterator<V> iterator() {
return new Iterator<V>() {
private Iterator<Entry<K,V>> i = entrySet().iterator();
@ -418,8 +440,9 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
return AbstractMap.this.containsValue(v);
}
};
values = vals;
}
return values;
return vals;
}
public abstract Set<Entry<K,V>> entrySet();

@ -5530,7 +5530,7 @@ public class Collections {
* @since 1.6
*/
public static <T> Queue<T> asLifoQueue(Deque<T> deque) {
return new AsLIFOQueue<>(deque);
return new AsLIFOQueue<>(Objects.requireNonNull(deque));
}
/**

@ -380,10 +380,11 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
*/
public Set<K> keySet() {
Set<K> ks = keySet;
if (ks != null)
return ks;
else
return keySet = new KeySet();
if (ks == null) {
ks = new KeySet();
keySet = ks;
}
return ks;
}
private class KeySet extends AbstractSet<K> {
@ -418,10 +419,11 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
*/
public Collection<V> values() {
Collection<V> vs = values;
if (vs != null)
return vs;
else
return values = new Values();
if (vs == null) {
vs = new Values();
values = vs;
}
return vs;
}
private class Values extends AbstractCollection<V> {

@ -902,8 +902,12 @@ public class HashMap<K,V> extends AbstractMap<K,V>
* @return a set view of the keys contained in this map
*/
public Set<K> keySet() {
Set<K> ks;
return (ks = keySet) == null ? (keySet = new KeySet()) : ks;
Set<K> ks = keySet;
if (ks == null) {
ks = new KeySet();
keySet = ks;
}
return ks;
}
final class KeySet extends AbstractSet<K> {
@ -949,8 +953,12 @@ public class HashMap<K,V> extends AbstractMap<K,V>
* @return a view of the values contained in this map
*/
public Collection<V> values() {
Collection<V> vs;
return (vs = values) == null ? (values = new Values()) : vs;
Collection<V> vs = values;
if (vs == null) {
vs = new Values();
values = vs;
}
return vs;
}
final class Values extends AbstractCollection<V> {

@ -964,10 +964,11 @@ public class IdentityHashMap<K,V>
*/
public Set<K> keySet() {
Set<K> ks = keySet;
if (ks != null)
return ks;
else
return keySet = new KeySet();
if (ks == null) {
ks = new KeySet();
keySet = ks;
}
return ks;
}
private class KeySet extends AbstractSet<K> {
@ -1069,10 +1070,11 @@ public class IdentityHashMap<K,V>
*/
public Collection<V> values() {
Collection<V> vs = values;
if (vs != null)
return vs;
else
return values = new Values();
if (vs == null) {
vs = new Values();
values = vs;
}
return vs;
}
private class Values extends AbstractCollection<V> {

@ -528,8 +528,12 @@ public class LinkedHashMap<K,V>
* @return a set view of the keys contained in this map
*/
public Set<K> keySet() {
Set<K> ks;
return (ks = keySet) == null ? (keySet = new LinkedKeySet()) : ks;
Set<K> ks = keySet;
if (ks == null) {
ks = new LinkedKeySet();
keySet = ks;
}
return ks;
}
final class LinkedKeySet extends AbstractSet<K> {
@ -577,8 +581,12 @@ public class LinkedHashMap<K,V>
* @return a view of the values contained in this map
*/
public Collection<V> values() {
Collection<V> vs;
return (vs = values) == null ? (values = new LinkedValues()) : vs;
Collection<V> vs = values;
if (vs == null) {
vs = new LinkedValues();
values = vs;
}
return vs;
}
final class LinkedValues extends AbstractCollection<V> {

@ -1670,9 +1670,9 @@ public interface Map<K, V> {
*/
@SafeVarargs
@SuppressWarnings("varargs")
static <K, V> Map<K, V> ofEntries(Entry<K, V>... entries) {
static <K, V> Map<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
Map<K, V> map = new HashMap<>(entries.length * 4 / 3 + 1); // throws NPE if entries is null
for (Entry<K, V> e : entries) {
for (Entry<? extends K, ? extends V> e : entries) {
// next line throws NPE if e is null
map.put(Objects.requireNonNull(e.getKey()), Objects.requireNonNull(e.getValue()));
}

@ -852,7 +852,11 @@ public class TreeMap<K,V>
*/
public Collection<V> values() {
Collection<V> vs = values;
return (vs != null) ? vs : (values = new Values());
if (vs == null) {
vs = new Values();
values = vs;
}
return vs;
}
/**

@ -866,7 +866,11 @@ public class WeakHashMap<K,V>
*/
public Set<K> keySet() {
Set<K> ks = keySet;
return (ks != null ? ks : (keySet = new KeySet()));
if (ks == null) {
ks = new KeySet();
keySet = ks;
}
return ks;
}
private class KeySet extends AbstractSet<K> {
@ -915,7 +919,11 @@ public class WeakHashMap<K,V>
*/
public Collection<V> values() {
Collection<V> vs = values;
return (vs != null) ? vs : (values = new Values());
if (vs == null) {
vs = new Values();
values = vs;
}
return vs;
}
private class Values extends AbstractCollection<V> {

@ -203,7 +203,10 @@ class JarFile extends ZipFile {
return man;
}
private native String[] getMetaInfEntryNames();
private String[] getMetaInfEntryNames() {
return jdk.internal.misc.SharedSecrets.getJavaUtilZipFileAccess()
.getMetaInfEntryNames((ZipFile)this);
}
/**
* Returns the {@code JarEntry} for the given entry name or

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
@ -5814,7 +5814,7 @@ NEXT: while (i <= last) {
*/
public Stream<String> splitAsStream(final CharSequence input) {
class MatcherIterator implements Iterator<String> {
private final Matcher matcher;
private Matcher matcher;
// The start position of the next sub-sequence of input
// when current == input.length there are no more elements
private int current;
@ -5823,14 +5823,6 @@ NEXT: while (i <= last) {
// > 0 if there are N next empty elements
private int emptyElementCount;
MatcherIterator() {
this.matcher = matcher(input);
// If the input is an empty string then the result can only be a
// stream of the input. Induce that by setting the empty
// element count to 1
this.emptyElementCount = input.length() == 0 ? 1 : 0;
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
@ -5846,6 +5838,13 @@ NEXT: while (i <= last) {
}
public boolean hasNext() {
if (matcher == null) {
matcher = matcher(input);
// If the input is an empty string then the result can only be a
// stream of the input. Induce that by setting the empty
// element count to 1
emptyElementCount = input.length() == 0 ? 1 : 0;
}
if (nextElement != null || emptyElementCount > 0)
return true;

@ -434,7 +434,7 @@ public final class Collectors {
* stream returned by mapper
* @return a collector which applies the mapping function to the input
* elements and provides the flat mapped results to the downstream collector
* @since 1.9
* @since 9
*/
public static <T, U, A, R>
Collector<T, ?, R> flatMapping(Function<? super T, ? extends Stream<? extends U>> mapper,
@ -451,6 +451,53 @@ public final class Collectors {
downstream.characteristics());
}
/**
* Adapts a {@code Collector} to one accepting elements of the same type
* {@code T} by applying the predicate to each input element and only
* accumulating if the predicate returns {@code true}.
*
* @apiNote
* The {@code filtering()} collectors are most useful when used in a
* multi-level reduction, such as downstream of a {@code groupingBy} or
* {@code partitioningBy}. For example, given a stream of
* {@code Employee}, to accumulate the employees in each department that have a
* salary above a certain threshold:
* <pre>{@code
* Map<Department, Set<Employee>> wellPaidEmployeesByDepartment
* = employees.stream().collect(groupingBy(Employee::getDepartment,
* filtering(e -> e.getSalary() > 2000, toSet())));
* }</pre>
* A filtering collector differs from a stream's {@code filter()} operation.
* In this example, suppose there are no employees whose salary is above the
* threshold in some department. Using a filtering collector as shown above
* would result in a mapping from that department to an empty {@code Set}.
* If a stream {@code filter()} operation were done instead, there would be
* no mapping for that department at all.
*
* @param <T> the type of the input elements
* @param <A> intermediate accumulation type of the downstream collector
* @param <R> result type of collector
* @param predicate a predicate to be applied to the input elements
* @param downstream a collector which will accept values that match the
* predicate
* @return a collector which applies the predicate to the input elements
* and provides matching elements to the downstream collector
* @since 9
*/
public static <T, A, R>
Collector<T, ?, R> filtering(Predicate<? super T> predicate,
Collector<? super T, A, R> downstream) {
BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator();
return new CollectorImpl<>(downstream.supplier(),
(r, t) -> {
if (predicate.test(t)) {
downstreamAccumulator.accept(r, t);
}
},
downstream.combiner(), downstream.finisher(),
downstream.characteristics());
}
/**
* Adapts a {@code Collector} to perform an additional finishing
* transformation. For example, one could adapt the {@link #toList()}

@ -43,7 +43,7 @@ import sun.nio.cs.ArrayEncoder;
final class ZipCoder {
String toString(byte[] ba, int length) {
String toString(byte[] ba, int off, int length) {
CharsetDecoder cd = decoder().reset();
int len = (int)(length * cd.maxCharsPerByte());
char[] ca = new char[len];
@ -53,12 +53,12 @@ final class ZipCoder {
// CodingErrorAction.REPLACE mode. ZipCoder uses
// REPORT mode.
if (isUTF8 && cd instanceof ArrayDecoder) {
int clen = ((ArrayDecoder)cd).decode(ba, 0, length, ca);
int clen = ((ArrayDecoder)cd).decode(ba, off, length, ca);
if (clen == -1) // malformed
throw new IllegalArgumentException("MALFORMED");
return new String(ca, 0, clen);
}
ByteBuffer bb = ByteBuffer.wrap(ba, 0, length);
ByteBuffer bb = ByteBuffer.wrap(ba, off, length);
CharBuffer cb = CharBuffer.wrap(ca);
CoderResult cr = cd.decode(bb, cb, true);
if (!cr.isUnderflow())
@ -69,8 +69,12 @@ final class ZipCoder {
return new String(ca, 0, cb.position());
}
String toString(byte[] ba, int length) {
return toString(ba, 0, length);
}
String toString(byte[] ba) {
return toString(ba, ba.length);
return toString(ba, 0, ba.length);
}
byte[] getBytes(String s) {
@ -111,13 +115,16 @@ final class ZipCoder {
return utf8.getBytes(s);
}
String toStringUTF8(byte[] ba, int len) {
return toStringUTF8(ba, 0, len);
}
String toStringUTF8(byte[] ba, int off, int len) {
if (isUTF8)
return toString(ba, len);
return toString(ba, off, len);
if (utf8 == null)
utf8 = new ZipCoder(StandardCharsets.UTF_8);
return utf8.toString(ba, len);
return utf8.toString(ba, off, len);
}
boolean isUTF8() {

File diff suppressed because it is too large Load Diff

@ -31,6 +31,8 @@ import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.concurrent.TimeUnit;
import static java.util.zip.ZipConstants.ENDHDR;
class ZipUtils {
// used to adjust values between Windows and java epoch
@ -133,7 +135,7 @@ class ZipUtils {
* The bytes are assumed to be in Intel (little-endian) byte order.
*/
public static final int get16(byte b[], int off) {
return Byte.toUnsignedInt(b[off]) | (Byte.toUnsignedInt(b[off+1]) << 8);
return (b[off] & 0xff) | ((b[off + 1] & 0xff) << 8);
}
/**
@ -160,4 +162,79 @@ class ZipUtils {
public static final int get32S(byte b[], int off) {
return (get16(b, off) | (get16(b, off+2) << 16));
}
// fields access methods
static final int CH(byte[] b, int n) {
return b[n] & 0xff ;
}
static final int SH(byte[] b, int n) {
return (b[n] & 0xff) | ((b[n + 1] & 0xff) << 8);
}
static final long LG(byte[] b, int n) {
return ((SH(b, n)) | (SH(b, n + 2) << 16)) & 0xffffffffL;
}
static final long LL(byte[] b, int n) {
return (LG(b, n)) | (LG(b, n + 4) << 32);
}
static final long GETSIG(byte[] b) {
return LG(b, 0);
}
// local file (LOC) header fields
static final long LOCSIG(byte[] b) { return LG(b, 0); } // signature
static final int LOCVER(byte[] b) { return SH(b, 4); } // version needed to extract
static final int LOCFLG(byte[] b) { return SH(b, 6); } // general purpose bit flags
static final int LOCHOW(byte[] b) { return SH(b, 8); } // compression method
static final long LOCTIM(byte[] b) { return LG(b, 10);} // modification time
static final long LOCCRC(byte[] b) { return LG(b, 14);} // crc of uncompressed data
static final long LOCSIZ(byte[] b) { return LG(b, 18);} // compressed data size
static final long LOCLEN(byte[] b) { return LG(b, 22);} // uncompressed data size
static final int LOCNAM(byte[] b) { return SH(b, 26);} // filename length
static final int LOCEXT(byte[] b) { return SH(b, 28);} // extra field length
// extra local (EXT) header fields
static final long EXTCRC(byte[] b) { return LG(b, 4);} // crc of uncompressed data
static final long EXTSIZ(byte[] b) { return LG(b, 8);} // compressed size
static final long EXTLEN(byte[] b) { return LG(b, 12);} // uncompressed size
// end of central directory header (END) fields
static final int ENDSUB(byte[] b) { return SH(b, 8); } // number of entries on this disk
static final int ENDTOT(byte[] b) { return SH(b, 10);} // total number of entries
static final long ENDSIZ(byte[] b) { return LG(b, 12);} // central directory size
static final long ENDOFF(byte[] b) { return LG(b, 16);} // central directory offset
static final int ENDCOM(byte[] b) { return SH(b, 20);} // size of zip file comment
static final int ENDCOM(byte[] b, int off) { return SH(b, off + 20);}
// zip64 end of central directory recoder fields
static final long ZIP64_ENDTOD(byte[] b) { return LL(b, 24);} // total number of entries on disk
static final long ZIP64_ENDTOT(byte[] b) { return LL(b, 32);} // total number of entries
static final long ZIP64_ENDSIZ(byte[] b) { return LL(b, 40);} // central directory size
static final long ZIP64_ENDOFF(byte[] b) { return LL(b, 48);} // central directory offset
static final long ZIP64_LOCOFF(byte[] b) { return LL(b, 8);} // zip64 end offset
// central directory header (CEN) fields
static final long CENSIG(byte[] b, int pos) { return LG(b, pos + 0); }
static final int CENVEM(byte[] b, int pos) { return SH(b, pos + 4); }
static final int CENVER(byte[] b, int pos) { return SH(b, pos + 6); }
static final int CENFLG(byte[] b, int pos) { return SH(b, pos + 8); }
static final int CENHOW(byte[] b, int pos) { return SH(b, pos + 10);}
static final long CENTIM(byte[] b, int pos) { return LG(b, pos + 12);}
static final long CENCRC(byte[] b, int pos) { return LG(b, pos + 16);}
static final long CENSIZ(byte[] b, int pos) { return LG(b, pos + 20);}
static final long CENLEN(byte[] b, int pos) { return LG(b, pos + 24);}
static final int CENNAM(byte[] b, int pos) { return SH(b, pos + 28);}
static final int CENEXT(byte[] b, int pos) { return SH(b, pos + 30);}
static final int CENCOM(byte[] b, int pos) { return SH(b, pos + 32);}
static final int CENDSK(byte[] b, int pos) { return SH(b, pos + 34);}
static final int CENATT(byte[] b, int pos) { return SH(b, pos + 36);}
static final long CENATX(byte[] b, int pos) { return LG(b, pos + 38);}
static final long CENOFF(byte[] b, int pos) { return LG(b, pos + 42);}
// The END header is followed by a variable length comment of size < 64k.
static final long END_MAXLEN = 0xFFFF + ENDHDR;
static final int READBLOCKSZ = 128;
}

@ -29,5 +29,6 @@ import java.util.zip.ZipFile;
public interface JavaUtilZipFileAccess {
public boolean startsWithLocHeader(ZipFile zip);
public String[] getMetaInfEntryNames(ZipFile zip);
}

@ -1,163 +0,0 @@
/*
* Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.misc;
import java.io.OutputStream;
import java.io.PushbackInputStream;
import java.io.PrintStream;
/**
* This class implements a BASE64 Character decoder as specified in RFC1521.
*
* This RFC is part of the MIME specification which is published by the
* Internet Engineering Task Force (IETF). Unlike some other encoding
* schemes there is nothing in this encoding that tells the decoder
* where a buffer starts or stops, so to use it you will need to isolate
* your encoded data into a single chunk and then feed them this decoder.
* The simplest way to do that is to read all of the encoded data into a
* string and then use:
* <pre>
* byte mydata[];
* BASE64Decoder base64 = new BASE64Decoder();
*
* mydata = base64.decodeBuffer(bufferString);
* </pre>
* This will decode the String in <i>bufferString</i> and give you an array
* of bytes in the array <i>myData</i>.
*
* On errors, this class throws a CEFormatException with the following detail
* strings:
* <pre>
* "BASE64Decoder: Not enough bytes for an atom."
* </pre>
*
* @author Chuck McManis
* @see CharacterEncoder
* @see BASE64Decoder
*/
public class BASE64Decoder extends CharacterDecoder {
/** This class has 4 bytes per atom */
protected int bytesPerAtom() {
return (4);
}
/** Any multiple of 4 will do, 72 might be common */
protected int bytesPerLine() {
return (72);
}
/**
* This character array provides the character to value map
* based on RFC1521.
*/
private static final char pem_array[] = {
// 0 1 2 3 4 5 6 7
'A','B','C','D','E','F','G','H', // 0
'I','J','K','L','M','N','O','P', // 1
'Q','R','S','T','U','V','W','X', // 2
'Y','Z','a','b','c','d','e','f', // 3
'g','h','i','j','k','l','m','n', // 4
'o','p','q','r','s','t','u','v', // 5
'w','x','y','z','0','1','2','3', // 6
'4','5','6','7','8','9','+','/' // 7
};
private static final byte pem_convert_array[] = new byte[256];
static {
for (int i = 0; i < 255; i++) {
pem_convert_array[i] = -1;
}
for (int i = 0; i < pem_array.length; i++) {
pem_convert_array[pem_array[i]] = (byte) i;
}
}
byte decode_buffer[] = new byte[4];
/**
* Decode one BASE64 atom into 1, 2, or 3 bytes of data.
*/
@SuppressWarnings("fallthrough")
protected void decodeAtom(PushbackInputStream inStream, OutputStream outStream, int rem)
throws java.io.IOException
{
int i;
byte a = -1, b = -1, c = -1, d = -1;
if (rem < 2) {
throw new CEFormatException("BASE64Decoder: Not enough bytes for an atom.");
}
do {
i = inStream.read();
if (i == -1) {
throw new CEStreamExhausted();
}
} while (i == '\n' || i == '\r');
decode_buffer[0] = (byte) i;
i = readFully(inStream, decode_buffer, 1, rem-1);
if (i == -1) {
throw new CEStreamExhausted();
}
if (rem > 3 && decode_buffer[3] == '=') {
rem = 3;
}
if (rem > 2 && decode_buffer[2] == '=') {
rem = 2;
}
switch (rem) {
case 4:
d = pem_convert_array[decode_buffer[3] & 0xff];
// NOBREAK
case 3:
c = pem_convert_array[decode_buffer[2] & 0xff];
// NOBREAK
case 2:
b = pem_convert_array[decode_buffer[1] & 0xff];
a = pem_convert_array[decode_buffer[0] & 0xff];
break;
}
switch (rem) {
case 2:
outStream.write( (byte)(((a << 2) & 0xfc) | ((b >>> 4) & 3)) );
break;
case 3:
outStream.write( (byte) (((a << 2) & 0xfc) | ((b >>> 4) & 3)) );
outStream.write( (byte) (((b << 4) & 0xf0) | ((c >>> 2) & 0xf)) );
break;
case 4:
outStream.write( (byte) (((a << 2) & 0xfc) | ((b >>> 4) & 3)) );
outStream.write( (byte) (((b << 4) & 0xf0) | ((c >>> 2) & 0xf)) );
outStream.write( (byte) (((c << 6) & 0xc0) | (d & 0x3f)) );
break;
}
return;
}
}

@ -1,112 +0,0 @@
/*
* Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.misc;
import java.io.OutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.IOException;
/**
* This class implements a BASE64 Character encoder as specified in RFC1521.
* This RFC is part of the MIME specification as published by the Internet
* Engineering Task Force (IETF). Unlike some other encoding schemes there
* is nothing in this encoding that indicates
* where a buffer starts or ends.
*
* This means that the encoded text will simply start with the first line
* of encoded text and end with the last line of encoded text.
*
* @author Chuck McManis
* @see CharacterEncoder
* @see BASE64Decoder
*/
public class BASE64Encoder extends CharacterEncoder {
/** this class encodes three bytes per atom. */
protected int bytesPerAtom() {
return (3);
}
/**
* this class encodes 57 bytes per line. This results in a maximum
* of 57/3 * 4 or 76 characters per output line. Not counting the
* line termination.
*/
protected int bytesPerLine() {
return (57);
}
/** This array maps the characters to their 6 bit values */
private static final char pem_array[] = {
// 0 1 2 3 4 5 6 7
'A','B','C','D','E','F','G','H', // 0
'I','J','K','L','M','N','O','P', // 1
'Q','R','S','T','U','V','W','X', // 2
'Y','Z','a','b','c','d','e','f', // 3
'g','h','i','j','k','l','m','n', // 4
'o','p','q','r','s','t','u','v', // 5
'w','x','y','z','0','1','2','3', // 6
'4','5','6','7','8','9','+','/' // 7
};
/**
* encodeAtom - Take three bytes of input and encode it as 4
* printable characters. Note that if the length in len is less
* than three is encodes either one or two '=' signs to indicate
* padding characters.
*/
protected void encodeAtom(OutputStream outStream, byte data[], int offset, int len)
throws IOException {
byte a, b, c;
if (len == 1) {
a = data[offset];
b = 0;
c = 0;
outStream.write(pem_array[(a >>> 2) & 0x3F]);
outStream.write(pem_array[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]);
outStream.write('=');
outStream.write('=');
} else if (len == 2) {
a = data[offset];
b = data[offset+1];
c = 0;
outStream.write(pem_array[(a >>> 2) & 0x3F]);
outStream.write(pem_array[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]);
outStream.write(pem_array[((b << 2) & 0x3c) + ((c >>> 6) & 0x3)]);
outStream.write('=');
} else {
a = data[offset];
b = data[offset+1];
c = data[offset+2];
outStream.write(pem_array[(a >>> 2) & 0x3F]);
outStream.write(pem_array[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]);
outStream.write(pem_array[((b << 2) & 0x3c) + ((c >>> 6) & 0x3)]);
outStream.write(pem_array[c & 0x3F]);
}
}
}

@ -1,218 +0,0 @@
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.misc;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PushbackInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
/**
* This class defines the decoding half of character encoders.
* A character decoder is an algorithim for transforming 8 bit
* binary data that has been encoded into text by a character
* encoder, back into original binary form.
*
* The character encoders, in general, have been structured
* around a central theme that binary data can be encoded into
* text that has the form:
*
* <pre>
* [Buffer Prefix]
* [Line Prefix][encoded data atoms][Line Suffix]
* [Buffer Suffix]
* </pre>
*
* Of course in the simplest encoding schemes, the buffer has no
* distinct prefix of suffix, however all have some fixed relationship
* between the text in an 'atom' and the binary data itself.
*
* In the CharacterEncoder and CharacterDecoder classes, one complete
* chunk of data is referred to as a <i>buffer</i>. Encoded buffers
* are all text, and decoded buffers (sometimes just referred to as
* buffers) are binary octets.
*
* To create a custom decoder, you must, at a minimum, overide three
* abstract methods in this class.
* <DL>
* <DD>bytesPerAtom which tells the decoder how many bytes to
* expect from decodeAtom
* <DD>decodeAtom which decodes the bytes sent to it as text.
* <DD>bytesPerLine which tells the encoder the maximum number of
* bytes per line.
* </DL>
*
* In general, the character decoders return error in the form of a
* CEFormatException. The syntax of the detail string is
* <pre>
* DecoderClassName: Error message.
* </pre>
*
* Several useful decoders have already been written and are
* referenced in the See Also list below.
*
* @author Chuck McManis
* @see CEFormatException
* @see CharacterEncoder
* @see UCDecoder
* @see UUDecoder
* @see BASE64Decoder
*/
public abstract class CharacterDecoder {
/** Return the number of bytes per atom of decoding */
protected abstract int bytesPerAtom();
/** Return the maximum number of bytes that can be encoded per line */
protected abstract int bytesPerLine();
/** decode the beginning of the buffer, by default this is a NOP. */
protected void decodeBufferPrefix(PushbackInputStream aStream, OutputStream bStream) throws IOException { }
/** decode the buffer suffix, again by default it is a NOP. */
protected void decodeBufferSuffix(PushbackInputStream aStream, OutputStream bStream) throws IOException { }
/**
* This method should return, if it knows, the number of bytes
* that will be decoded. Many formats such as uuencoding provide
* this information. By default we return the maximum bytes that
* could have been encoded on the line.
*/
protected int decodeLinePrefix(PushbackInputStream aStream, OutputStream bStream) throws IOException {
return (bytesPerLine());
}
/**
* This method post processes the line, if there are error detection
* or correction codes in a line, they are generally processed by
* this method. The simplest version of this method looks for the
* (newline) character.
*/
protected void decodeLineSuffix(PushbackInputStream aStream, OutputStream bStream) throws IOException { }
/**
* This method does an actual decode. It takes the decoded bytes and
* writes them to the OutputStream. The integer <i>l</i> tells the
* method how many bytes are required. This is always {@literal <=} bytesPerAtom().
*/
protected void decodeAtom(PushbackInputStream aStream, OutputStream bStream, int l) throws IOException {
throw new CEStreamExhausted();
}
/**
* This method works around the bizarre semantics of BufferedInputStream's
* read method.
*/
protected int readFully(InputStream in, byte buffer[], int offset, int len)
throws java.io.IOException {
for (int i = 0; i < len; i++) {
int q = in.read();
if (q == -1)
return ((i == 0) ? -1 : i);
buffer[i+offset] = (byte)q;
}
return len;
}
/**
* Decode the text from the InputStream and write the decoded
* octets to the OutputStream. This method runs until the stream
* is exhausted.
* @exception CEFormatException An error has occurred while decoding
* @exception CEStreamExhausted The input stream is unexpectedly out of data
*/
public void decodeBuffer(InputStream aStream, OutputStream bStream) throws IOException {
int i;
int totalBytes = 0;
PushbackInputStream ps = new PushbackInputStream (aStream);
decodeBufferPrefix(ps, bStream);
while (true) {
int length;
try {
length = decodeLinePrefix(ps, bStream);
for (i = 0; (i+bytesPerAtom()) < length; i += bytesPerAtom()) {
decodeAtom(ps, bStream, bytesPerAtom());
totalBytes += bytesPerAtom();
}
if ((i + bytesPerAtom()) == length) {
decodeAtom(ps, bStream, bytesPerAtom());
totalBytes += bytesPerAtom();
} else {
decodeAtom(ps, bStream, length - i);
totalBytes += (length - i);
}
decodeLineSuffix(ps, bStream);
} catch (CEStreamExhausted e) {
break;
}
}
decodeBufferSuffix(ps, bStream);
}
/**
* Alternate decode interface that takes a String containing the encoded
* buffer and returns a byte array containing the data.
* @exception CEFormatException An error has occurred while decoding
*/
public byte[] decodeBuffer(String inputString) throws IOException {
byte inputBuffer[] = inputString.getBytes("ISO-8859-1");
ByteArrayInputStream inStream = new ByteArrayInputStream(inputBuffer);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
decodeBuffer(inStream, outStream);
return outStream.toByteArray();
}
/**
* Decode the contents of the inputstream into a buffer.
*/
public byte[] decodeBuffer(InputStream in) throws IOException {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
decodeBuffer(in, outStream);
return outStream.toByteArray();
}
/**
* Decode the contents of the String into a ByteBuffer.
*/
public ByteBuffer decodeBufferToByteBuffer(String inputString)
throws IOException {
return ByteBuffer.wrap(decodeBuffer(inputString));
}
/**
* Decode the contents of the inputStream into a ByteBuffer.
*/
public ByteBuffer decodeBufferToByteBuffer(InputStream in)
throws IOException {
return ByteBuffer.wrap(decodeBuffer(in));
}
}

@ -82,7 +82,7 @@ public class GC {
*/
public static native long maxObjectInspectionAge();
private static class Daemon extends ManagedLocalsThread {
private static class Daemon extends Thread {
public void run() {
for (;;) {
@ -122,7 +122,7 @@ public class GC {
}
private Daemon(ThreadGroup tg) {
super(tg, "GC Daemon");
super(tg, null, "GC Daemon", 0L, false);
}
/* Create a new daemon thread in the root thread group */

@ -1,120 +0,0 @@
/*
* Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.misc;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.IOException;
/**
* This class encodes a buffer into the classic: "Hexadecimal Dump" format of
* the past. It is useful for analyzing the contents of binary buffers.
* The format produced is as follows:
* <pre>
* xxxx: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff ................
* </pre>
* Where xxxx is the offset into the buffer in 16 byte chunks, followed
* by ascii coded hexadecimal bytes followed by the ASCII representation of
* the bytes or '.' if they are not valid bytes.
*
* @author Chuck McManis
*/
public class HexDumpEncoder extends CharacterEncoder {
private int offset;
private int thisLineLength;
private int currentByte;
private byte thisLine[] = new byte[16];
static void hexDigit(PrintStream p, byte x) {
char c;
c = (char) ((x >> 4) & 0xf);
if (c > 9)
c = (char) ((c-10) + 'A');
else
c = (char)(c + '0');
p.write(c);
c = (char) (x & 0xf);
if (c > 9)
c = (char)((c-10) + 'A');
else
c = (char)(c + '0');
p.write(c);
}
protected int bytesPerAtom() {
return (1);
}
protected int bytesPerLine() {
return (16);
}
protected void encodeBufferPrefix(OutputStream o) throws IOException {
offset = 0;
super.encodeBufferPrefix(o);
}
protected void encodeLinePrefix(OutputStream o, int len) throws IOException {
hexDigit(pStream, (byte)((offset >>> 8) & 0xff));
hexDigit(pStream, (byte)(offset & 0xff));
pStream.print(": ");
currentByte = 0;
thisLineLength = len;
}
protected void encodeAtom(OutputStream o, byte buf[], int off, int len) throws IOException {
thisLine[currentByte] = buf[off];
hexDigit(pStream, buf[off]);
pStream.print(" ");
currentByte++;
if (currentByte == 8)
pStream.print(" ");
}
protected void encodeLineSuffix(OutputStream o) throws IOException {
if (thisLineLength < 16) {
for (int i = thisLineLength; i < 16; i++) {
pStream.print(" ");
if (i == 7)
pStream.print(" ");
}
}
pStream.print(" ");
for (int i = 0; i < thisLineLength; i++) {
if ((thisLine[i] < ' ') || (thisLine[i] > 'z')) {
pStream.print(".");
} else {
pStream.write(thisLine[i]);
}
}
pStream.println();
offset += thisLineLength;
}
}

@ -35,8 +35,10 @@ import java.util.concurrent.atomic.AtomicInteger;
* A thread that has no permissions, is not a member of any user-defined
* ThreadGroup and supports the ability to erase ThreadLocals.
*/
public final class InnocuousThread extends ManagedLocalsThread {
public final class InnocuousThread extends Thread {
private static final jdk.internal.misc.Unsafe UNSAFE;
private static final long THREAD_LOCALS;
private static final long INHERITABLE_THREAD_LOCALS;
private static final ThreadGroup INNOCUOUSTHREADGROUP;
private static final AccessControlContext ACC;
private static final long INHERITEDACCESSCONTROLCONTEXT;
@ -54,7 +56,7 @@ public final class InnocuousThread extends ManagedLocalsThread {
}
public InnocuousThread(ThreadGroup group, Runnable target, String name) {
super(group, target, name);
super(group, target, name, 0L, false);
UNSAFE.putOrderedObject(this, INHERITEDACCESSCONTROLCONTEXT, ACC);
UNSAFE.putOrderedObject(this, CONTEXTCLASSLOADER, ClassLoader.getSystemClassLoader());
}
@ -73,6 +75,14 @@ public final class InnocuousThread extends ManagedLocalsThread {
throw new SecurityException("setContextClassLoader");
}
/**
* Drops all thread locals (and inherited thread locals).
*/
public final void eraseThreadLocals() {
UNSAFE.putObject(this, THREAD_LOCALS, null);
UNSAFE.putObject(this, INHERITABLE_THREAD_LOCALS, null);
}
// ensure run method is run only once
private volatile boolean hasRun;
@ -96,6 +106,10 @@ public final class InnocuousThread extends ManagedLocalsThread {
Class<?> tk = Thread.class;
Class<?> gk = ThreadGroup.class;
THREAD_LOCALS = UNSAFE.objectFieldOffset
(tk.getDeclaredField("threadLocals"));
INHERITABLE_THREAD_LOCALS = UNSAFE.objectFieldOffset
(tk.getDeclaredField("inheritableThreadLocals"));
INHERITEDACCESSCONTROLCONTEXT = UNSAFE.objectFieldOffset
(tk.getDeclaredField("inheritedAccessControlContext"));
CONTEXTCLASSLOADER = UNSAFE.objectFieldOffset

@ -1,214 +0,0 @@
/*
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.misc;
import java.util.Enumeration;
import java.util.NoSuchElementException;
/**
* Queue: implements a simple queue mechanism. Allows for enumeration of the
* elements.
*
* @author Herb Jellinek
*/
public class Queue<T> {
int length = 0;
QueueElement<T> head = null;
QueueElement<T> tail = null;
public Queue() {
}
/**
* Enqueue an object.
*/
public synchronized void enqueue(T obj) {
QueueElement<T> newElt = new QueueElement<>(obj);
if (head == null) {
head = newElt;
tail = newElt;
length = 1;
} else {
newElt.next = head;
head.prev = newElt;
head = newElt;
length++;
}
notify();
}
/**
* Dequeue the oldest object on the queue. Will wait indefinitely.
*
* @return the oldest object on the queue.
* @exception java.lang.InterruptedException if any thread has
* interrupted this thread.
*/
public T dequeue() throws InterruptedException {
return dequeue(0L);
}
/**
* Dequeue the oldest object on the queue.
* @param timeOut the number of milliseconds to wait for something
* to arrive.
*
* @return the oldest object on the queue.
* @exception java.lang.InterruptedException if any thread has
* interrupted this thread.
*/
public synchronized T dequeue(long timeOut)
throws InterruptedException {
while (tail == null) {
wait(timeOut);
}
QueueElement<T> elt = tail;
tail = elt.prev;
if (tail == null) {
head = null;
} else {
tail.next = null;
}
length--;
return elt.obj;
}
/**
* Is the queue empty?
* @return true if the queue is empty.
*/
public synchronized boolean isEmpty() {
return (tail == null);
}
/**
* Returns an enumeration of the elements in Last-In, First-Out
* order. Use the Enumeration methods on the returned object to
* fetch the elements sequentially.
*/
public final synchronized Enumeration<T> elements() {
return new LIFOQueueEnumerator<>(this);
}
/**
* Returns an enumeration of the elements in First-In, First-Out
* order. Use the Enumeration methods on the returned object to
* fetch the elements sequentially.
*/
public final synchronized Enumeration<T> reverseElements() {
return new FIFOQueueEnumerator<>(this);
}
public synchronized void dump(String msg) {
System.err.println(">> "+msg);
System.err.println("["+length+" elt(s); head = "+
(head == null ? "null" : (head.obj)+"")+
" tail = "+(tail == null ? "null" : (tail.obj)+""));
QueueElement<T> cursor = head;
QueueElement<T> last = null;
while (cursor != null) {
System.err.println(" "+cursor);
last = cursor;
cursor = cursor.next;
}
if (last != tail) {
System.err.println(" tail != last: "+tail+", "+last);
}
System.err.println("]");
}
}
final class FIFOQueueEnumerator<T> implements Enumeration<T> {
Queue<T> queue;
QueueElement<T> cursor;
FIFOQueueEnumerator(Queue<T> q) {
queue = q;
cursor = q.tail;
}
public boolean hasMoreElements() {
return (cursor != null);
}
public T nextElement() {
synchronized (queue) {
if (cursor != null) {
QueueElement<T> result = cursor;
cursor = cursor.prev;
return result.obj;
}
}
throw new NoSuchElementException("FIFOQueueEnumerator");
}
}
final class LIFOQueueEnumerator<T> implements Enumeration<T> {
Queue<T> queue;
QueueElement<T> cursor;
LIFOQueueEnumerator(Queue<T> q) {
queue = q;
cursor = q.head;
}
public boolean hasMoreElements() {
return (cursor != null);
}
public T nextElement() {
synchronized (queue) {
if (cursor != null) {
QueueElement<T> result = cursor;
cursor = cursor.next;
return result.obj;
}
}
throw new NoSuchElementException("LIFOQueueEnumerator");
}
}
class QueueElement<T> {
QueueElement<T> next = null;
QueueElement<T> prev = null;
T obj = null;
QueueElement(T obj) {
this.obj = obj;
}
public String toString() {
return "QueueElement[obj="+obj+(prev == null ? " null" : " prev")+
(next == null ? " null" : " next")+"]";
}
}

@ -1,41 +0,0 @@
/*
* Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.misc;
/**
* Requests are functor objects; that is, they provide part of the mechanism
* for deferred function application.
*
* @author Steven B. Byrne
*/
public abstract class Request {
/**
* The main task of the Request object is to be exectuted from a request
* queue.
*/
public abstract void execute();
}

@ -1,96 +0,0 @@
/*
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.misc;
/**
* The request processor allows functors (Request instances) to be created
* in arbitrary threads, and to be posted for execution in a non-restricted
* thread.
*
* @author Steven B. Byrne
*/
public class RequestProcessor implements Runnable {
private static Queue<Request> requestQueue;
private static Thread dispatcher;
/**
* Queues a Request instance for execution by the request procesor
* thread.
*/
public static void postRequest(Request req) {
lazyInitialize();
requestQueue.enqueue(req);
}
/**
* Process requests as they are queued.
*/
public void run() {
lazyInitialize();
while (true) {
try {
Request req = requestQueue.dequeue();
try {
req.execute();
} catch (Throwable t) {
// do nothing at the moment...maybe report an error
// in the future
}
} catch (InterruptedException e) {
// do nothing at the present time.
}
}
}
/**
* This method initiates the request processor thread. It is safe
* to call it after the thread has been started. It provides a way for
* clients to deliberately control the context in which the request
* processor thread is created
*/
public static synchronized void startProcessing() {
if (dispatcher == null) {
dispatcher = new ManagedLocalsThread(new RequestProcessor(), "Request Processor");
dispatcher.setPriority(Thread.NORM_PRIORITY + 2);
dispatcher.start();
}
}
/**
* This method performs lazy initialization.
*/
private static synchronized void lazyInitialize() {
if (requestQueue == null) {
requestQueue = new Queue<Request>();
}
}
}

@ -213,7 +213,7 @@ public final class Signal {
}
};
if (handler != null) {
new ManagedLocalsThread(runnable, sig + " handler").start();
new Thread(null, runnable, sig + " handler", 0, false).start();
}
}

@ -1,233 +0,0 @@
/*
* Copyright (c) 1995, 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.misc;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.io.PushbackInputStream;
import java.io.PrintStream;
import java.io.IOException;
/**
* This class implements a robust character decoder. The decoder will
* converted encoded text into binary data.
*
* The basic encoding unit is a 3 character atom. It encodes two bytes
* of data. Bytes are encoded into a 64 character set, the characters
* were chosen specifically because they appear in all codesets.
* We don't care what their numerical equivalent is because
* we use a character array to map them. This is like UUencoding
* with the dependency on ASCII removed.
*
* The three chars that make up an atom are encoded as follows:
* <pre>
* 00xxxyyy 00axxxxx 00byyyyy
* 00 = leading zeros, all values are 0 - 63
* xxxyyy - Top 3 bits of X, Top 3 bits of Y
* axxxxx - a = X parity bit, xxxxx lower 5 bits of X
* byyyyy - b = Y parity bit, yyyyy lower 5 bits of Y
* </pre>
*
* The atoms are arranged into lines suitable for inclusion into an
* email message or text file. The number of bytes that are encoded
* per line is 48 which keeps the total line length under 80 chars)
*
* Each line has the form(
* <pre>
* *(LLSS)(DDDD)(DDDD)(DDDD)...(CRC)
* Where each (xxx) represents a three character atom.
* (LLSS) - 8 bit length (high byte), and sequence number
* modulo 256;
* (DDDD) - Data byte atoms, if length is odd, last data
* atom has (DD00) (high byte data, low byte 0)
* (CRC) - 16 bit CRC for the line, includes length,
* sequence, and all data bytes. If there is a
* zero pad byte (odd length) it is _NOT_
* included in the CRC.
* </pre>
*
* If an error is encountered during decoding this class throws a
* CEFormatException. The specific detail messages are:
*
* <pre>
* "UCDecoder: High byte parity error."
* "UCDecoder: Low byte parity error."
* "UCDecoder: Out of sequence line."
* "UCDecoder: CRC check failed."
* </pre>
*
* @author Chuck McManis
* @see CharacterEncoder
* @see UCEncoder
*/
public class UCDecoder extends CharacterDecoder {
/** This class encodes two bytes per atom. */
protected int bytesPerAtom() {
return (2);
}
/** this class encodes 48 bytes per line */
protected int bytesPerLine() {
return (48);
}
/* this is the UCE mapping of 0-63 to characters .. */
private static final byte map_array[] = {
// 0 1 2 3 4 5 6 7
(byte)'0',(byte)'1',(byte)'2',(byte)'3',(byte)'4',(byte)'5',(byte)'6',(byte)'7', // 0
(byte)'8',(byte)'9',(byte)'A',(byte)'B',(byte)'C',(byte)'D',(byte)'E',(byte)'F', // 1
(byte)'G',(byte)'H',(byte)'I',(byte)'J',(byte)'K',(byte)'L',(byte)'M',(byte)'N', // 2
(byte)'O',(byte)'P',(byte)'Q',(byte)'R',(byte)'S',(byte)'T',(byte)'U',(byte)'V', // 3
(byte)'W',(byte)'X',(byte)'Y',(byte)'Z',(byte)'a',(byte)'b',(byte)'c',(byte)'d', // 4
(byte)'e',(byte)'f',(byte)'g',(byte)'h',(byte)'i',(byte)'j',(byte)'k',(byte)'l', // 5
(byte)'m',(byte)'n',(byte)'o',(byte)'p',(byte)'q',(byte)'r',(byte)'s',(byte)'t', // 6
(byte)'u',(byte)'v',(byte)'w',(byte)'x',(byte)'y',(byte)'z',(byte)'(',(byte)')' // 7
};
private int sequence;
private byte tmp[] = new byte[2];
private CRC16 crc = new CRC16();
/**
* Decode one atom - reads the characters from the input stream, decodes
* them, and checks for valid parity.
*/
protected void decodeAtom(PushbackInputStream inStream, OutputStream outStream, int l) throws IOException {
int i, p1, p2, np1, np2;
byte a = -1, b = -1, c = -1;
byte high_byte, low_byte;
byte tmp[] = new byte[3];
i = inStream.read(tmp);
if (i != 3) {
throw new CEStreamExhausted();
}
for (i = 0; (i < 64) && ((a == -1) || (b == -1) || (c == -1)); i++) {
if (tmp[0] == map_array[i]) {
a = (byte) i;
}
if (tmp[1] == map_array[i]) {
b = (byte) i;
}
if (tmp[2] == map_array[i]) {
c = (byte) i;
}
}
high_byte = (byte) (((a & 0x38) << 2) + (b & 0x1f));
low_byte = (byte) (((a & 0x7) << 5) + (c & 0x1f));
p1 = 0;
p2 = 0;
for (i = 1; i < 256; i = i * 2) {
if ((high_byte & i) != 0)
p1++;
if ((low_byte & i) != 0)
p2++;
}
np1 = (b & 32) / 32;
np2 = (c & 32) / 32;
if ((p1 & 1) != np1) {
throw new CEFormatException("UCDecoder: High byte parity error.");
}
if ((p2 & 1) != np2) {
throw new CEFormatException("UCDecoder: Low byte parity error.");
}
outStream.write(high_byte);
crc.update(high_byte);
if (l == 2) {
outStream.write(low_byte);
crc.update(low_byte);
}
}
private ByteArrayOutputStream lineAndSeq = new ByteArrayOutputStream(2);
/**
* decodeBufferPrefix initializes the sequence number to zero.
*/
protected void decodeBufferPrefix(PushbackInputStream inStream, OutputStream outStream) {
sequence = 0;
}
/**
* decodeLinePrefix reads the sequence number and the number of
* encoded bytes from the line. If the sequence number is not the
* previous sequence number + 1 then an exception is thrown.
* UCE lines are line terminator immune, they all start with *
* so the other thing this method does is scan for the next line
* by looking for the * character.
*
* @exception CEFormatException out of sequence lines detected.
*/
protected int decodeLinePrefix(PushbackInputStream inStream, OutputStream outStream) throws IOException {
int i;
int nLen, nSeq;
byte xtmp[];
int c;
crc.value = 0;
while (true) {
c = inStream.read(tmp, 0, 1);
if (c == -1) {
throw new CEStreamExhausted();
}
if (tmp[0] == '*') {
break;
}
}
lineAndSeq.reset();
decodeAtom(inStream, lineAndSeq, 2);
xtmp = lineAndSeq.toByteArray();
nLen = xtmp[0] & 0xff;
nSeq = xtmp[1] & 0xff;
if (nSeq != sequence) {
throw new CEFormatException("UCDecoder: Out of sequence line.");
}
sequence = (sequence + 1) & 0xff;
return (nLen);
}
/**
* this method reads the CRC that is at the end of every line and
* verifies that it matches the computed CRC.
*
* @exception CEFormatException if CRC check fails.
*/
protected void decodeLineSuffix(PushbackInputStream inStream, OutputStream outStream) throws IOException {
int i;
int lineCRC = crc.value;
int readCRC;
byte tmp[];
lineAndSeq.reset();
decodeAtom(inStream, lineAndSeq, 2);
tmp = lineAndSeq.toByteArray();
readCRC = ((tmp[0] << 8) & 0xFF00) + (tmp[1] & 0xff);
if (readCRC != lineCRC) {
throw new CEFormatException("UCDecoder: CRC check failed.");
}
}
}

@ -1,178 +0,0 @@
/*
* Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.misc;
import java.io.OutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.IOException;
/**
* This class implements a robust character encoder. The encoder is designed
* to convert binary data into printable characters. The characters are
* assumed to exist but they are not assumed to be ASCII, the complete set
* is 0-9, A-Z, a-z, "(", and ")".
*
* The basic encoding unit is a 3 character atom. It encodes two bytes
* of data. Bytes are encoded into a 64 character set, the characters
* were chosen specifically because they appear in all codesets.
* We don't care what their numerical equivalent is because
* we use a character array to map them. This is like UUencoding
* with the dependency on ASCII removed.
*
* The three chars that make up an atom are encoded as follows:
* <pre>
* 00xxxyyy 00axxxxx 00byyyyy
* 00 = leading zeros, all values are 0 - 63
* xxxyyy - Top 3 bits of X, Top 3 bits of Y
* axxxxx - a = X parity bit, xxxxx lower 5 bits of X
* byyyyy - b = Y parity bit, yyyyy lower 5 bits of Y
* </pre>
*
* The atoms are arranged into lines suitable for inclusion into an
* email message or text file. The number of bytes that are encoded
* per line is 48 which keeps the total line length under 80 chars)
*
* Each line has the form(
* <pre>
* *(LLSS)(DDDD)(DDDD)(DDDD)...(CRC)
* Where each (xxx) represents a three character atom.
* (LLSS) - 8 bit length (high byte), and sequence number
* modulo 256;
* (DDDD) - Data byte atoms, if length is odd, last data
* atom has (DD00) (high byte data, low byte 0)
* (CRC) - 16 bit CRC for the line, includes length,
* sequence, and all data bytes. If there is a
* zero pad byte (odd length) it is _NOT_
* included in the CRC.
* </pre>
*
* @author Chuck McManis
* @see CharacterEncoder
* @see UCDecoder
*/
public class UCEncoder extends CharacterEncoder {
/** this clase encodes two bytes per atom */
protected int bytesPerAtom() {
return (2);
}
/** this class encodes 48 bytes per line */
protected int bytesPerLine() {
return (48);
}
/* this is the UCE mapping of 0-63 to characters .. */
private static final byte map_array[] = {
// 0 1 2 3 4 5 6 7
(byte)'0',(byte)'1',(byte)'2',(byte)'3',(byte)'4',(byte)'5',(byte)'6',(byte)'7', // 0
(byte)'8',(byte)'9',(byte)'A',(byte)'B',(byte)'C',(byte)'D',(byte)'E',(byte)'F', // 1
(byte)'G',(byte)'H',(byte)'I',(byte)'J',(byte)'K',(byte)'L',(byte)'M',(byte)'N', // 2
(byte)'O',(byte)'P',(byte)'Q',(byte)'R',(byte)'S',(byte)'T',(byte)'U',(byte)'V', // 3
(byte)'W',(byte)'X',(byte)'Y',(byte)'Z',(byte)'a',(byte)'b',(byte)'c',(byte)'d', // 4
(byte)'e',(byte)'f',(byte)'g',(byte)'h',(byte)'i',(byte)'j',(byte)'k',(byte)'l', // 5
(byte)'m',(byte)'n',(byte)'o',(byte)'p',(byte)'q',(byte)'r',(byte)'s',(byte)'t', // 6
(byte)'u',(byte)'v',(byte)'w',(byte)'x',(byte)'y',(byte)'z',(byte)'(',(byte)')' // 7
};
private int sequence;
private byte tmp[] = new byte[2];
private CRC16 crc = new CRC16();
/**
* encodeAtom - take two bytes and encode them into the correct
* three characters. If only one byte is to be encoded, the other
* must be zero. The padding byte is not included in the CRC computation.
*/
protected void encodeAtom(OutputStream outStream, byte data[], int offset, int len) throws IOException
{
int i;
int p1, p2; // parity bits
byte a, b;
a = data[offset];
if (len == 2) {
b = data[offset+1];
} else {
b = 0;
}
crc.update(a);
if (len == 2) {
crc.update(b);
}
outStream.write(map_array[((a >>> 2) & 0x38) + ((b >>> 5) & 0x7)]);
p1 = 0; p2 = 0;
for (i = 1; i < 256; i = i * 2) {
if ((a & i) != 0) {
p1++;
}
if ((b & i) != 0) {
p2++;
}
}
p1 = (p1 & 1) * 32;
p2 = (p2 & 1) * 32;
outStream.write(map_array[(a & 31) + p1]);
outStream.write(map_array[(b & 31) + p2]);
return;
}
/**
* Each UCE encoded line starts with a prefix of '*[XXX]', where
* the sequence number and the length are encoded in the first
* atom.
*/
protected void encodeLinePrefix(OutputStream outStream, int length) throws IOException {
outStream.write('*');
crc.value = 0;
tmp[0] = (byte) length;
tmp[1] = (byte) sequence;
sequence = (sequence + 1) & 0xff;
encodeAtom(outStream, tmp, 0, 2);
}
/**
* each UCE encoded line ends with YYY and encoded version of the
* 16 bit checksum. The most significant byte of the check sum
* is always encoded FIRST.
*/
protected void encodeLineSuffix(OutputStream outStream) throws IOException {
tmp[0] = (byte) ((crc.value >>> 8) & 0xff);
tmp[1] = (byte) (crc.value & 0xff);
encodeAtom(outStream, tmp, 0, 2);
super.pStream.println();
}
/**
* The buffer prefix code is used to initialize the sequence number
* to zero.
*/
protected void encodeBufferPrefix(OutputStream a) throws IOException {
sequence = 0;
super.encodeBufferPrefix(a);
}
}

@ -1,274 +0,0 @@
/*
* Copyright (c) 1995, 2001, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.misc;
import java.io.PushbackInputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.IOException;
/**
* This class implements a Berkeley uu character decoder. This decoder
* was made famous by the uudecode program.
*
* The basic character coding is algorithmic, taking 6 bits of binary
* data and adding it to an ASCII ' ' (space) character. This converts
* these six bits into a printable representation. Note that it depends
* on the ASCII character encoding standard for english. Groups of three
* bytes are converted into 4 characters by treating the three bytes
* a four 6 bit groups, group 1 is byte 1's most significant six bits,
* group 2 is byte 1's least significant two bits plus byte 2's four
* most significant bits. etc.
*
* In this encoding, the buffer prefix is:
* <pre>
* begin [mode] [filename]
* </pre>
*
* This is followed by one or more lines of the form:
* <pre>
* (len)(data)(data)(data) ...
* </pre>
* where (len) is the number of bytes on this line. Note that groupings
* are always four characters, even if length is not a multiple of three
* bytes. When less than three characters are encoded, the values of the
* last remaining bytes is undefined and should be ignored.
*
* The last line of data in a uuencoded buffer is represented by a single
* space character. This is translated by the decoding engine to a line
* length of zero. This is immediately followed by a line which contains
* the word 'end[newline]'
*
* If an error is encountered during decoding this class throws a
* CEFormatException. The specific detail messages are:
*
* <pre>
* "UUDecoder: No begin line."
* "UUDecoder: Malformed begin line."
* "UUDecoder: Short Buffer."
* "UUDecoder: Bad Line Length."
* "UUDecoder: Missing 'end' line."
* </pre>
*
* @author Chuck McManis
* @see CharacterDecoder
* @see UUEncoder
*/
public class UUDecoder extends CharacterDecoder {
/**
* This string contains the name that was in the buffer being decoded.
*/
public String bufferName;
/**
* Represents UNIX(tm) mode bits. Generally three octal digits
* representing read, write, and execute permission of the owner,
* group owner, and others. They should be interpreted as the bit groups:
* <pre>
* (owner) (group) (others)
* rwx rwx rwx (r = read, w = write, x = execute)
*</pre>
*
*/
public int mode;
/**
* UU encoding specifies 3 bytes per atom.
*/
protected int bytesPerAtom() {
return (3);
}
/**
* All UU lines have 45 bytes on them, for line length of 15*4+1 or 61
* characters per line.
*/
protected int bytesPerLine() {
return (45);
}
/** This is used to decode the atoms */
private byte decoderBuffer[] = new byte[4];
/**
* Decode a UU atom. Note that if l is less than 3 we don't write
* the extra bits, however the encoder always encodes 4 character
* groups even when they are not needed.
*/
protected void decodeAtom(PushbackInputStream inStream, OutputStream outStream, int l)
throws IOException {
int i, c1, c2, c3, c4;
int a, b, c;
StringBuilder x = new StringBuilder();
for (i = 0; i < 4; i++) {
c1 = inStream.read();
if (c1 == -1) {
throw new CEStreamExhausted();
}
x.append((char)c1);
decoderBuffer[i] = (byte) ((c1 - ' ') & 0x3f);
}
a = ((decoderBuffer[0] << 2) & 0xfc) | ((decoderBuffer[1] >>> 4) & 3);
b = ((decoderBuffer[1] << 4) & 0xf0) | ((decoderBuffer[2] >>> 2) & 0xf);
c = ((decoderBuffer[2] << 6) & 0xc0) | (decoderBuffer[3] & 0x3f);
outStream.write((byte)(a & 0xff));
if (l > 1) {
outStream.write((byte)( b & 0xff));
}
if (l > 2) {
outStream.write((byte)(c&0xff));
}
}
/**
* For uuencoded buffers, the data begins with a line of the form:
* begin MODE FILENAME
* This line always starts in column 1.
*/
protected void decodeBufferPrefix(PushbackInputStream inStream, OutputStream outStream) throws IOException {
int c;
StringBuilder q = new StringBuilder(32);
String r;
boolean sawNewLine;
/*
* This works by ripping through the buffer until it finds a 'begin'
* line or the end of the buffer.
*/
sawNewLine = true;
while (true) {
c = inStream.read();
if (c == -1) {
throw new CEFormatException("UUDecoder: No begin line.");
}
if ((c == 'b') && sawNewLine){
c = inStream.read();
if (c == 'e') {
break;
}
}
sawNewLine = (c == '\n') || (c == '\r');
}
/*
* Now we think its begin, (we've seen ^be) so verify it here.
*/
while ((c != '\n') && (c != '\r')) {
c = inStream.read();
if (c == -1) {
throw new CEFormatException("UUDecoder: No begin line.");
}
if ((c != '\n') && (c != '\r')) {
q.append((char)c);
}
}
r = q.toString();
if (r.indexOf(' ') != 3) {
throw new CEFormatException("UUDecoder: Malformed begin line.");
}
mode = Integer.parseInt(r.substring(4,7));
bufferName = r.substring(r.indexOf(' ',6)+1);
/*
* Check for \n after \r
*/
if (c == '\r') {
c = inStream.read ();
if ((c != '\n') && (c != -1))
inStream.unread (c);
}
}
/**
* In uuencoded buffers, encoded lines start with a character that
* represents the number of bytes encoded in this line. The last
* line of input is always a line that starts with a single space
* character, which would be a zero length line.
*/
protected int decodeLinePrefix(PushbackInputStream inStream, OutputStream outStream) throws IOException {
int c;
c = inStream.read();
if (c == ' ') {
c = inStream.read(); /* discard the (first)trailing CR or LF */
c = inStream.read(); /* check for a second one */
if ((c != '\n') && (c != -1))
inStream.unread (c);
throw new CEStreamExhausted();
} else if (c == -1) {
throw new CEFormatException("UUDecoder: Short Buffer.");
}
c = (c - ' ') & 0x3f;
if (c > bytesPerLine()) {
throw new CEFormatException("UUDecoder: Bad Line Length.");
}
return (c);
}
/**
* Find the end of the line for the next operation.
* The following sequences are recognized as end-of-line
* CR, CR LF, or LF
*/
protected void decodeLineSuffix(PushbackInputStream inStream, OutputStream outStream) throws IOException {
int c;
while (true) {
c = inStream.read();
if (c == -1) {
throw new CEStreamExhausted();
}
if (c == '\n') {
break;
}
if (c == '\r') {
c = inStream.read();
if ((c != '\n') && (c != -1)) {
inStream.unread (c);
}
break;
}
}
}
/**
* UUencoded files have a buffer suffix which consists of the word
* end. This line should immediately follow the line with a single
* space in it.
*/
protected void decodeBufferSuffix(PushbackInputStream inStream, OutputStream outStream) throws IOException {
int c;
c = inStream.read(decoderBuffer);
if ((decoderBuffer[0] != 'e') || (decoderBuffer[1] != 'n') ||
(decoderBuffer[2] != 'd')) {
throw new CEFormatException("UUDecoder: Missing 'end' line.");
}
}
}

@ -1,200 +0,0 @@
/*
* Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.misc;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.IOException;
/**
* This class implements a Berkeley uu character encoder. This encoder
* was made famous by uuencode program.
*
* The basic character coding is algorithmic, taking 6 bits of binary
* data and adding it to an ASCII ' ' (space) character. This converts
* these six bits into a printable representation. Note that it depends
* on the ASCII character encoding standard for english. Groups of three
* bytes are converted into 4 characters by treating the three bytes
* a four 6 bit groups, group 1 is byte 1's most significant six bits,
* group 2 is byte 1's least significant two bits plus byte 2's four
* most significant bits. etc.
*
* In this encoding, the buffer prefix is:
* <pre>
* begin [mode] [filename]
* </pre>
*
* This is followed by one or more lines of the form:
* <pre>
* (len)(data)(data)(data) ...
* </pre>
* where (len) is the number of bytes on this line. Note that groupings
* are always four characters, even if length is not a multiple of three
* bytes. When less than three characters are encoded, the values of the
* last remaining bytes is undefined and should be ignored.
*
* The last line of data in a uuencoded file is represented by a single
* space character. This is translated by the decoding engine to a line
* length of zero. This is immediately followed by a line which contains
* the word 'end[newline]'
*
* @author Chuck McManis
* @see CharacterEncoder
* @see UUDecoder
*/
public class UUEncoder extends CharacterEncoder {
/**
* This name is stored in the begin line.
*/
private String bufferName;
/**
* Represents UNIX(tm) mode bits. Generally three octal digits representing
* read, write, and execute permission of the owner, group owner, and
* others. They should be interpreted as the bit groups:
* (owner) (group) (others)
* rwx rwx rwx (r = read, w = write, x = execute)
*
* By default these are set to 644 (UNIX rw-r--r-- permissions).
*/
private int mode;
/**
* Default - buffer begin line will be:
* <pre>
* begin 644 encoder.buf
* </pre>
*/
public UUEncoder() {
bufferName = "encoder.buf";
mode = 644;
}
/**
* Specifies a name for the encoded buffer, begin line will be:
* <pre>
* begin 644 [FNAME]
* </pre>
*/
public UUEncoder(String fname) {
bufferName = fname;
mode = 644;
}
/**
* Specifies a name and mode for the encoded buffer, begin line will be:
* <pre>
* begin [MODE] [FNAME]
* </pre>
*/
public UUEncoder(String fname, int newMode) {
bufferName = fname;
mode = newMode;
}
/** number of bytes per atom in uuencoding is 3 */
protected int bytesPerAtom() {
return (3);
}
/** number of bytes per line in uuencoding is 45 */
protected int bytesPerLine() {
return (45);
}
/**
* encodeAtom - take three bytes and encodes them into 4 characters
* If len is less than 3 then remaining bytes are filled with '1'.
* This insures that the last line won't end in spaces and potentiallly
* be truncated.
*/
protected void encodeAtom(OutputStream outStream, byte data[], int offset, int len)
throws IOException {
byte a, b = 1, c = 1;
int c1, c2, c3, c4;
a = data[offset];
if (len > 1) {
b = data[offset+1];
}
if (len > 2) {
c = data[offset+2];
}
c1 = (a >>> 2) & 0x3f;
c2 = ((a << 4) & 0x30) | ((b >>> 4) & 0xf);
c3 = ((b << 2) & 0x3c) | ((c >>> 6) & 0x3);
c4 = c & 0x3f;
outStream.write(c1 + ' ');
outStream.write(c2 + ' ');
outStream.write(c3 + ' ');
outStream.write(c4 + ' ');
return;
}
/**
* Encode the line prefix which consists of the single character. The
* lenght is added to the value of ' ' (32 decimal) and printed.
*/
protected void encodeLinePrefix(OutputStream outStream, int length)
throws IOException {
outStream.write((length & 0x3f) + ' ');
}
/**
* The line suffix for uuencoded files is simply a new line.
*/
protected void encodeLineSuffix(OutputStream outStream) throws IOException {
pStream.println();
}
/**
* encodeBufferPrefix writes the begin line to the output stream.
*/
protected void encodeBufferPrefix(OutputStream a) throws IOException {
super.pStream = new PrintStream(a);
super.pStream.print("begin "+mode+" ");
if (bufferName != null) {
super.pStream.println(bufferName);
} else {
super.pStream.println("encoder.bin");
}
super.pStream.flush();
}
/**
* encodeBufferSuffix writes the single line containing space (' ') and
* the line containing the word 'end' to the output stream.
*/
protected void encodeBufferSuffix(OutputStream a) throws IOException {
super.pStream.println(" \nend");
super.pStream.flush();
}
}

@ -274,9 +274,6 @@ public class VM {
// used by java.lang.Integer.IntegerCache
props.remove("java.lang.Integer.IntegerCache.high");
// used by java.util.zip.ZipFile
props.remove("sun.zip.disableMemoryMapping");
// used by sun.launcher.LauncherHelper
props.remove("sun.java.launcher.diag");
}

@ -27,7 +27,6 @@ package sun.net;
import java.io.*;
import java.net.Socket;
import java.net.ServerSocket;
import sun.misc.ManagedLocalsThread;
/**
* This is the base class for network servers. To define a new type
@ -73,7 +72,7 @@ public class NetworkServer implements Runnable, Cloneable {
NetworkServer n = (NetworkServer)clone();
n.serverSocket = null;
n.clientSocket = ns;
new ManagedLocalsThread(n).start();
new Thread(null, n, "NetworkServer", 0, false).start();
} catch(Exception e) {
System.out.print("Server failure\n");
e.printStackTrace();
@ -108,7 +107,7 @@ public class NetworkServer implements Runnable, Cloneable {
for each new connection. */
public final void startServer(int port) throws IOException {
serverSocket = new ServerSocket(port, 50);
serverInstance = new ManagedLocalsThread(this);
serverInstance = new Thread(null, this, "NetworkServer", 0, false);
serverInstance.start();
}

@ -27,9 +27,8 @@ package sun.net.www;
import java.net.URL;
import java.io.*;
import java.util.StringTokenizer;
import sun.misc.ManagedLocalsThread;
class MimeLauncher extends ManagedLocalsThread {
class MimeLauncher extends Thread {
java.net.URLConnection uc;
MimeEntry m;
String genericTempFileTemplate;
@ -38,7 +37,7 @@ class MimeLauncher extends ManagedLocalsThread {
MimeLauncher (MimeEntry M, java.net.URLConnection uc,
InputStream is, String tempFileTemplate, String threadName) throws ApplicationLaunchException {
super(threadName);
super(null, null, threadName, 0, false);
m = M;
this.uc = uc;
this.is = is;

@ -30,7 +30,6 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.io.IOException;
import java.util.*;
import sun.misc.ManagedLocalsThread;
/**
* Base implementation of background poller thread used in watch service
@ -60,7 +59,7 @@ abstract class AbstractPoller implements Runnable {
AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Object run() {
Thread thr = new ManagedLocalsThread(thisRunnable);
Thread thr = new Thread(null, thisRunnable, "FileSystemWatchService", 0, false);
thr.setDaemon(true);
thr.start();
return null;

@ -25,7 +25,6 @@
package sun.nio.fs;
import sun.misc.ManagedLocalsThread;
import jdk.internal.misc.Unsafe;
import java.util.concurrent.ExecutionException;
@ -118,7 +117,7 @@ abstract class Cancellable implements Runnable {
* thread by writing into the memory location that it polls cooperatively.
*/
static void runInterruptibly(Cancellable task) throws ExecutionException {
Thread t = new ManagedLocalsThread(task);
Thread t = new Thread(null, task, "NIO-Task", 0, false);
t.start();
boolean cancelledByInterrupt = false;
while (t.isAlive()) {

@ -35,7 +35,6 @@ import java.io.IOException;
import java.util.*;
import java.util.concurrent.*;
import com.sun.nio.file.SensitivityWatchEventModifier;
import sun.misc.ManagedLocalsThread;
/**
* Simple WatchService implementation that uses periodic tasks to poll
@ -59,7 +58,7 @@ class PollingWatchService
.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = new ManagedLocalsThread(r);
Thread t = new Thread(null, r, "FileSystemWatchService", 0, false);
t.setDaemon(true);
return t;
}});

@ -62,7 +62,7 @@ public final class AnnotatedTypeFactory {
decl);
if (type instanceof Class) {
return new AnnotatedTypeBaseImpl(type,
addNesting(type, currentLoc),
currentLoc,
actualTypeAnnos,
allOnSameTarget,
decl);
@ -74,7 +74,7 @@ public final class AnnotatedTypeFactory {
decl);
} else if (type instanceof ParameterizedType) {
return new AnnotatedParameterizedTypeImpl((ParameterizedType)type,
addNesting(type, currentLoc),
currentLoc,
actualTypeAnnos,
allOnSameTarget,
decl);
@ -88,7 +88,7 @@ public final class AnnotatedTypeFactory {
throw new AssertionError("Unknown instance of Type: " + type + "\nThis should not happen.");
}
private static LocationInfo addNesting(Type type, LocationInfo addTo) {
public static LocationInfo nestingForType(Type type, LocationInfo addTo) {
if (isArray(type))
return addTo;
if (type instanceof Class) {
@ -96,13 +96,13 @@ public final class AnnotatedTypeFactory {
if (clz.getEnclosingClass() == null)
return addTo;
if (Modifier.isStatic(clz.getModifiers()))
return addNesting(clz.getEnclosingClass(), addTo);
return addNesting(clz.getEnclosingClass(), addTo.pushInner());
return nestingForType(clz.getEnclosingClass(), addTo);
return nestingForType(clz.getEnclosingClass(), addTo.pushInner());
} else if (type instanceof ParameterizedType) {
ParameterizedType t = (ParameterizedType)type;
if (t.getOwnerType() == null)
return addTo;
return addNesting(t.getOwnerType(), addTo.pushInner());
return nestingForType(t.getOwnerType(), addTo.pushInner());
}
return addTo;
}
@ -118,8 +118,9 @@ public final class AnnotatedTypeFactory {
return false;
}
static final TypeAnnotation[] EMPTY_TYPE_ANNOTATION_ARRAY = new TypeAnnotation[0];
static final AnnotatedType EMPTY_ANNOTATED_TYPE = new AnnotatedTypeBaseImpl(null, LocationInfo.BASE_LOCATION,
new TypeAnnotation[0], new TypeAnnotation[0], null);
EMPTY_TYPE_ANNOTATION_ARRAY, EMPTY_TYPE_ANNOTATION_ARRAY, null);
static final AnnotatedType[] EMPTY_ANNOTATED_TYPE_ARRAY = new AnnotatedType[0];
private static class AnnotatedTypeBaseImpl implements AnnotatedType {
@ -177,6 +178,30 @@ public final class AnnotatedTypeFactory {
return type;
}
@Override
public AnnotatedType getAnnotatedOwnerType() {
if (!(type instanceof Class<?>))
throw new IllegalStateException("Can't compute owner");
Class<?> inner = (Class<?>)type;
Class<?> owner = inner.getDeclaringClass();
if (owner == null) // top-level, local or anonymous
return null;
if (inner.isPrimitive() || inner == Void.TYPE)
return null;
LocationInfo outerLoc = nestingForType(owner, getLocation().popAllLocations((byte)1));
TypeAnnotation[]all = getTypeAnnotations();
List<TypeAnnotation> l = new ArrayList<>(all.length);
for (TypeAnnotation t : all)
if (t.getLocationInfo().isSameLocationInfo(outerLoc))
l.add(t);
return buildAnnotatedType(owner, outerLoc, l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY), all, getDecl());
}
// Implementation details
final LocationInfo getLocation() {
return location;
@ -198,11 +223,17 @@ public final class AnnotatedTypeFactory {
@Override
public AnnotatedType getAnnotatedGenericComponentType() {
return AnnotatedTypeFactory.buildAnnotatedType(getComponentType(),
getLocation().pushArray(),
getTypeAnnotations(),
getTypeAnnotations(),
getDecl());
Type t = getComponentType();
return AnnotatedTypeFactory.buildAnnotatedType(t,
nestingForType(t, getLocation().pushArray()),
getTypeAnnotations(),
getTypeAnnotations(),
getDecl());
}
@Override
public AnnotatedType getAnnotatedOwnerType() {
return null;
}
private Type getComponentType() {
@ -227,6 +258,11 @@ public final class AnnotatedTypeFactory {
return getTypeVariable().getAnnotatedBounds();
}
@Override
public AnnotatedType getAnnotatedOwnerType() {
return null;
}
private TypeVariable<?> getTypeVariable() {
return (TypeVariable)getType();
}
@ -248,19 +284,35 @@ public final class AnnotatedTypeFactory {
int initialCapacity = getTypeAnnotations().length;
for (int i = 0; i < res.length; i++) {
List<TypeAnnotation> l = new ArrayList<>(initialCapacity);
LocationInfo newLoc = getLocation().pushTypeArg((byte)i);
LocationInfo newLoc = nestingForType(arguments[i], getLocation().pushTypeArg((byte)i));
for (TypeAnnotation t : getTypeAnnotations())
if (t.getLocationInfo().isSameLocationInfo(newLoc))
l.add(t);
res[i] = buildAnnotatedType(arguments[i],
newLoc,
l.toArray(new TypeAnnotation[0]),
getTypeAnnotations(),
getDecl());
newLoc,
l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY),
getTypeAnnotations(),
getDecl());
}
return res;
}
@Override
public AnnotatedType getAnnotatedOwnerType() {
Type owner = getParameterizedType().getOwnerType();
if (owner == null)
return null;
LocationInfo outerLoc = nestingForType(owner, getLocation().popAllLocations((byte)1));
TypeAnnotation[]all = getTypeAnnotations();
List<TypeAnnotation> l = new ArrayList<>(all.length);
for (TypeAnnotation t : all)
if (t.getLocationInfo().isSameLocationInfo(outerLoc))
l.add(t);
return buildAnnotatedType(owner, outerLoc, l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY), all, getDecl());
}
private ParameterizedType getParameterizedType() {
return (ParameterizedType)getType();
}
@ -279,11 +331,11 @@ public final class AnnotatedTypeFactory {
public AnnotatedType[] getAnnotatedUpperBounds() {
if (!hasUpperBounds()) {
return new AnnotatedType[] { buildAnnotatedType(Object.class,
LocationInfo.BASE_LOCATION,
new TypeAnnotation[0],
new TypeAnnotation[0],
null)
};
LocationInfo.BASE_LOCATION,
EMPTY_TYPE_ANNOTATION_ARRAY,
EMPTY_TYPE_ANNOTATION_ARRAY,
null)
};
}
return getAnnotatedBounds(getWildcardType().getUpperBounds());
}
@ -295,21 +347,26 @@ public final class AnnotatedTypeFactory {
return getAnnotatedBounds(getWildcardType().getLowerBounds());
}
@Override
public AnnotatedType getAnnotatedOwnerType() {
return null;
}
private AnnotatedType[] getAnnotatedBounds(Type[] bounds) {
AnnotatedType[] res = new AnnotatedType[bounds.length];
Arrays.fill(res, EMPTY_ANNOTATED_TYPE);
LocationInfo newLoc = getLocation().pushWildcard();
int initialCapacity = getTypeAnnotations().length;
for (int i = 0; i < res.length; i++) {
LocationInfo newLoc = nestingForType(bounds[i], getLocation().pushWildcard());
List<TypeAnnotation> l = new ArrayList<>(initialCapacity);
for (TypeAnnotation t : getTypeAnnotations())
if (t.getLocationInfo().isSameLocationInfo(newLoc))
l.add(t);
res[i] = buildAnnotatedType(bounds[i],
newLoc,
l.toArray(new TypeAnnotation[0]),
getTypeAnnotations(),
getDecl());
newLoc,
l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY),
getTypeAnnotations(),
getDecl());
}
return res;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
@ -187,13 +187,28 @@ public final class TypeAnnotation {
return new LocationInfo(newDepth, res);
}
/** Pop a series of locations matching {@code tag}. Stop poping as soon as a non-matching tag is found. */
public LocationInfo popAllLocations(byte tag) {
LocationInfo l = this;
int newDepth = l.depth;
while(newDepth > 0 && l.locations[newDepth - 1].tag == tag) {
newDepth--;
}
if (newDepth != l.depth) {
Location[] res = new Location[newDepth];
System.arraycopy(this.locations, 0, res, 0, newDepth);
return new LocationInfo(newDepth, res);
} else
return l;
}
public TypeAnnotation[] filter(TypeAnnotation[] ta) {
ArrayList<TypeAnnotation> l = new ArrayList<>(ta.length);
for (TypeAnnotation t : ta) {
if (isSameLocationInfo(t.getLocationInfo()))
l.add(t);
}
return l.toArray(new TypeAnnotation[0]);
return l.toArray(AnnotatedTypeFactory.EMPTY_TYPE_ANNOTATION_ARRAY);
}
boolean isSameLocationInfo(LocationInfo other) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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,7 +32,6 @@ import java.nio.BufferUnderflowException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import jdk.internal.misc.SharedSecrets;
@ -67,9 +66,8 @@ public final class TypeAnnotationParser {
Type type,
TypeAnnotationTarget filter) {
TypeAnnotation[] tas = parseTypeAnnotations(rawAnnotations,
cp,
decl,
container);
cp, decl, container);
List<TypeAnnotation> l = new ArrayList<>(tas.length);
for (TypeAnnotation t : tas) {
TypeAnnotationTargetInfo ti = t.getTargetInfo();
@ -78,10 +76,10 @@ public final class TypeAnnotationParser {
}
TypeAnnotation[] typeAnnotations = l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY);
return AnnotatedTypeFactory.buildAnnotatedType(type,
LocationInfo.BASE_LOCATION,
typeAnnotations,
typeAnnotations,
decl);
AnnotatedTypeFactory.nestingForType(type, LocationInfo.BASE_LOCATION),
typeAnnotations,
typeAnnotations,
decl);
}
/**
@ -110,9 +108,8 @@ public final class TypeAnnotationParser {
ArrayList[] l = new ArrayList[size]; // array of ArrayList<TypeAnnotation>
TypeAnnotation[] tas = parseTypeAnnotations(rawAnnotations,
cp,
decl,
container);
cp, decl, container);
for (TypeAnnotation t : tas) {
TypeAnnotationTargetInfo ti = t.getTargetInfo();
if (ti.getTarget() == filter) {
@ -136,10 +133,10 @@ public final class TypeAnnotationParser {
typeAnnotations = EMPTY_TYPE_ANNOTATION_ARRAY;
}
result[i] = AnnotatedTypeFactory.buildAnnotatedType(types[i],
LocationInfo.BASE_LOCATION,
typeAnnotations,
typeAnnotations,
decl);
AnnotatedTypeFactory.nestingForType(types[i], LocationInfo.BASE_LOCATION),
typeAnnotations,
typeAnnotations,
decl);
}
return result;
@ -278,7 +275,7 @@ public final class TypeAnnotationParser {
}
}
res[i] = AnnotatedTypeFactory.buildAnnotatedType(bounds[i],
loc,
AnnotatedTypeFactory.nestingForType(bounds[i], loc),
l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY),
candidates.toArray(EMPTY_TYPE_ANNOTATION_ARRAY),
(AnnotatedElement)decl);

@ -39,7 +39,7 @@ import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import sun.security.x509.*;
import sun.security.util.*;

@ -38,7 +38,7 @@ import sun.security.util.DerValue;
import sun.security.util.DerInputStream;
import sun.security.util.DerOutputStream;
import sun.security.util.ObjectIdentifier;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
/**
* Class supporting any PKCS9 attributes.

@ -41,7 +41,7 @@ import sun.security.util.*;
import sun.security.x509.AlgorithmId;
import sun.security.x509.X500Name;
import sun.security.x509.KeyUsageExtension;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
/**
* A SignerInfo, as defined in PKCS#7's signedData type.

@ -28,7 +28,7 @@ package sun.security.pkcs;
import java.io.IOException;
import java.util.ArrayList;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import sun.security.util.DerInputStream;
import sun.security.util.DerValue;
import sun.security.x509.GeneralNames;

@ -75,7 +75,6 @@ import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Random;
import sun.misc.ManagedLocalsThread;
import sun.security.util.Debug;
abstract class SeedGenerator {
@ -305,9 +304,11 @@ abstract class SeedGenerator {
}
finalsg[0] = new ThreadGroup
(group, "SeedGenerator ThreadGroup");
Thread newT = new ManagedLocalsThread(finalsg[0],
Thread newT = new Thread(finalsg[0],
ThreadedSeedGenerator.this,
"SeedGenerator Thread");
"SeedGenerator Thread",
0,
false);
newT.setPriority(Thread.MIN_PRIORITY);
newT.setDaemon(true);
return newT;
@ -342,8 +343,8 @@ abstract class SeedGenerator {
// Start some noisy threads
try {
BogusThread bt = new BogusThread();
Thread t = new ManagedLocalsThread
(seedGroup, bt, "SeedGenerator Thread");
Thread t = new Thread
(seedGroup, bt, "SeedGenerator Thread", 0, false);
t.start();
} catch (Exception e) {
throw new InternalError("internal error: " +

@ -33,7 +33,7 @@ import java.security.PublicKey;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import javax.security.auth.x500.X500Principal;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import sun.security.x509.*;
import sun.security.util.*;

@ -30,7 +30,7 @@ import java.security.cert.Extension;
import java.util.Collections;
import java.util.List;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import sun.security.util.*;
import sun.security.x509.PKIXExtensions;

@ -44,7 +44,7 @@ import java.util.Map;
import java.util.Set;
import javax.security.auth.x500.X500Principal;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import sun.security.action.GetIntegerAction;
import sun.security.x509.*;
import sun.security.util.*;

@ -42,7 +42,7 @@ import sun.security.ssl.CipherSuite.*;
import static sun.security.ssl.CipherSuite.*;
import static sun.security.ssl.CipherSuite.CipherType.*;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
/**

@ -32,7 +32,7 @@ import javax.crypto.BadPaddingException;
import javax.net.ssl.*;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import static sun.security.ssl.HandshakeMessage.*;
/**

@ -33,7 +33,7 @@ import javax.crypto.BadPaddingException;
import javax.net.ssl.*;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import static sun.security.ssl.Ciphertext.RecordType;
/**

@ -29,7 +29,7 @@ import java.io.PrintStream;
import java.security.AccessController;
import java.util.Locale;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import java.nio.ByteBuffer;
import sun.security.action.GetPropertyAction;

@ -41,7 +41,7 @@ import javax.crypto.*;
import javax.crypto.spec.*;
import javax.net.ssl.*;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import sun.security.internal.spec.*;
import sun.security.internal.interfaces.TlsMasterSecret;

@ -33,7 +33,7 @@ import javax.crypto.BadPaddingException;
import javax.net.ssl.*;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
/**

@ -30,7 +30,7 @@ import java.nio.*;
import java.util.Arrays;
import javax.net.ssl.SSLException;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
/**

@ -32,7 +32,7 @@ import javax.crypto.BadPaddingException;
import javax.net.ssl.*;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
/**

@ -31,7 +31,7 @@ import java.util.*;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import static sun.security.ssl.Ciphertext.RecordType;
/**

@ -40,7 +40,6 @@ import java.util.concurrent.locks.ReentrantLock;
import javax.crypto.BadPaddingException;
import javax.net.ssl.*;
import sun.misc.ManagedLocalsThread;
import jdk.internal.misc.JavaNetInetAddressAccess;
import jdk.internal.misc.SharedSecrets;
@ -1153,10 +1152,13 @@ public final class SSLSocketImpl extends BaseSSLSocketImpl {
HandshakeCompletedEvent event =
new HandshakeCompletedEvent(this, sess);
Thread thread = new ManagedLocalsThread(
Thread thread = new Thread(
null,
new NotifyHandshake(
handshakeListeners.entrySet(), event),
"HandshakeCompletedNotify-Thread");
"HandshakeCompletedNotify-Thread",
0,
false);
thread.start();
}
}

@ -32,7 +32,7 @@ import javax.crypto.BadPaddingException;
import javax.net.ssl.*;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
/**

@ -31,7 +31,7 @@ import java.util.Arrays;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
/**

@ -2956,7 +2956,7 @@ public final class Main {
if (v.length == 0) {
out.println(rb.getString(".Empty.value."));
} else {
new sun.misc.HexDumpEncoder().encodeBuffer(ext.getExtensionValue(), out);
new sun.security.util.HexDumpEncoder().encodeBuffer(ext.getExtensionValue(), out);
out.println();
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 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,106 +23,114 @@
* questions.
*/
package sun.misc;
import java.io.InputStream;
package sun.security.util;
import java.io.ByteArrayInputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
/**
* This class defines the encoding half of character encoders.
* A character encoder is an algorithim for transforming 8 bit binary
* data into text (generally 7 bit ASCII or 8 bit ISO-Latin-1 text)
* for transmition over text channels such as e-mail and network news.
*
* The character encoders have been structured around a central theme
* that, in general, the encoded text has the form:
*
* This class encodes a buffer into the classic: "Hexadecimal Dump" format of
* the past. It is useful for analyzing the contents of binary buffers.
* The format produced is as follows:
* <pre>
* [Buffer Prefix]
* [Line Prefix][encoded data atoms][Line Suffix]
* [Buffer Suffix]
* xxxx: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff ................
* </pre>
*
* In the CharacterEncoder and CharacterDecoder classes, one complete
* chunk of data is referred to as a <i>buffer</i>. Encoded buffers
* are all text, and decoded buffers (sometimes just referred to as
* buffers) are binary octets.
*
* To create a custom encoder, you must, at a minimum, overide three
* abstract methods in this class.
* <DL>
* <DD>bytesPerAtom which tells the encoder how many bytes to
* send to encodeAtom
* <DD>encodeAtom which encodes the bytes sent to it as text.
* <DD>bytesPerLine which tells the encoder the maximum number of
* bytes per line.
* </DL>
*
* Several useful encoders have already been written and are
* referenced in the See Also list below.
* Where xxxx is the offset into the buffer in 16 byte chunks, followed
* by ascii coded hexadecimal bytes followed by the ASCII representation of
* the bytes or '.' if they are not valid bytes.
*
* @author Chuck McManis
* @see CharacterDecoder
* @see UCEncoder
* @see UUEncoder
* @see BASE64Encoder
*/
public abstract class CharacterEncoder {
public class HexDumpEncoder {
private int offset;
private int thisLineLength;
private int currentByte;
private byte thisLine[] = new byte[16];
static void hexDigit(PrintStream p, byte x) {
char c;
c = (char) ((x >> 4) & 0xf);
if (c > 9)
c = (char) ((c-10) + 'A');
else
c = (char)(c + '0');
p.write(c);
c = (char) (x & 0xf);
if (c > 9)
c = (char)((c-10) + 'A');
else
c = (char)(c + '0');
p.write(c);
}
protected int bytesPerAtom() {
return (1);
}
protected int bytesPerLine() {
return (16);
}
protected void encodeBufferPrefix(OutputStream o) throws IOException {
offset = 0;
pStream = new PrintStream(o);
}
protected void encodeLinePrefix(OutputStream o, int len) throws IOException {
hexDigit(pStream, (byte)((offset >>> 8) & 0xff));
hexDigit(pStream, (byte)(offset & 0xff));
pStream.print(": ");
currentByte = 0;
thisLineLength = len;
}
protected void encodeAtom(OutputStream o, byte buf[], int off, int len) throws IOException {
thisLine[currentByte] = buf[off];
hexDigit(pStream, buf[off]);
pStream.print(" ");
currentByte++;
if (currentByte == 8)
pStream.print(" ");
}
protected void encodeLineSuffix(OutputStream o) throws IOException {
if (thisLineLength < 16) {
for (int i = thisLineLength; i < 16; i++) {
pStream.print(" ");
if (i == 7)
pStream.print(" ");
}
}
pStream.print(" ");
for (int i = 0; i < thisLineLength; i++) {
if ((thisLine[i] < ' ') || (thisLine[i] > 'z')) {
pStream.print(".");
} else {
pStream.write(thisLine[i]);
}
}
pStream.println();
offset += thisLineLength;
}
/** Stream that understands "printing" */
protected PrintStream pStream;
/** Return the number of bytes per atom of encoding */
protected abstract int bytesPerAtom();
/** Return the number of bytes that can be encoded per line */
protected abstract int bytesPerLine();
/**
* Encode the prefix for the entire buffer. By default is simply
* opens the PrintStream for use by the other functions.
*/
protected void encodeBufferPrefix(OutputStream aStream) throws IOException {
pStream = new PrintStream(aStream);
}
/**
* Encode the suffix for the entire buffer.
*/
protected void encodeBufferSuffix(OutputStream aStream) throws IOException {
}
/**
* Encode the prefix that starts every output line.
*/
protected void encodeLinePrefix(OutputStream aStream, int aLength)
throws IOException {
}
/**
* Encode the suffix that ends every output line. By default
* this method just prints a newline into the output stream.
*/
protected void encodeLineSuffix(OutputStream aStream) throws IOException {
pStream.println();
}
/** Encode one "atom" of information into characters. */
protected abstract void encodeAtom(OutputStream aStream, byte someBytes[],
int anOffset, int aLength) throws IOException;
/**
* This method works around the bizarre semantics of BufferedInputStream's
* read method.
*/
protected int readFully(InputStream in, byte buffer[])
throws java.io.IOException {
throws java.io.IOException {
for (int i = 0; i < buffer.length; i++) {
int q = in.read();
if (q == -1)
@ -139,7 +147,8 @@ public abstract class CharacterEncoder {
* line that is shorter than bytesPerLine().
*/
public void encode(InputStream inStream, OutputStream outStream)
throws IOException {
throws IOException
{
int j;
int numBytes;
byte tmpbuffer[] = new byte[bytesPerLine()];
@ -166,17 +175,6 @@ public abstract class CharacterEncoder {
encodeLineSuffix(outStream);
}
}
encodeBufferSuffix(outStream);
}
/**
* Encode the buffer in <i>aBuffer</i> and write the encoded
* result to the OutputStream <i>aStream</i>.
*/
public void encode(byte aBuffer[], OutputStream aStream)
throws IOException {
ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
encode(inStream, aStream);
}
/**
@ -184,7 +182,7 @@ public abstract class CharacterEncoder {
* bytes and returns a string containing the encoded buffer.
*/
public String encode(byte aBuffer[]) {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
String retVal = null;
try {
@ -244,18 +242,6 @@ public abstract class CharacterEncoder {
return buf;
}
/**
* Encode the <i>aBuffer</i> ByteBuffer and write the encoded
* result to the OutputStream <i>aStream</i>.
* <P>
* The ByteBuffer's position will be advanced to ByteBuffer's limit.
*/
public void encode(ByteBuffer aBuffer, OutputStream aStream)
throws IOException {
byte [] buf = getBytes(aBuffer);
encode(buf, aStream);
}
/**
* A 'streamless' version of encode that simply takes a ByteBuffer
* and returns a string containing the encoded buffer.
@ -274,7 +260,8 @@ public abstract class CharacterEncoder {
* line at the end of a final line that is shorter than bytesPerLine().
*/
public void encodeBuffer(InputStream inStream, OutputStream outStream)
throws IOException {
throws IOException
{
int j;
int numBytes;
byte tmpbuffer[] = new byte[bytesPerLine()];
@ -299,7 +286,6 @@ public abstract class CharacterEncoder {
break;
}
}
encodeBufferSuffix(outStream);
}
/**
@ -307,7 +293,8 @@ public abstract class CharacterEncoder {
* result to the OutputStream <i>aStream</i>.
*/
public void encodeBuffer(byte aBuffer[], OutputStream aStream)
throws IOException {
throws IOException
{
ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
encodeBuffer(inStream, aStream);
}
@ -335,20 +322,10 @@ public abstract class CharacterEncoder {
* The ByteBuffer's position will be advanced to ByteBuffer's limit.
*/
public void encodeBuffer(ByteBuffer aBuffer, OutputStream aStream)
throws IOException {
throws IOException
{
byte [] buf = getBytes(aBuffer);
encodeBuffer(buf, aStream);
}
/**
* A 'streamless' version of encode that simply takes a ByteBuffer
* and returns a string containing the encoded buffer.
* <P>
* The ByteBuffer's position will be advanced to ByteBuffer's limit.
*/
public String encodeBuffer(ByteBuffer aBuffer) {
byte [] buf = getBytes(aBuffer);
return encodeBuffer(buf);
}
}

@ -443,7 +443,7 @@ public class SignatureFileVerifier {
if (sfAttr != null) {
//sun.misc.HexDumpEncoder hex = new sun.misc.HexDumpEncoder();
//sun.security.util.HexDumpEncoder hex = new sun.security.util.HexDumpEncoder();
//hex.encodeBuffer(data, System.out);
// go through all the attributes and process *-Digest entries

@ -33,7 +33,7 @@ import java.lang.reflect.InvocationTargetException;
import java.security.cert.CertificateException;
import java.util.*;
import sun.misc.HexDumpEncoder;
import sun.security.util.HexDumpEncoder;
import sun.security.util.*;
@ -376,6 +376,6 @@ class UnparseableExtension extends Extension {
@Override public String toString() {
return super.toString() +
"Unparseable " + name + "extension due to\n" + why + "\n\n" +
new sun.misc.HexDumpEncoder().encodeBuffer(getExtensionValue());
new HexDumpEncoder().encodeBuffer(getExtensionValue());
}
}

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