Merge
@ -180,6 +180,8 @@ ifeq ($(OPENJDK_TARGET_OS), solaris)
|
||||
OBJECT_DIR := $(BUILDTOOLS_OUTPUTDIR)/objs/fix_empty_sec_hdr_flags, \
|
||||
OUTPUT_DIR := $(BUILDTOOLS_OUTPUTDIR)/bin, \
|
||||
PROGRAM := fix_empty_sec_hdr_flags))
|
||||
|
||||
BUILD_TOOLS_JDK += $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS)
|
||||
endif
|
||||
|
||||
$(BUILD_TOOLS_JDK): $(BUILD_INTERIM_JIMAGE) $(COPY_JIMAGE_SERVICE_PROVIDER)
|
||||
@ -189,4 +191,3 @@ java-tools: $(BUILD_TOOLS_JDK)
|
||||
all: java-tools
|
||||
|
||||
endif # _TOOLS_GMK
|
||||
|
||||
|
@ -100,34 +100,3 @@ $(LIB_DST_DIR)/%: $(PSFONTPROPFILE_SRC_DIR)/%
|
||||
TARGETS += $(PSFONTPROPFILE_TARGET_FILES)
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Copy cursor.properties and cursors gif files to LIB_DST_DIR
|
||||
#
|
||||
ifneq ($(OPENJDK_TARGET_OS), macosx)
|
||||
OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/conf
|
||||
else
|
||||
OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/macosx/conf
|
||||
endif
|
||||
|
||||
CURSORS_DEST_DIR := $(LIB_DST_DIR)/images/cursors
|
||||
CURSORS_OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/conf/images/cursors
|
||||
|
||||
$(CURSORS_DEST_DIR)/cursors.properties: $(CURSORS_OPENJDK_TARGET_OS_LIB_SRC)/cursors.properties
|
||||
$(call install-file)
|
||||
|
||||
TARGETS += $(CURSORS_DEST_DIR)/cursors.properties
|
||||
|
||||
CURSORS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/share/conf/images/cursors
|
||||
ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||
CURSORS_SRC_FILES := $(CURSORS_LIB_SRC)/invalid32x32.gif $(wildcard $(CURSORS_LIB_SRC)/win32_*.gif)
|
||||
else # OPENJDK_TARGET_OS
|
||||
CURSORS_SRC_FILES := $(CURSORS_LIB_SRC)/invalid32x32.gif $(wildcard $(CURSORS_LIB_SRC)/motif_*.gif)
|
||||
endif # OPENJDK_TARGET_OS
|
||||
CURSORS_TARGET_FILES := $(subst $(CURSORS_LIB_SRC),$(CURSORS_DEST_DIR),$(CURSORS_SRC_FILES))
|
||||
|
||||
$(CURSORS_DEST_DIR)/%: $(CURSORS_LIB_SRC)/%
|
||||
$(call install-file)
|
||||
|
||||
TARGETS += $(CURSORS_TARGET_FILES)
|
||||
|
||||
################################################################################
|
||||
|
@ -66,8 +66,11 @@ else
|
||||
PROP_SRC_DIRS += $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/resources
|
||||
endif
|
||||
|
||||
PROP_SRC_FILES := $(filter-out %cursors.properties, \
|
||||
$(filter %.properties, $(call CacheFind, $(PROP_SRC_DIRS))))
|
||||
|
||||
$(eval $(call SetupCompileProperties,COMPILE_PROPERTIES, \
|
||||
$(filter %.properties, $(call CacheFind, $(PROP_SRC_DIRS))), ListResourceBundle))
|
||||
$(PROP_SRC_FILES), ListResourceBundle))
|
||||
|
||||
GENSRC_JAVA_DESKTOP += $(COMPILE_PROPERTIES)
|
||||
|
||||
|
@ -25,6 +25,9 @@
|
||||
|
||||
include GensrcCommon.gmk
|
||||
|
||||
# Hook to include the corresponding custom file, if present.
|
||||
$(eval $(call IncludeCustomExtension, jdk, gensrc/Gensrc-java.management.gmk))
|
||||
|
||||
################################################################################
|
||||
|
||||
include GensrcProperties.gmk
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -114,38 +114,9 @@ ifeq ($(OPENJDK_TARGET_OS), solaris)
|
||||
endif # OPENJDK_TARGET_OS solaris
|
||||
|
||||
|
||||
ifeq ($(JVM_VARIANT_ZERO), true)
|
||||
LIBJSOUND_CFLAGS += -DX_ARCH=X_ZERO
|
||||
else
|
||||
ifeq ($(OPENJDK_TARGET_CPU), x86)
|
||||
LIBJSOUND_CFLAGS += -DX_ARCH=X_I586
|
||||
ifeq ($(OPENJDK_TARGET_CPU), aarch64)
|
||||
LIBJSOUND_CFLAGS += -DX_ARCH=X_AARCH64
|
||||
endif
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_CPU), sparc)
|
||||
LIBJSOUND_CFLAGS += -DX_ARCH=X_SPARC
|
||||
endif
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
|
||||
LIBJSOUND_CFLAGS += -DX_ARCH=X_SPARCV9
|
||||
endif
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_CPU), x86_64)
|
||||
LIBJSOUND_CFLAGS += -DX_ARCH=X_AMD64
|
||||
endif
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_CPU), arm)
|
||||
LIBJSOUND_CFLAGS += -DX_ARCH=X_ARM
|
||||
endif
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_CPU), ppc)
|
||||
LIBJSOUND_CFLAGS += -DX_ARCH=X_PPC
|
||||
endif
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_CPU), ppc64)
|
||||
LIBJSOUND_CFLAGS += -DX_ARCH=X_PPC64
|
||||
endif
|
||||
endif
|
||||
|
||||
LIBJSOUND_CFLAGS += -DEXTRA_SOUND_JNI_LIBS='"$(EXTRA_SOUND_JNI_LIBS)"'
|
||||
|
||||
$(eval $(call SetupNativeCompilation,BUILD_LIBJSOUND, \
|
||||
|
@ -68,7 +68,6 @@ SUNWprivate_1.1 {
|
||||
Java_com_sun_media_sound_Platform_nGetExtraLibraries;
|
||||
Java_com_sun_media_sound_Platform_nGetLibraryForFeature;
|
||||
Java_com_sun_media_sound_Platform_nIsBigEndian;
|
||||
Java_com_sun_media_sound_Platform_nIsSigned8;
|
||||
Java_com_sun_media_sound_PortMixer_nClose;
|
||||
Java_com_sun_media_sound_PortMixer_nControlGetFloatValue;
|
||||
Java_com_sun_media_sound_PortMixer_nControlGetIntValue;
|
||||
|
@ -22,6 +22,7 @@ jdk.deploy.osx
|
||||
jdk.hprof.agent
|
||||
jdk.httpserver
|
||||
jdk.jfr
|
||||
jdk.management.cmm
|
||||
jdk.naming.rmi
|
||||
jdk.sctp
|
||||
jdk.security.auth
|
||||
|
82
jdk/make/test/JtregNative.gmk
Normal file
@ -0,0 +1,82 @@
|
||||
#
|
||||
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
################################################################################
|
||||
# This file builds the native component of the JTReg tests for JDK.
|
||||
# It also covers the test-image part, where the built files are copied to the
|
||||
# test image.
|
||||
################################################################################
|
||||
|
||||
default: all
|
||||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
include TestFilesCompilation.gmk
|
||||
|
||||
################################################################################
|
||||
# Targets for building the native tests themselves.
|
||||
################################################################################
|
||||
|
||||
# Add more directories here when needed.
|
||||
BUILD_JDK_JTREG_NATIVE_SRC := \
|
||||
$(JDK_TOPDIR)/test/native_sanity \
|
||||
#
|
||||
|
||||
BUILD_JDK_JTREG_OUTPUT_DIR := $(BUILD_OUTPUT)/support/test/jdk/jtreg/native
|
||||
|
||||
BUILD_JDK_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/jdk/jtreg
|
||||
|
||||
$(eval $(call SetupTestFilesCompilation, BUILD_JDK_JTREG_LIBRARIES, \
|
||||
TYPE := LIBRARY, \
|
||||
SOURCE_DIRS := $(BUILD_JDK_JTREG_NATIVE_SRC), \
|
||||
OUTPUT_DIR := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
|
||||
))
|
||||
|
||||
$(eval $(call SetupTestFilesCompilation, BUILD_JDK_JTREG_EXECUTABLES, \
|
||||
TYPE := PROGRAM, \
|
||||
SOURCE_DIRS := $(BUILD_JDK_JTREG_NATIVE_SRC), \
|
||||
OUTPUT_DIR := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
|
||||
))
|
||||
|
||||
build-test-jdk-jtreg-native: $(BUILD_JDK_JTREG_LIBRARIES) $(BUILD_JDK_JTREG_EXECUTABLES)
|
||||
|
||||
|
||||
################################################################################
|
||||
# Targets for building test-image.
|
||||
################################################################################
|
||||
|
||||
# Copy to jdk jtreg test image
|
||||
$(eval $(call SetupCopyFiles,COPY_JDK_JTREG_NATIVE, \
|
||||
SRC := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
|
||||
DEST := $(TEST_IMAGE_DIR)/jdk/jtreg/native, \
|
||||
FILES := $(BUILD_JDK_JTREG_LIBRARIES) $(BUILD_JDK_JTREG_EXECUTABLES), \
|
||||
FLATTEN := true))
|
||||
|
||||
test-image-jdk-jtreg-native: $(COPY_JDK_JTREG_NATIVE)
|
||||
|
||||
all: build-test-jdk-jtreg-native
|
||||
test-image: test-image-jdk-jtreg-native
|
||||
|
||||
.PHONY: default all build-test-jdk-jtreg-native test-image-jdk-jtreg-native test-image
|
@ -40,6 +40,7 @@ import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import static java.io.ObjectStreamClass.processQueue;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.reflect.misc.ReflectUtil;
|
||||
|
||||
/**
|
||||
@ -375,6 +376,7 @@ public class ObjectInputStream
|
||||
}
|
||||
if (depth == 0) {
|
||||
vlist.doCallbacks();
|
||||
freeze();
|
||||
}
|
||||
return obj;
|
||||
} finally {
|
||||
@ -465,6 +467,7 @@ public class ObjectInputStream
|
||||
}
|
||||
if (depth == 0) {
|
||||
vlist.doCallbacks();
|
||||
freeze();
|
||||
}
|
||||
return obj;
|
||||
} finally {
|
||||
@ -2357,6 +2360,26 @@ public class ObjectInputStream
|
||||
}
|
||||
}
|
||||
|
||||
private static final Unsafe UNSAFE = Unsafe.getUnsafe();
|
||||
|
||||
/**
|
||||
* Performs a "freeze" action, required to adhere to final field semantics.
|
||||
*
|
||||
* <p> This method can be called unconditionally before returning the graph,
|
||||
* from the topmost readObject call, since it is expected that the
|
||||
* additional cost of the freeze action is negligible compared to
|
||||
* reconstituting even the most simple graph.
|
||||
*
|
||||
* <p> Nested calls to readObject do not issue freeze actions because the
|
||||
* sub-graph returned from a nested call is not guaranteed to be fully
|
||||
* initialized yet (possible cycles).
|
||||
*/
|
||||
private void freeze() {
|
||||
// Issue a StoreStore|StoreLoad fence, which is at least sufficient
|
||||
// to provide final-freeze semantics.
|
||||
UNSAFE.storeFence();
|
||||
}
|
||||
|
||||
/**
|
||||
* Input stream with two modes: in default mode, inputs data written in the
|
||||
* same format as DataOutputStream; in "block data" mode, inputs data
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -60,6 +60,7 @@ import java.lang.annotation.*;
|
||||
* @jls 4.3.2. The Class Object
|
||||
* @jls 9.8 Functional Interfaces
|
||||
* @jls 9.4.3 Interface Method Body
|
||||
* @jls 9.6.4.9 @FunctionalInterface
|
||||
* @since 1.8
|
||||
*/
|
||||
@Documented
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -43,7 +43,9 @@ import java.lang.annotation.*;
|
||||
*
|
||||
* @author Peter von der Ahé
|
||||
* @author Joshua Bloch
|
||||
* @jls 9.6.1.4 @Override
|
||||
* @jls 8.4.8 Inheritance, Overriding, and Hiding
|
||||
* @jls 9.4.1 Inheritance and Overriding
|
||||
* @jls 9.6.4.4 @Override
|
||||
* @since 1.5
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 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
|
||||
@ -85,7 +85,7 @@ import java.lang.annotation.*;
|
||||
* @since 1.7
|
||||
* @jls 4.7 Reifiable Types
|
||||
* @jls 8.4.1 Formal Parameters
|
||||
* @jls 9.6.3.7 @SafeVarargs
|
||||
* @jls 9.6.4.7 @SafeVarargs
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 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
|
||||
@ -47,7 +47,7 @@ import static java.lang.annotation.ElementType.*;
|
||||
* @jls 4.12.2 Variables of Reference Type
|
||||
* @jls 5.1.9 Unchecked Conversion
|
||||
* @jls 5.5.2 Checked Casts and Unchecked Casts
|
||||
* @jls 9.6.3.5 @SuppressWarnings
|
||||
* @jls 9.6.4.5 @SuppressWarnings
|
||||
*/
|
||||
@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -44,7 +44,7 @@ package java.lang.annotation;
|
||||
*
|
||||
* @author Joshua Bloch
|
||||
* @since 1.5
|
||||
* @jls 9.6.3.3 @Inherited
|
||||
* @jls 9.6.4.3 @Inherited
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -33,8 +33,8 @@ package java.lang.annotation;
|
||||
* type</em> for the repeatable annotation type.
|
||||
*
|
||||
* @since 1.8
|
||||
* @jls 9.6 Annotation Types
|
||||
* @jls 9.7 Annotations
|
||||
* @jls 9.6.3 Repeatable Annotation Types
|
||||
* @jls 9.7.5 Multiple Annotations of the Same Type
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -38,7 +38,7 @@ package java.lang.annotation;
|
||||
*
|
||||
* @author Joshua Bloch
|
||||
* @since 1.5
|
||||
* @jls 9.6.3.2 @Retention
|
||||
* @jls 9.6.4.2 @Retention
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -72,6 +72,7 @@ package java.lang.annotation;
|
||||
* @since 1.5
|
||||
* @jls 9.6.4.1 @Target
|
||||
* @jls 9.7.4 Where Annotations May Appear
|
||||
* @jls 9.7.5 Multiple Annotations of the Same Type
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -436,7 +436,7 @@ class LambdaFormEditor {
|
||||
}
|
||||
|
||||
private MethodType bindArgumentType(BoundMethodHandle mh, int pos, BasicType bt) {
|
||||
assert(mh.form == lambdaForm);
|
||||
assert(mh.form.uncustomize() == lambdaForm);
|
||||
assert(mh.form.names[1+pos].type == bt);
|
||||
assert(BasicType.basicType(mh.type().parameterType(pos)) == bt);
|
||||
return mh.type().dropParameterTypes(pos, pos+1);
|
||||
|
@ -3740,8 +3740,8 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||
throw new ExceptionInInitializerError(ex);
|
||||
}
|
||||
}
|
||||
static void setIntCompactVolatile(BigDecimal bd, long val) {
|
||||
unsafe.putLongVolatile(bd, intCompactOffset, val);
|
||||
static void setIntCompact(BigDecimal bd, long val) {
|
||||
unsafe.putLong(bd, intCompactOffset, val);
|
||||
}
|
||||
|
||||
static void setIntValVolatile(BigDecimal bd, BigInteger val) {
|
||||
@ -3765,7 +3765,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||
throw new java.io.StreamCorruptedException(message);
|
||||
// [all values of scale are now allowed]
|
||||
}
|
||||
UnsafeHolder.setIntCompactVolatile(this, compactValFor(intVal));
|
||||
UnsafeHolder.setIntCompact(this, compactValFor(intVal));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4368,11 +4368,11 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
}
|
||||
|
||||
static void putSign(BigInteger bi, int sign) {
|
||||
unsafe.putIntVolatile(bi, signumOffset, sign);
|
||||
unsafe.putInt(bi, signumOffset, sign);
|
||||
}
|
||||
|
||||
static void putMag(BigInteger bi, int[] magnitude) {
|
||||
unsafe.putObjectVolatile(bi, magOffset, magnitude);
|
||||
unsafe.putObject(bi, magOffset, magnitude);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -3427,11 +3427,8 @@ public final class Files {
|
||||
* reflect updates to the directory that occur after returning from this
|
||||
* method.
|
||||
*
|
||||
* <p> The returned stream encapsulates a {@link DirectoryStream}.
|
||||
* If timely disposal of file system resources is required, the
|
||||
* {@code try}-with-resources construct should be used to ensure that the
|
||||
* stream's {@link Stream#close close} method is invoked after the stream
|
||||
* operations are completed.
|
||||
* <p> The returned stream contains a reference to an open directory.
|
||||
* The directory is closed by closing the stream.
|
||||
*
|
||||
* <p> Operating on a closed stream behaves as if the end of stream
|
||||
* has been reached. Due to read-ahead, one or more elements may be
|
||||
@ -3442,6 +3439,11 @@ public final class Files {
|
||||
* UncheckedIOException} which will be thrown from the method that caused
|
||||
* the access to take place.
|
||||
*
|
||||
* @apiNote
|
||||
* This method must be used within a try-with-resources statement or similar
|
||||
* control structure to ensure that the stream's open directory is closed
|
||||
* promptly after the stream's operations have completed.
|
||||
*
|
||||
* @param dir The path to the directory
|
||||
*
|
||||
* @return The {@code Stream} describing the content of the
|
||||
@ -3549,18 +3551,19 @@ public final class Files {
|
||||
* <p> When a security manager is installed and it denies access to a file
|
||||
* (or directory), then it is ignored and not included in the stream.
|
||||
*
|
||||
* <p> The returned stream encapsulates one or more {@link DirectoryStream}s.
|
||||
* If timely disposal of file system resources is required, the
|
||||
* {@code try}-with-resources construct should be used to ensure that the
|
||||
* stream's {@link Stream#close close} method is invoked after the stream
|
||||
* operations are completed. Operating on a closed stream will result in an
|
||||
* {@link java.lang.IllegalStateException}.
|
||||
* <p> The returned stream contains references to one or more open directories.
|
||||
* The directories are closed by closing the stream.
|
||||
*
|
||||
* <p> If an {@link IOException} is thrown when accessing the directory
|
||||
* after this method has returned, it is wrapped in an {@link
|
||||
* UncheckedIOException} which will be thrown from the method that caused
|
||||
* the access to take place.
|
||||
*
|
||||
* @apiNote
|
||||
* This method must be used within a try-with-resources statement or similar
|
||||
* control structure to ensure that the stream's open directories are closed
|
||||
* promptly after the stream's operations have completed.
|
||||
*
|
||||
* @param start
|
||||
* the starting file
|
||||
* @param maxDepth
|
||||
@ -3613,12 +3616,13 @@ public final class Files {
|
||||
* </pre></blockquote>
|
||||
* In other words, it visits all levels of the file tree.
|
||||
*
|
||||
* <p> The returned stream encapsulates one or more {@link DirectoryStream}s.
|
||||
* If timely disposal of file system resources is required, the
|
||||
* {@code try}-with-resources construct should be used to ensure that the
|
||||
* stream's {@link Stream#close close} method is invoked after the stream
|
||||
* operations are completed. Operating on a closed stream will result in an
|
||||
* {@link java.lang.IllegalStateException}.
|
||||
* <p> The returned stream contains references to one or more open directories.
|
||||
* The directories are closed by closing the stream.
|
||||
*
|
||||
* @apiNote
|
||||
* This method must be used within a try-with-resources statement or similar
|
||||
* control structure to ensure that the stream's open directories are closed
|
||||
* promptly after the stream's operations have completed.
|
||||
*
|
||||
* @param start
|
||||
* the starting file
|
||||
@ -3658,18 +3662,19 @@ public final class Files {
|
||||
* returned by {@code walk} method, this method may be more efficient by
|
||||
* avoiding redundant retrieval of the {@code BasicFileAttributes}.
|
||||
*
|
||||
* <p> The returned stream encapsulates one or more {@link DirectoryStream}s.
|
||||
* If timely disposal of file system resources is required, the
|
||||
* {@code try}-with-resources construct should be used to ensure that the
|
||||
* stream's {@link Stream#close close} method is invoked after the stream
|
||||
* operations are completed. Operating on a closed stream will result in an
|
||||
* {@link java.lang.IllegalStateException}.
|
||||
* <p> The returned stream contains references to one or more open directories.
|
||||
* The directories are closed by closing the stream.
|
||||
*
|
||||
* <p> If an {@link IOException} is thrown when accessing the directory
|
||||
* after returned from this method, it is wrapped in an {@link
|
||||
* UncheckedIOException} which will be thrown from the method that caused
|
||||
* the access to take place.
|
||||
*
|
||||
* @apiNote
|
||||
* This method must be used within a try-with-resources statement or similar
|
||||
* control structure to ensure that the stream's open directories are closed
|
||||
* promptly after the stream's operations have completed.
|
||||
*
|
||||
* @param start
|
||||
* the starting file
|
||||
* @param maxDepth
|
||||
@ -3725,6 +3730,9 @@ public final class Files {
|
||||
* charset and the same line terminators as specified by {@code
|
||||
* readAllLines} are supported.
|
||||
*
|
||||
* <p> The returned stream contains a reference to an open file. The file
|
||||
* is closed by closing the stream.
|
||||
*
|
||||
* <p> After this method returns, then any subsequent I/O exception that
|
||||
* occurs while reading from the file or when a malformed or unmappable byte
|
||||
* sequence is read, is wrapped in an {@link UncheckedIOException} that will
|
||||
@ -3733,12 +3741,10 @@ public final class Files {
|
||||
* place. In case an {@code IOException} is thrown when closing the file,
|
||||
* it is also wrapped as an {@code UncheckedIOException}.
|
||||
*
|
||||
* <p> The returned stream encapsulates a {@link Reader}. If timely
|
||||
* disposal of file system resources is required, the try-with-resources
|
||||
* construct should be used to ensure that the stream's
|
||||
* {@link Stream#close close} method is invoked after the stream operations
|
||||
* are completed.
|
||||
*
|
||||
* @apiNote
|
||||
* This method must be used within a try-with-resources statement or similar
|
||||
* control structure to ensure that the stream's open file is closed promptly
|
||||
* after the stream's operations have completed.
|
||||
*
|
||||
* @param path
|
||||
* the path to the file
|
||||
@ -3780,12 +3786,20 @@ public final class Files {
|
||||
* decoded into characters using the {@link StandardCharsets#UTF_8 UTF-8}
|
||||
* {@link Charset charset}.
|
||||
*
|
||||
* <p> The returned stream contains a reference to an open file. The file
|
||||
* is closed by closing the stream.
|
||||
*
|
||||
* <p> This method works as if invoking it were equivalent to evaluating the
|
||||
* expression:
|
||||
* <pre>{@code
|
||||
* Files.lines(path, StandardCharsets.UTF_8)
|
||||
* }</pre>
|
||||
*
|
||||
* @apiNote
|
||||
* This method must be used within a try-with-resources statement or similar
|
||||
* control structure to ensure that the stream's open file is closed promptly
|
||||
* after the stream's operations have completed.
|
||||
*
|
||||
* @param path
|
||||
* the path to the file
|
||||
*
|
||||
|
@ -2574,8 +2574,10 @@ public class X509CertSelector implements CertSelector {
|
||||
} else {
|
||||
if (maxPathLen < basicConstraints) {
|
||||
if (debug != null) {
|
||||
debug.println("X509CertSelector.match: maxPathLen too small ("
|
||||
+ maxPathLen + " < " + basicConstraints + ")");
|
||||
debug.println("X509CertSelector.match: cert's maxPathLen " +
|
||||
"is less than the min maxPathLen set by " +
|
||||
"basicConstraints. " +
|
||||
"(" + maxPathLen + " < " + basicConstraints + ")");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1229,8 +1229,14 @@ public final class Instant
|
||||
* @throws ArithmeticException if numeric overflow occurs
|
||||
*/
|
||||
public long toEpochMilli() {
|
||||
long millis = Math.multiplyExact(seconds, 1000);
|
||||
return millis + nanos / 1000_000;
|
||||
if (seconds < 0 && nanos > 0) {
|
||||
long millis = Math.multiplyExact(seconds+1, 1000);
|
||||
long adjustment = nanos / 1000_000 - 1000;
|
||||
return millis + adjustment;
|
||||
} else {
|
||||
long millis = Math.multiplyExact(seconds, 1000);
|
||||
return millis + nanos / 1000_000;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -4685,6 +4685,14 @@ public class Arrays {
|
||||
* <p>If the generator function throws an exception, it is relayed to
|
||||
* the caller and the array is left in an indeterminate state.
|
||||
*
|
||||
* @apiNote
|
||||
* Setting a subrange of an array, using a generator function to compute
|
||||
* each element, can be written as follows:
|
||||
* <pre>{@code
|
||||
* IntStream.range(startInclusive, endExclusive)
|
||||
* .forEach(i -> array[i] = generator.apply(i));
|
||||
* }</pre>
|
||||
*
|
||||
* @param <T> type of elements of the array
|
||||
* @param array array to be initialized
|
||||
* @param generator a function accepting an index and producing the desired
|
||||
@ -4706,6 +4714,15 @@ public class Arrays {
|
||||
* is thrown from {@code parallelSetAll} and the array is left in an
|
||||
* indeterminate state.
|
||||
*
|
||||
* @apiNote
|
||||
* Setting a subrange of an array, in parallel, using a generator function
|
||||
* to compute each element, can be written as follows:
|
||||
* <pre>{@code
|
||||
* IntStream.range(startInclusive, endExclusive)
|
||||
* .parallel()
|
||||
* .forEach(i -> array[i] = generator.apply(i));
|
||||
* }</pre>
|
||||
*
|
||||
* @param <T> type of elements of the array
|
||||
* @param array array to be initialized
|
||||
* @param generator a function accepting an index and producing the desired
|
||||
@ -4725,6 +4742,14 @@ public class Arrays {
|
||||
* <p>If the generator function throws an exception, it is relayed to
|
||||
* the caller and the array is left in an indeterminate state.
|
||||
*
|
||||
* @apiNote
|
||||
* Setting a subrange of an array, using a generator function to compute
|
||||
* each element, can be written as follows:
|
||||
* <pre>{@code
|
||||
* IntStream.range(startInclusive, endExclusive)
|
||||
* .forEach(i -> array[i] = generator.applyAsInt(i));
|
||||
* }</pre>
|
||||
*
|
||||
* @param array array to be initialized
|
||||
* @param generator a function accepting an index and producing the desired
|
||||
* value for that position
|
||||
@ -4745,6 +4770,15 @@ public class Arrays {
|
||||
* is thrown from {@code parallelSetAll} and the array is left in an
|
||||
* indeterminate state.
|
||||
*
|
||||
* @apiNote
|
||||
* Setting a subrange of an array, in parallel, using a generator function
|
||||
* to compute each element, can be written as follows:
|
||||
* <pre>{@code
|
||||
* IntStream.range(startInclusive, endExclusive)
|
||||
* .parallel()
|
||||
* .forEach(i -> array[i] = generator.applyAsInt(i));
|
||||
* }</pre>
|
||||
*
|
||||
* @param array array to be initialized
|
||||
* @param generator a function accepting an index and producing the desired
|
||||
* value for that position
|
||||
@ -4763,6 +4797,14 @@ public class Arrays {
|
||||
* <p>If the generator function throws an exception, it is relayed to
|
||||
* the caller and the array is left in an indeterminate state.
|
||||
*
|
||||
* @apiNote
|
||||
* Setting a subrange of an array, using a generator function to compute
|
||||
* each element, can be written as follows:
|
||||
* <pre>{@code
|
||||
* IntStream.range(startInclusive, endExclusive)
|
||||
* .forEach(i -> array[i] = generator.applyAsLong(i));
|
||||
* }</pre>
|
||||
*
|
||||
* @param array array to be initialized
|
||||
* @param generator a function accepting an index and producing the desired
|
||||
* value for that position
|
||||
@ -4783,6 +4825,15 @@ public class Arrays {
|
||||
* is thrown from {@code parallelSetAll} and the array is left in an
|
||||
* indeterminate state.
|
||||
*
|
||||
* @apiNote
|
||||
* Setting a subrange of an array, in parallel, using a generator function
|
||||
* to compute each element, can be written as follows:
|
||||
* <pre>{@code
|
||||
* IntStream.range(startInclusive, endExclusive)
|
||||
* .parallel()
|
||||
* .forEach(i -> array[i] = generator.applyAsLong(i));
|
||||
* }</pre>
|
||||
*
|
||||
* @param array array to be initialized
|
||||
* @param generator a function accepting an index and producing the desired
|
||||
* value for that position
|
||||
@ -4801,6 +4852,14 @@ public class Arrays {
|
||||
* <p>If the generator function throws an exception, it is relayed to
|
||||
* the caller and the array is left in an indeterminate state.
|
||||
*
|
||||
* @apiNote
|
||||
* Setting a subrange of an array, using a generator function to compute
|
||||
* each element, can be written as follows:
|
||||
* <pre>{@code
|
||||
* IntStream.range(startInclusive, endExclusive)
|
||||
* .forEach(i -> array[i] = generator.applyAsDouble(i));
|
||||
* }</pre>
|
||||
*
|
||||
* @param array array to be initialized
|
||||
* @param generator a function accepting an index and producing the desired
|
||||
* value for that position
|
||||
@ -4821,6 +4880,15 @@ public class Arrays {
|
||||
* is thrown from {@code parallelSetAll} and the array is left in an
|
||||
* indeterminate state.
|
||||
*
|
||||
* @apiNote
|
||||
* Setting a subrange of an array, in parallel, using a generator function
|
||||
* to compute each element, can be written as follows:
|
||||
* <pre>{@code
|
||||
* IntStream.range(startInclusive, endExclusive)
|
||||
* .parallel()
|
||||
* .forEach(i -> array[i] = generator.applyAsDouble(i));
|
||||
* }</pre>
|
||||
*
|
||||
* @param array array to be initialized
|
||||
* @param generator a function accepting an index and producing the desired
|
||||
* value for that position
|
||||
|
@ -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
|
||||
@ -25,7 +25,16 @@
|
||||
|
||||
package java.util.regex;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
import java.util.Spliterator;
|
||||
import java.util.Spliterators;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
/**
|
||||
* An engine that performs match operations on a {@linkplain java.lang.CharSequence
|
||||
@ -208,6 +217,11 @@ public final class Matcher implements MatchResult {
|
||||
*/
|
||||
boolean anchoringBounds = true;
|
||||
|
||||
/**
|
||||
* Number of times this matcher's state has been modified
|
||||
*/
|
||||
int modCount;
|
||||
|
||||
/**
|
||||
* No default constructor.
|
||||
*/
|
||||
@ -248,11 +262,76 @@ public final class Matcher implements MatchResult {
|
||||
* @since 1.5
|
||||
*/
|
||||
public MatchResult toMatchResult() {
|
||||
Matcher result = new Matcher(this.parentPattern, text.toString());
|
||||
result.first = this.first;
|
||||
result.last = this.last;
|
||||
result.groups = this.groups.clone();
|
||||
return result;
|
||||
return toMatchResult(text.toString());
|
||||
}
|
||||
|
||||
private MatchResult toMatchResult(String text) {
|
||||
return new ImmutableMatchResult(this.first,
|
||||
this.last,
|
||||
groupCount(),
|
||||
this.groups.clone(),
|
||||
text);
|
||||
}
|
||||
|
||||
private static class ImmutableMatchResult implements MatchResult {
|
||||
private final int first;
|
||||
private final int last;
|
||||
private final int[] groups;
|
||||
private final int groupCount;
|
||||
private final String text;
|
||||
|
||||
ImmutableMatchResult(int first, int last, int groupCount,
|
||||
int groups[], String text)
|
||||
{
|
||||
this.first = first;
|
||||
this.last = last;
|
||||
this.groupCount = groupCount;
|
||||
this.groups = groups;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int start() {
|
||||
return first;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int start(int group) {
|
||||
if (group < 0 || group > groupCount)
|
||||
throw new IndexOutOfBoundsException("No group " + group);
|
||||
return groups[group * 2];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int end() {
|
||||
return last;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int end(int group) {
|
||||
if (group < 0 || group > groupCount)
|
||||
throw new IndexOutOfBoundsException("No group " + group);
|
||||
return groups[group * 2 + 1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int groupCount() {
|
||||
return groupCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String group() {
|
||||
return group(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String group(int group) {
|
||||
if (group < 0 || group > groupCount)
|
||||
throw new IndexOutOfBoundsException("No group " + group);
|
||||
if ((groups[group*2] == -1) || (groups[group*2+1] == -1))
|
||||
return null;
|
||||
return text.subSequence(groups[group * 2], groups[group * 2 + 1]).toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -284,6 +363,7 @@ public final class Matcher implements MatchResult {
|
||||
groups[i] = -1;
|
||||
for (int i = 0; i < locals.length; i++)
|
||||
locals[i] = -1;
|
||||
modCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -308,6 +388,7 @@ public final class Matcher implements MatchResult {
|
||||
lastAppendPosition = 0;
|
||||
from = 0;
|
||||
to = getTextLength();
|
||||
modCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -803,6 +884,7 @@ public final class Matcher implements MatchResult {
|
||||
// Append the match substitution
|
||||
sb.append(result);
|
||||
lastAppendPosition = last;
|
||||
modCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -892,6 +974,7 @@ public final class Matcher implements MatchResult {
|
||||
// Append the match substitution
|
||||
sb.append(result);
|
||||
lastAppendPosition = last;
|
||||
modCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -1077,6 +1160,183 @@ public final class Matcher implements MatchResult {
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces every subsequence of the input sequence that matches the
|
||||
* pattern with the result of applying the given replacer function to the
|
||||
* match result of this matcher corresponding to that subsequence.
|
||||
* Exceptions thrown by the function are relayed to the caller.
|
||||
*
|
||||
* <p> This method first resets this matcher. It then scans the input
|
||||
* sequence looking for matches of the pattern. Characters that are not
|
||||
* part of any match are appended directly to the result string; each match
|
||||
* is replaced in the result by the applying the replacer function that
|
||||
* returns a replacement string. Each replacement string may contain
|
||||
* references to captured subsequences as in the {@link #appendReplacement
|
||||
* appendReplacement} method.
|
||||
*
|
||||
* <p> Note that backslashes (<tt>\</tt>) and dollar signs (<tt>$</tt>) in
|
||||
* a replacement string may cause the results to be different than if it
|
||||
* were being treated as a literal replacement string. Dollar signs may be
|
||||
* treated as references to captured subsequences as described above, and
|
||||
* backslashes are used to escape literal characters in the replacement
|
||||
* string.
|
||||
*
|
||||
* <p> Given the regular expression <tt>dog</tt>, the input
|
||||
* <tt>"zzzdogzzzdogzzz"</tt>, and the function
|
||||
* <tt>mr -> mr.group().toUpperCase()</tt>, an invocation of this method on
|
||||
* a matcher for that expression would yield the string
|
||||
* <tt>"zzzDOGzzzDOGzzz"</tt>.
|
||||
*
|
||||
* <p> Invoking this method changes this matcher's state. If the matcher
|
||||
* is to be used in further matching operations then it should first be
|
||||
* reset. </p>
|
||||
*
|
||||
* <p> The replacer function should not modify this matcher's state during
|
||||
* replacement. This method will, on a best-effort basis, throw a
|
||||
* {@link java.util.ConcurrentModificationException} if such modification is
|
||||
* detected.
|
||||
*
|
||||
* <p> The state of each match result passed to the replacer function is
|
||||
* guaranteed to be constant only for the duration of the replacer function
|
||||
* call and only if the replacer function does not modify this matcher's
|
||||
* state.
|
||||
*
|
||||
* @implNote
|
||||
* This implementation applies the replacer function to this matcher, which
|
||||
* is an instance of {@code MatchResult}.
|
||||
*
|
||||
* @param replacer
|
||||
* The function to be applied to the match result of this matcher
|
||||
* that returns a replacement string.
|
||||
* @return The string constructed by replacing each matching subsequence
|
||||
* with the result of applying the replacer function to that
|
||||
* matched subsequence, substituting captured subsequences as
|
||||
* needed.
|
||||
* @throws NullPointerException if the replacer function is null
|
||||
* @throws ConcurrentModificationException if it is detected, on a
|
||||
* best-effort basis, that the replacer function modified this
|
||||
* matcher's state
|
||||
* @since 1.9
|
||||
*/
|
||||
public String replaceAll(Function<MatchResult, String> replacer) {
|
||||
Objects.requireNonNull(replacer);
|
||||
reset();
|
||||
boolean result = find();
|
||||
if (result) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
do {
|
||||
int ec = modCount;
|
||||
String replacement = replacer.apply(this);
|
||||
if (ec != modCount)
|
||||
throw new ConcurrentModificationException();
|
||||
appendReplacement(sb, replacement);
|
||||
result = find();
|
||||
} while (result);
|
||||
appendTail(sb);
|
||||
return sb.toString();
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream of match results for each subsequence of the input
|
||||
* sequence that matches the pattern. The match results occur in the
|
||||
* same order as the matching subsequences in the input sequence.
|
||||
*
|
||||
* <p> Each match result is produced as if by {@link #toMatchResult()}.
|
||||
*
|
||||
* <p> This method does not reset this matcher. Matching starts on
|
||||
* initiation of the terminal stream operation either at the beginning of
|
||||
* this matcher's region, or, if the matcher has not since been reset, at
|
||||
* the first character not matched by a previous match.
|
||||
*
|
||||
* <p> If the matcher is to be used for further matching operations after
|
||||
* the terminal stream operation completes then it should be first reset.
|
||||
*
|
||||
* <p> This matcher's state should not be modified during execution of the
|
||||
* returned stream's pipeline. The returned stream's source
|
||||
* {@code Spliterator} is <em>fail-fast</em> and will, on a best-effort
|
||||
* basis, throw a {@link java.util.ConcurrentModificationException} if such
|
||||
* modification is detected.
|
||||
*
|
||||
* @return a sequential stream of match results.
|
||||
* @since 1.9
|
||||
*/
|
||||
public Stream<MatchResult> results() {
|
||||
class MatchResultIterator implements Iterator<MatchResult> {
|
||||
// -ve for call to find, 0 for not found, 1 for found
|
||||
int state = -1;
|
||||
// State for concurrent modification checking
|
||||
// -1 for uninitialized
|
||||
int expectedCount = -1;
|
||||
// The input sequence as a string, set once only after first find
|
||||
// Avoids repeated conversion from CharSequence for each match
|
||||
String textAsString;
|
||||
|
||||
@Override
|
||||
public MatchResult next() {
|
||||
if (expectedCount >= 0 && expectedCount != modCount)
|
||||
throw new ConcurrentModificationException();
|
||||
|
||||
if (!hasNext())
|
||||
throw new NoSuchElementException();
|
||||
|
||||
state = -1;
|
||||
return toMatchResult(textAsString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (state >= 0)
|
||||
return state == 1;
|
||||
|
||||
// Defer throwing ConcurrentModificationException to when next
|
||||
// or forEachRemaining is called. The is consistent with other
|
||||
// fail-fast implementations.
|
||||
if (expectedCount >= 0 && expectedCount != modCount)
|
||||
return true;
|
||||
|
||||
boolean found = find();
|
||||
// Capture the input sequence as a string on first find
|
||||
if (found && state < 0)
|
||||
textAsString = text.toString();
|
||||
state = found ? 1 : 0;
|
||||
expectedCount = modCount;
|
||||
return found;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachRemaining(Consumer<? super MatchResult> action) {
|
||||
if (expectedCount >= 0 && expectedCount != modCount)
|
||||
throw new ConcurrentModificationException();
|
||||
|
||||
int s = state;
|
||||
if (s == 0)
|
||||
return;
|
||||
|
||||
// Set state to report no more elements on further operations
|
||||
state = 0;
|
||||
expectedCount = -1;
|
||||
|
||||
// Perform a first find if required
|
||||
if (s < 0 && !find())
|
||||
return;
|
||||
|
||||
// Capture the input sequence as a string on first find
|
||||
textAsString = text.toString();
|
||||
|
||||
do {
|
||||
int ec = modCount;
|
||||
action.accept(toMatchResult(textAsString));
|
||||
if (ec != modCount)
|
||||
throw new ConcurrentModificationException();
|
||||
} while (find());
|
||||
}
|
||||
}
|
||||
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(
|
||||
new MatchResultIterator(), Spliterator.ORDERED | Spliterator.NONNULL), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the first subsequence of the input sequence that matches the
|
||||
* pattern with the given replacement string.
|
||||
@ -1122,6 +1382,79 @@ public final class Matcher implements MatchResult {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the first subsequence of the input sequence that matches the
|
||||
* pattern with the result of applying the given replacer function to the
|
||||
* match result of this matcher corresponding to that subsequence.
|
||||
* Exceptions thrown by the replace function are relayed to the caller.
|
||||
*
|
||||
* <p> This method first resets this matcher. It then scans the input
|
||||
* sequence looking for a match of the pattern. Characters that are not
|
||||
* part of the match are appended directly to the result string; the match
|
||||
* is replaced in the result by the applying the replacer function that
|
||||
* returns a replacement string. The replacement string may contain
|
||||
* references to captured subsequences as in the {@link #appendReplacement
|
||||
* appendReplacement} method.
|
||||
*
|
||||
* <p>Note that backslashes (<tt>\</tt>) and dollar signs (<tt>$</tt>) in
|
||||
* the replacement string may cause the results to be different than if it
|
||||
* were being treated as a literal replacement string. Dollar signs may be
|
||||
* treated as references to captured subsequences as described above, and
|
||||
* backslashes are used to escape literal characters in the replacement
|
||||
* string.
|
||||
*
|
||||
* <p> Given the regular expression <tt>dog</tt>, the input
|
||||
* <tt>"zzzdogzzzdogzzz"</tt>, and the function
|
||||
* <tt>mr -> mr.group().toUpperCase()</tt>, an invocation of this method on
|
||||
* a matcher for that expression would yield the string
|
||||
* <tt>"zzzDOGzzzdogzzz"</tt>.
|
||||
*
|
||||
* <p> Invoking this method changes this matcher's state. If the matcher
|
||||
* is to be used in further matching operations then it should first be
|
||||
* reset.
|
||||
*
|
||||
* <p> The replacer function should not modify this matcher's state during
|
||||
* replacement. This method will, on a best-effort basis, throw a
|
||||
* {@link java.util.ConcurrentModificationException} if such modification is
|
||||
* detected.
|
||||
*
|
||||
* <p> The state of the match result passed to the replacer function is
|
||||
* guaranteed to be constant only for the duration of the replacer function
|
||||
* call and only if the replacer function does not modify this matcher's
|
||||
* state.
|
||||
*
|
||||
* @implNote
|
||||
* This implementation applies the replacer function to this matcher, which
|
||||
* is an instance of {@code MatchResult}.
|
||||
*
|
||||
* @param replacer
|
||||
* The function to be applied to the match result of this matcher
|
||||
* that returns a replacement string.
|
||||
* @return The string constructed by replacing the first matching
|
||||
* subsequence with the result of applying the replacer function to
|
||||
* the matched subsequence, substituting captured subsequences as
|
||||
* needed.
|
||||
* @throws NullPointerException if the replacer function is null
|
||||
* @throws ConcurrentModificationException if it is detected, on a
|
||||
* best-effort basis, that the replacer function modified this
|
||||
* matcher's state
|
||||
* @since 1.9
|
||||
*/
|
||||
public String replaceFirst(Function<MatchResult, String> replacer) {
|
||||
Objects.requireNonNull(replacer);
|
||||
reset();
|
||||
if (!find())
|
||||
return text.toString();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int ec = modCount;
|
||||
String replacement = replacer.apply(this);
|
||||
if (ec != modCount)
|
||||
throw new ConcurrentModificationException();
|
||||
appendReplacement(sb, replacement);
|
||||
appendTail(sb);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the limits of this matcher's region. The region is the part of the
|
||||
* input sequence that will be searched to find a match. Invoking this
|
||||
@ -1365,6 +1698,7 @@ public final class Matcher implements MatchResult {
|
||||
if (!result)
|
||||
this.first = -1;
|
||||
this.oldLast = this.last;
|
||||
this.modCount++;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1387,6 +1721,7 @@ public final class Matcher implements MatchResult {
|
||||
if (!result)
|
||||
this.first = -1;
|
||||
this.oldLast = this.last;
|
||||
this.modCount++;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -403,6 +403,54 @@ public final class Collectors {
|
||||
downstream.characteristics());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapts a {@code Collector} accepting elements of type {@code U} to one
|
||||
* accepting elements of type {@code T} by applying a flat mapping function
|
||||
* to each input element before accumulation. The flat mapping function
|
||||
* maps an input element to a {@link Stream stream} covering zero or more
|
||||
* output elements that are then accumulated downstream. Each mapped stream
|
||||
* is {@link java.util.stream.BaseStream#close() closed} after its contents
|
||||
* have been placed downstream. (If a mapped stream is {@code null}
|
||||
* an empty stream is used, instead.)
|
||||
*
|
||||
* @apiNote
|
||||
* The {@code flatMapping()} 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 Order}, to accumulate the set of line items for each customer:
|
||||
* <pre>{@code
|
||||
* Map<String, Set<LineItem>> itemsByCustomerName
|
||||
* = orders.stream().collect(groupingBy(Order::getCustomerName,
|
||||
* flatMapping(order -> order.getLineItems().stream(), toSet())));
|
||||
* }</pre>
|
||||
*
|
||||
* @param <T> the type of the input elements
|
||||
* @param <U> type of elements accepted by downstream collector
|
||||
* @param <A> intermediate accumulation type of the downstream collector
|
||||
* @param <R> result type of collector
|
||||
* @param mapper a function to be applied to the input elements, which
|
||||
* returns a stream of results
|
||||
* @param downstream a collector which will receive the elements of the
|
||||
* 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
|
||||
*/
|
||||
public static <T, U, A, R>
|
||||
Collector<T, ?, R> flatMapping(Function<? super T, ? extends Stream<? extends U>> mapper,
|
||||
Collector<? super U, A, R> downstream) {
|
||||
BiConsumer<A, ? super U> downstreamAccumulator = downstream.accumulator();
|
||||
return new CollectorImpl<>(downstream.supplier(),
|
||||
(r, t) -> {
|
||||
try (Stream<? extends U> result = mapper.apply(t)) {
|
||||
if (result != null)
|
||||
result.sequential().forEach(u -> downstreamAccumulator.accept(r, u));
|
||||
}
|
||||
},
|
||||
downstream.combiner(), downstream.finisher(),
|
||||
downstream.characteristics());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapts a {@code Collector} to perform an additional finishing
|
||||
* transformation. For example, one could adapt the {@link #toList()}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -126,13 +126,15 @@ import java.util.function.UnaryOperator;
|
||||
* operations may return their receiver rather than a new stream object, it may
|
||||
* not be possible to detect reuse in all cases.
|
||||
*
|
||||
* <p>Streams have a {@link #close()} method and implement {@link AutoCloseable},
|
||||
* but nearly all stream instances do not actually need to be closed after use.
|
||||
* Generally, only streams whose source is an IO channel (such as those returned
|
||||
* by {@link Files#lines(Path, Charset)}) will require closing. Most streams
|
||||
* <p>Streams have a {@link #close()} method and implement {@link AutoCloseable}.
|
||||
* Operating on a stream after it has been closed will throw {@link IllegalStateException}.
|
||||
* Most stream instances do not actually need to be closed after use, as they
|
||||
* are backed by collections, arrays, or generating functions, which require no
|
||||
* special resource management. (If a stream does require closing, it can be
|
||||
* declared as a resource in a {@code try}-with-resources statement.)
|
||||
* special resource management. Generally, only streams whose source is an IO channel,
|
||||
* such as those returned by {@link Files#lines(Path)}, will require closing. If a
|
||||
* stream does require closing, it must be opened as a resource within a try-with-resources
|
||||
* statement or similar control structure to ensure that it is closed promptly after its
|
||||
* operations have completed.
|
||||
*
|
||||
* <p>Stream pipelines may execute either sequentially or in
|
||||
* <a href="package-summary.html#Parallelism">parallel</a>. This
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2013, 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
|
||||
@ -41,7 +41,9 @@ public
|
||||
class ZipEntry implements ZipConstants, Cloneable {
|
||||
|
||||
String name; // entry name
|
||||
long time = -1; // last modification time
|
||||
long xdostime = -1; // last modification time (in extended DOS time,
|
||||
// where milliseconds lost in conversion might
|
||||
// be encoded into the upper half)
|
||||
FileTime mtime; // last modification time, from extra field data
|
||||
FileTime atime; // last access time, from extra field data
|
||||
FileTime ctime; // creation time, from extra field data
|
||||
@ -63,6 +65,28 @@ class ZipEntry implements ZipConstants, Cloneable {
|
||||
*/
|
||||
public static final int DEFLATED = 8;
|
||||
|
||||
/**
|
||||
* DOS time constant for representing timestamps before 1980.
|
||||
*/
|
||||
static final long DOSTIME_BEFORE_1980 = (1 << 21) | (1 << 16);
|
||||
|
||||
/**
|
||||
* Approximately 128 years, in milliseconds (ignoring leap years etc).
|
||||
*
|
||||
* This establish an approximate high-bound value for DOS times in
|
||||
* milliseconds since epoch, used to enable an efficient but
|
||||
* sufficient bounds check to avoid generating extended last modified
|
||||
* time entries.
|
||||
*
|
||||
* Calculating the exact number is locale dependent, would require loading
|
||||
* TimeZone data eagerly, and would make little practical sense. Since DOS
|
||||
* times theoretically go to 2107 - with compatibility not guaranteed
|
||||
* after 2099 - setting this to a time that is before but near 2099
|
||||
* should be sufficient.
|
||||
*/
|
||||
private static final long UPPER_DOSTIME_BOUND =
|
||||
128L * 365 * 24 * 60 * 60 * 1000;
|
||||
|
||||
/**
|
||||
* Creates a new zip entry with the specified name.
|
||||
*
|
||||
@ -93,7 +117,7 @@ class ZipEntry implements ZipConstants, Cloneable {
|
||||
public ZipEntry(ZipEntry e) {
|
||||
Objects.requireNonNull(e, "entry");
|
||||
name = e.name;
|
||||
time = e.time;
|
||||
xdostime = e.xdostime;
|
||||
mtime = e.mtime;
|
||||
atime = e.atime;
|
||||
ctime = e.ctime;
|
||||
@ -137,8 +161,14 @@ class ZipEntry implements ZipConstants, Cloneable {
|
||||
* @see #getLastModifiedTime()
|
||||
*/
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
this.mtime = null;
|
||||
this.xdostime = javaToExtendedDosTime(time);
|
||||
// Avoid setting the mtime field if time is in the valid
|
||||
// range for a DOS time
|
||||
if (xdostime != DOSTIME_BEFORE_1980 && time <= UPPER_DOSTIME_BOUND) {
|
||||
this.mtime = null;
|
||||
} else {
|
||||
this.mtime = FileTime.from(time, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,7 +188,10 @@ class ZipEntry implements ZipConstants, Cloneable {
|
||||
* @see #setLastModifiedTime(FileTime)
|
||||
*/
|
||||
public long getTime() {
|
||||
return time;
|
||||
if (mtime != null) {
|
||||
return mtime.toMillis();
|
||||
}
|
||||
return (xdostime != -1) ? extendedDosToJavaTime(xdostime) : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,7 +214,7 @@ class ZipEntry implements ZipConstants, Cloneable {
|
||||
*/
|
||||
public ZipEntry setLastModifiedTime(FileTime time) {
|
||||
this.mtime = Objects.requireNonNull(time, "lastModifiedTime");
|
||||
this.time = time.to(TimeUnit.MILLISECONDS);
|
||||
this.xdostime = javaToExtendedDosTime(time.to(TimeUnit.MILLISECONDS));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -204,9 +237,9 @@ class ZipEntry implements ZipConstants, Cloneable {
|
||||
public FileTime getLastModifiedTime() {
|
||||
if (mtime != null)
|
||||
return mtime;
|
||||
if (time == -1)
|
||||
if (xdostime == -1)
|
||||
return null;
|
||||
return FileTime.from(time, TimeUnit.MILLISECONDS);
|
||||
return FileTime.from(getTime(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2013, 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
|
||||
@ -46,7 +46,6 @@ import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import static java.util.zip.ZipConstants64.*;
|
||||
import static java.util.zip.ZipUtils.*;
|
||||
|
||||
/**
|
||||
* This class is used to read entries from a zip file.
|
||||
@ -567,7 +566,7 @@ class ZipFile implements ZipConstants, Closeable {
|
||||
e.name = zc.toString(bname, bname.length);
|
||||
}
|
||||
}
|
||||
e.time = dosToJavaTime(getEntryTime(jzentry));
|
||||
e.xdostime = getEntryTime(jzentry);
|
||||
e.crc = getEntryCrc(jzentry);
|
||||
e.size = getEntrySize(jzentry);
|
||||
e.csize = getEntryCSize(jzentry);
|
||||
|
@ -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
|
||||
@ -303,7 +303,7 @@ class ZipInputStream extends InflaterInputStream implements ZipConstants {
|
||||
throw new ZipException("encrypted ZIP entry not supported");
|
||||
}
|
||||
e.method = get16(tmpbuf, LOCHOW);
|
||||
e.time = dosToJavaTime(get32(tmpbuf, LOCTIM));
|
||||
e.xdostime = get32(tmpbuf, LOCTIM);
|
||||
if ((flag & 8) == 8) {
|
||||
/* "Data Descriptor" present */
|
||||
if (e.method != DEFLATED) {
|
||||
|
@ -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
|
||||
@ -61,7 +61,6 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
|
||||
private static class XEntry {
|
||||
final ZipEntry entry;
|
||||
final long offset;
|
||||
long dostime; // last modification time in msdos format
|
||||
public XEntry(ZipEntry entry, long offset) {
|
||||
this.entry = entry;
|
||||
this.offset = offset;
|
||||
@ -192,7 +191,7 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
|
||||
if (current != null) {
|
||||
closeEntry(); // close previous entry
|
||||
}
|
||||
if (e.time == -1) {
|
||||
if (e.xdostime == -1) {
|
||||
// by default, do NOT use extended timestamps in extra
|
||||
// data, for now.
|
||||
e.setTime(System.currentTimeMillis());
|
||||
@ -389,18 +388,12 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
|
||||
boolean hasZip64 = false;
|
||||
int elen = getExtraLen(e.extra);
|
||||
|
||||
// keep a copy of dostime for writeCEN(), otherwise the tz
|
||||
// sensitive local time entries in loc and cen might be
|
||||
// different if the default tz get changed during writeLOC()
|
||||
// and writeCEN()
|
||||
xentry.dostime = javaToDosTime(e.time);
|
||||
|
||||
writeInt(LOCSIG); // LOC header signature
|
||||
if ((flag & 8) == 8) {
|
||||
writeShort(version(e)); // version needed to extract
|
||||
writeShort(flag); // general purpose bit flag
|
||||
writeShort(e.method); // compression method
|
||||
writeInt(xentry.dostime); // last modification time
|
||||
writeInt(e.xdostime); // last modification time
|
||||
// store size, uncompressed size, and crc-32 in data descriptor
|
||||
// immediately following compressed entry data
|
||||
writeInt(0);
|
||||
@ -415,7 +408,7 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
|
||||
}
|
||||
writeShort(flag); // general purpose bit flag
|
||||
writeShort(e.method); // compression method
|
||||
writeInt(xentry.dostime); // last modification time
|
||||
writeInt(e.xdostime); // last modification time
|
||||
writeInt(e.crc); // crc-32
|
||||
if (hasZip64) {
|
||||
writeInt(ZIP64_MAGICVAL);
|
||||
@ -522,9 +515,7 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
|
||||
}
|
||||
writeShort(flag); // general purpose bit flag
|
||||
writeShort(e.method); // compression method
|
||||
// use the copy in xentry, which has been converted
|
||||
// from e.time in writeLOC()
|
||||
writeInt(xentry.dostime); // last modification time
|
||||
writeInt(e.xdostime); // last modification time
|
||||
writeInt(e.crc); // crc-32
|
||||
writeInt(csize); // compressed size
|
||||
writeInt(size); // uncompressed size
|
||||
|
@ -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
|
||||
@ -29,9 +29,6 @@ import java.nio.file.attribute.FileTime;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static java.util.zip.ZipConstants.*;
|
||||
import static java.util.zip.ZipConstants64.*;
|
||||
|
||||
class ZipUtils {
|
||||
|
||||
// used to adjust values between Windows and java epoch
|
||||
@ -69,7 +66,7 @@ class ZipUtils {
|
||||
/**
|
||||
* Converts DOS time to Java time (number of milliseconds since epoch).
|
||||
*/
|
||||
public static long dosToJavaTime(long dtime) {
|
||||
private static long dosToJavaTime(long dtime) {
|
||||
@SuppressWarnings("deprecation") // Use of date constructor.
|
||||
Date d = new Date((int)(((dtime >> 25) & 0x7f) + 80),
|
||||
(int)(((dtime >> 21) & 0x0f) - 1),
|
||||
@ -80,21 +77,50 @@ class ZipUtils {
|
||||
return d.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts extended DOS time to Java time, where up to 1999 milliseconds
|
||||
* might be encoded into the upper half of the returned long.
|
||||
*
|
||||
* @param xdostime the extended DOS time value
|
||||
* @return milliseconds since epoch
|
||||
*/
|
||||
public static long extendedDosToJavaTime(long xdostime) {
|
||||
long time = dosToJavaTime(xdostime);
|
||||
return time + (xdostime >> 32);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Java time to DOS time.
|
||||
*/
|
||||
@SuppressWarnings("deprecation") // Use of date methods
|
||||
public static long javaToDosTime(long time) {
|
||||
private static long javaToDosTime(long time) {
|
||||
Date d = new Date(time);
|
||||
int year = d.getYear() + 1900;
|
||||
if (year < 1980) {
|
||||
return (1 << 21) | (1 << 16);
|
||||
return ZipEntry.DOSTIME_BEFORE_1980;
|
||||
}
|
||||
return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
|
||||
d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
|
||||
d.getSeconds() >> 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Java time to DOS time, encoding any milliseconds lost
|
||||
* in the conversion into the upper half of the returned long.
|
||||
*
|
||||
* @param time milliseconds since epoch
|
||||
* @return DOS time with 2s remainder encoded into upper half
|
||||
*/
|
||||
public static long javaToExtendedDosTime(long time) {
|
||||
if (time < 0) {
|
||||
return ZipEntry.DOSTIME_BEFORE_1980;
|
||||
}
|
||||
long dostime = javaToDosTime(time);
|
||||
return (dostime != ZipEntry.DOSTIME_BEFORE_1980)
|
||||
? dostime + ((time % 2000) << 32)
|
||||
: ZipEntry.DOSTIME_BEFORE_1980;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches unsigned 16-bit value from byte array at specified offset.
|
||||
* The bytes are assumed to be in Intel (little-endian) byte order.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 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
|
||||
@ -253,10 +253,10 @@ class JrtFileSystem extends FileSystem {
|
||||
String syntax = syntaxAndInput.substring(0, pos);
|
||||
String input = syntaxAndInput.substring(pos + 1);
|
||||
String expr;
|
||||
if (syntax.equals(GLOB_SYNTAX)) {
|
||||
if (syntax.equalsIgnoreCase(GLOB_SYNTAX)) {
|
||||
expr = JrtUtils.toRegexPattern(input);
|
||||
} else {
|
||||
if (syntax.equals(REGEX_SYNTAX)) {
|
||||
if (syntax.equalsIgnoreCase(REGEX_SYNTAX)) {
|
||||
expr = input;
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Syntax '" + syntax
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 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
|
||||
@ -321,12 +321,9 @@ public class SocketAdaptor
|
||||
}
|
||||
|
||||
public void sendUrgentData(int data) throws IOException {
|
||||
synchronized (sc.blockingLock()) {
|
||||
if (!sc.isBlocking())
|
||||
throw new IllegalBlockingModeException();
|
||||
int n = sc.sendOutOfBandData((byte)data);
|
||||
assert n == 1;
|
||||
}
|
||||
int n = sc.sendOutOfBandData((byte) data);
|
||||
if (n == 0)
|
||||
throw new IOException("Socket buffer full");
|
||||
}
|
||||
|
||||
public void setOOBInline(boolean on) throws SocketException {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -224,7 +224,8 @@ class AdaptableX509CertSelector extends X509CertSelector {
|
||||
if (extVal == null) {
|
||||
if (debug != null) {
|
||||
debug.println("AdaptableX509CertSelector.match: "
|
||||
+ "no subject key ID extension");
|
||||
+ "no subject key ID extension. Subject: "
|
||||
+ xcert.getSubjectX500Principal());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -234,7 +235,9 @@ class AdaptableX509CertSelector extends X509CertSelector {
|
||||
!Arrays.equals(ski, certSubjectKeyID)) {
|
||||
if (debug != null) {
|
||||
debug.println("AdaptableX509CertSelector.match: "
|
||||
+ "subject key IDs don't match");
|
||||
+ "subject key IDs don't match. "
|
||||
+ "Expected: " + Arrays.toString(ski) + " "
|
||||
+ "Cert's: " + Arrays.toString(certSubjectKeyID));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 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
|
||||
@ -435,7 +435,12 @@ public abstract class Builder {
|
||||
if (selector.match(targetCert) && !X509CertImpl.isSelfSigned
|
||||
(targetCert, buildParams.sigProvider())) {
|
||||
if (debug != null) {
|
||||
debug.println("Builder.addMatchingCerts: adding target cert");
|
||||
debug.println("Builder.addMatchingCerts: " +
|
||||
"adding target cert" +
|
||||
"\n SN: " + Debug.toHexString(
|
||||
targetCert.getSerialNumber()) +
|
||||
"\n Subject: " + targetCert.getSubjectX500Principal() +
|
||||
"\n Issuer: " + targetCert.getIssuerX500Principal());
|
||||
}
|
||||
return resultCerts.add(targetCert);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 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
|
||||
@ -145,8 +145,8 @@ class ConstraintsChecker extends PKIXCertPathChecker {
|
||||
if (prevNC != null && ((i == certPathLength) ||
|
||||
!X509CertImpl.isSelfIssued(currCert))) {
|
||||
if (debug != null) {
|
||||
debug.println("prevNC = " + prevNC);
|
||||
debug.println("currDN = " + currCert.getSubjectX500Principal());
|
||||
debug.println("prevNC = " + prevNC +
|
||||
", currDN = " + currCert.getSubjectX500Principal());
|
||||
}
|
||||
|
||||
try {
|
||||
@ -184,8 +184,8 @@ class ConstraintsChecker extends PKIXCertPathChecker {
|
||||
currCertImpl.getNameConstraintsExtension();
|
||||
|
||||
if (debug != null) {
|
||||
debug.println("prevNC = " + prevNC);
|
||||
debug.println("newNC = " + String.valueOf(newConstraints));
|
||||
debug.println("prevNC = " + prevNC +
|
||||
", newNC = " + String.valueOf(newConstraints));
|
||||
}
|
||||
|
||||
// if there are no previous name constraints, we just return the
|
||||
@ -225,8 +225,8 @@ class ConstraintsChecker extends PKIXCertPathChecker {
|
||||
String msg = "basic constraints";
|
||||
if (debug != null) {
|
||||
debug.println("---checking " + msg + "...");
|
||||
debug.println("i = " + i);
|
||||
debug.println("maxPathLength = " + maxPathLength);
|
||||
debug.println("i = " + i +
|
||||
", maxPathLength = " + maxPathLength);
|
||||
}
|
||||
|
||||
/* check if intermediate cert */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 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
|
||||
@ -320,6 +320,14 @@ public class DistributionPointFetcher {
|
||||
Set<TrustAnchor> trustAnchors, List<CertStore> certStores,
|
||||
Date validity) throws CRLException, IOException {
|
||||
|
||||
if (debug != null) {
|
||||
debug.println("DistributionPointFetcher.verifyCRL: " +
|
||||
"checking revocation status for" +
|
||||
"\n SN: " + Debug.toHexString(certImpl.getSerialNumber()) +
|
||||
"\n Subject: " + certImpl.getSubjectX500Principal() +
|
||||
"\n Issuer: " + certImpl.getIssuerX500Principal());
|
||||
}
|
||||
|
||||
boolean indirectCRL = false;
|
||||
X509CRLImpl crlImpl = X509CRLImpl.toImpl(crl);
|
||||
IssuingDistributionPointExtension idpExt =
|
||||
@ -363,7 +371,9 @@ public class DistributionPointFetcher {
|
||||
}
|
||||
} else if (crlIssuer.equals(certIssuer) == false) {
|
||||
if (debug != null) {
|
||||
debug.println("crl issuer does not equal cert issuer");
|
||||
debug.println("crl issuer does not equal cert issuer.\n" +
|
||||
"crl issuer: " + crlIssuer + "\n" +
|
||||
"cert issuer: " + certIssuer);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 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
|
||||
@ -209,7 +209,8 @@ class ForwardBuilder extends Builder {
|
||||
* getMatchingEECerts
|
||||
*/
|
||||
if (debug != null) {
|
||||
debug.println("ForwardBuilder.getMatchingCACerts(): ca is target");
|
||||
debug.println("ForwardBuilder.getMatchingCACerts(): " +
|
||||
"the target is a CA");
|
||||
}
|
||||
|
||||
if (caTargetSelector == null) {
|
||||
@ -291,8 +292,14 @@ class ForwardBuilder extends Builder {
|
||||
for (X509Certificate trustedCert : trustedCerts) {
|
||||
if (sel.match(trustedCert)) {
|
||||
if (debug != null) {
|
||||
debug.println("ForwardBuilder.getMatchingCACerts: "
|
||||
+ "found matching trust anchor");
|
||||
debug.println("ForwardBuilder.getMatchingCACerts: " +
|
||||
"found matching trust anchor." +
|
||||
"\n SN: " +
|
||||
Debug.toHexString(trustedCert.getSerialNumber()) +
|
||||
"\n Subject: " +
|
||||
trustedCert.getSubjectX500Principal() +
|
||||
"\n Issuer: " +
|
||||
trustedCert.getIssuerX500Principal());
|
||||
}
|
||||
if (caCerts.add(trustedCert) && !searchAllCertStores) {
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 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
|
||||
@ -30,6 +30,7 @@ import sun.security.util.Debug;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.security.cert.CertPath;
|
||||
import java.security.cert.CertPathValidatorException;
|
||||
import java.security.cert.PKIXCertPathChecker;
|
||||
@ -88,20 +89,25 @@ class PKIXMasterCertPathValidator {
|
||||
* current certificate of this loop to be the previous certificate
|
||||
* of the next loop. The state is initialized during first loop.
|
||||
*/
|
||||
if (debug != null)
|
||||
debug.println("Checking cert" + (i+1) + " ...");
|
||||
|
||||
X509Certificate currCert = reversedCertList.get(i);
|
||||
|
||||
if (debug != null) {
|
||||
debug.println("Checking cert" + (i+1) + " - Subject: " +
|
||||
currCert.getSubjectX500Principal());
|
||||
}
|
||||
|
||||
Set<String> unresCritExts = currCert.getCriticalExtensionOIDs();
|
||||
if (unresCritExts == null) {
|
||||
unresCritExts = Collections.<String>emptySet();
|
||||
}
|
||||
|
||||
if (debug != null && !unresCritExts.isEmpty()) {
|
||||
debug.println("Set of critical extensions:");
|
||||
StringJoiner joiner = new StringJoiner(", ", "{", "}");
|
||||
for (String oid : unresCritExts) {
|
||||
debug.println(oid);
|
||||
joiner.add(oid);
|
||||
}
|
||||
debug.println("Set of critical extensions: " +
|
||||
joiner.toString());
|
||||
}
|
||||
|
||||
for (int j = 0; j < certPathCheckers.size(); j++) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -343,11 +343,17 @@ class RevocationChecker extends PKIXRevocationChecker {
|
||||
PublicKey pubKey, boolean crlSignFlag)
|
||||
throws CertPathValidatorException
|
||||
{
|
||||
if (debug != null) {
|
||||
debug.println("RevocationChecker.check: checking cert" +
|
||||
"\n SN: " + Debug.toHexString(xcert.getSerialNumber()) +
|
||||
"\n Subject: " + xcert.getSubjectX500Principal() +
|
||||
"\n Issuer: " + xcert.getIssuerX500Principal());
|
||||
}
|
||||
try {
|
||||
if (onlyEE && xcert.getBasicConstraints() != -1) {
|
||||
if (debug != null) {
|
||||
debug.println("Skipping revocation check, not end " +
|
||||
"entity cert");
|
||||
debug.println("Skipping revocation check; cert is not " +
|
||||
"an end entity cert");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 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
|
||||
@ -136,7 +136,8 @@ public final class SunCertPathBuilder extends CertPathBuilderSpi {
|
||||
PKIXCertPathBuilderResult result = buildCertPath(false, adjList);
|
||||
if (result == null) {
|
||||
if (debug != null) {
|
||||
debug.println("SunCertPathBuilder.engineBuild: 2nd pass");
|
||||
debug.println("SunCertPathBuilder.engineBuild: 2nd pass; " +
|
||||
"try building again searching all certstores");
|
||||
}
|
||||
// try again
|
||||
adjList.clear();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2014, 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
|
||||
@ -59,6 +59,10 @@ import static sun.security.ssl.CipherSuite.KeyExchange.*;
|
||||
*/
|
||||
final class ClientHandshaker extends Handshaker {
|
||||
|
||||
// constants for subject alt names of type DNS and IP
|
||||
private final static int ALTNAME_DNS = 2;
|
||||
private final static int ALTNAME_IP = 7;
|
||||
|
||||
// the server's public key from its certificate.
|
||||
private PublicKey serverKey;
|
||||
|
||||
@ -818,6 +822,11 @@ final class ClientHandshaker extends Handshaker {
|
||||
} else {
|
||||
warningSE(Alerts.alert_no_certificate);
|
||||
}
|
||||
if (debug != null && Debug.isOn("handshake")) {
|
||||
System.out.println(
|
||||
"Warning: no suitable certificate found - " +
|
||||
"continuing without client authentication");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@ -1497,20 +1506,49 @@ final class ClientHandshaker extends Handshaker {
|
||||
return true;
|
||||
}
|
||||
|
||||
// check the iPAddress field in subjectAltName extension
|
||||
Object thisIPAddress = getSubjectAltName(thisCert, 7); // 7: iPAddress
|
||||
Object prevIPAddress = getSubjectAltName(prevCert, 7);
|
||||
if (thisIPAddress != null && prevIPAddress!= null) {
|
||||
// only allow the exactly match
|
||||
return Objects.equals(thisIPAddress, prevIPAddress);
|
||||
// check subject alternative names
|
||||
Collection<List<?>> thisSubjectAltNames = null;
|
||||
try {
|
||||
thisSubjectAltNames = thisCert.getSubjectAlternativeNames();
|
||||
} catch (CertificateParsingException cpe) {
|
||||
if (debug != null && Debug.isOn("handshake")) {
|
||||
System.out.println(
|
||||
"Attempt to obtain subjectAltNames extension failed!");
|
||||
}
|
||||
}
|
||||
|
||||
// check the dNSName field in subjectAltName extension
|
||||
Object thisDNSName = getSubjectAltName(thisCert, 2); // 2: dNSName
|
||||
Object prevDNSName = getSubjectAltName(prevCert, 2);
|
||||
if (thisDNSName != null && prevDNSName!= null) {
|
||||
// only allow the exactly match
|
||||
return Objects.equals(thisDNSName, prevDNSName);
|
||||
Collection<List<?>> prevSubjectAltNames = null;
|
||||
try {
|
||||
prevSubjectAltNames = prevCert.getSubjectAlternativeNames();
|
||||
} catch (CertificateParsingException cpe) {
|
||||
if (debug != null && Debug.isOn("handshake")) {
|
||||
System.out.println(
|
||||
"Attempt to obtain subjectAltNames extension failed!");
|
||||
}
|
||||
}
|
||||
|
||||
if ((thisSubjectAltNames != null) && (prevSubjectAltNames != null)) {
|
||||
// check the iPAddress field in subjectAltName extension
|
||||
Collection<String> thisSubAltIPAddrs =
|
||||
getSubjectAltNames(thisSubjectAltNames, ALTNAME_IP);
|
||||
Collection<String> prevSubAltIPAddrs =
|
||||
getSubjectAltNames(prevSubjectAltNames, ALTNAME_IP);
|
||||
if ((thisSubAltIPAddrs != null) && (prevSubAltIPAddrs != null) &&
|
||||
(isEquivalent(thisSubAltIPAddrs, prevSubAltIPAddrs))) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// check the dNSName field in subjectAltName extension
|
||||
Collection<String> thisSubAltDnsNames =
|
||||
getSubjectAltNames(thisSubjectAltNames, ALTNAME_DNS);
|
||||
Collection<String> prevSubAltDnsNames =
|
||||
getSubjectAltNames(prevSubjectAltNames, ALTNAME_DNS);
|
||||
if ((thisSubAltDnsNames != null) && (prevSubAltDnsNames != null) &&
|
||||
(isEquivalent(thisSubAltDnsNames, prevSubAltDnsNames))) {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// check the certificate subject and issuer
|
||||
@ -1532,28 +1570,39 @@ final class ClientHandshaker extends Handshaker {
|
||||
* Returns the subject alternative name of the specified type in the
|
||||
* subjectAltNames extension of a certificate.
|
||||
*/
|
||||
private static Object getSubjectAltName(X509Certificate cert, int type) {
|
||||
Collection<List<?>> subjectAltNames;
|
||||
private static Collection<String> getSubjectAltNames(
|
||||
Collection<List<?>> subjectAltNames, int type) {
|
||||
|
||||
try {
|
||||
subjectAltNames = cert.getSubjectAlternativeNames();
|
||||
} catch (CertificateParsingException cpe) {
|
||||
if (debug != null && Debug.isOn("handshake")) {
|
||||
System.out.println(
|
||||
"Attempt to obtain subjectAltNames extension failed!");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (subjectAltNames != null) {
|
||||
for (List<?> subjectAltName : subjectAltNames) {
|
||||
int subjectAltNameType = (Integer)subjectAltName.get(0);
|
||||
if (subjectAltNameType == type) {
|
||||
return subjectAltName.get(1);
|
||||
HashSet<String> subAltDnsNames = null;
|
||||
for (List<?> subjectAltName : subjectAltNames) {
|
||||
int subjectAltNameType = (Integer)subjectAltName.get(0);
|
||||
if (subjectAltNameType == type) {
|
||||
String subAltDnsName = (String)subjectAltName.get(1);
|
||||
if ((subAltDnsName != null) && !subAltDnsName.isEmpty()) {
|
||||
if (subAltDnsNames == null) {
|
||||
subAltDnsNames =
|
||||
new HashSet<>(subjectAltNames.size());
|
||||
}
|
||||
subAltDnsNames.add(subAltDnsName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return subAltDnsNames;
|
||||
}
|
||||
|
||||
private static boolean isEquivalent(Collection<String> thisSubAltNames,
|
||||
Collection<String> prevSubAltNames) {
|
||||
|
||||
for (String thisSubAltName : thisSubAltNames) {
|
||||
for (String prevSubAltName : prevSubAltNames) {
|
||||
// Only allow the exactly match. Check no wildcard character.
|
||||
if (thisSubAltName.equalsIgnoreCase(prevSubAltName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -492,11 +492,14 @@ class CertificateMsg extends HandshakeMessage
|
||||
void print(PrintStream s) throws IOException {
|
||||
s.println("*** Certificate chain");
|
||||
|
||||
if (debug != null && Debug.isOn("verbose")) {
|
||||
for (int i = 0; i < chain.length; i++)
|
||||
if (chain.length == 0) {
|
||||
s.println("<Empty>");
|
||||
} else if (debug != null && Debug.isOn("verbose")) {
|
||||
for (int i = 0; i < chain.length; i++) {
|
||||
s.println("chain [" + i + "] = " + chain[i]);
|
||||
s.println("***");
|
||||
}
|
||||
}
|
||||
s.println("***");
|
||||
}
|
||||
|
||||
X509Certificate[] getCertificateChain() {
|
||||
|
@ -3790,6 +3790,17 @@ public final class Main {
|
||||
PublicKey pkey,
|
||||
PublicKey akey) throws Exception {
|
||||
|
||||
// By design, inside a CertificateExtensions object, all known
|
||||
// extensions uses name (say, "BasicConstraints") as key and
|
||||
// a child Extension type (say, "BasicConstraintsExtension")
|
||||
// as value, unknown extensions uses OID as key and bare
|
||||
// Extension object as value. This works fine inside JDK.
|
||||
//
|
||||
// However, in keytool, there is no way to prevent people
|
||||
// using OID in -ext, either as a new extension, or in a
|
||||
// honored value. Thus here we (ab)use CertificateExtensions
|
||||
// by always using OID as key and value can be of any type.
|
||||
|
||||
if (existingEx != null && requestedEx != null) {
|
||||
// This should not happen
|
||||
throw new Exception("One of request and original should be null.");
|
||||
@ -3805,13 +3816,19 @@ public final class Main {
|
||||
// name{:critical}{=value}
|
||||
// Honoring requested extensions
|
||||
if (requestedEx != null) {
|
||||
// The existing requestedEx might use names as keys,
|
||||
// translate to all-OID first.
|
||||
CertificateExtensions request2 = new CertificateExtensions();
|
||||
for (sun.security.x509.Extension ex: requestedEx.getAllExtensions()) {
|
||||
request2.set(ex.getId(), ex);
|
||||
}
|
||||
for(String extstr: extstrs) {
|
||||
if (extstr.toLowerCase(Locale.ENGLISH).startsWith("honored=")) {
|
||||
List<String> list = Arrays.asList(
|
||||
extstr.toLowerCase(Locale.ENGLISH).substring(8).split(","));
|
||||
// First check existence of "all"
|
||||
if (list.contains("all")) {
|
||||
for (Extension ex: requestedEx.getAllExtensions()) {
|
||||
for (Extension ex: request2.getAllExtensions()) {
|
||||
setExt(result, ex);
|
||||
}
|
||||
}
|
||||
@ -3844,7 +3861,7 @@ public final class Main {
|
||||
}
|
||||
String n = findOidForExtName(type).toString();
|
||||
if (add) {
|
||||
Extension e = requestedEx.get(n);
|
||||
Extension e = request2.get(n);
|
||||
if (!e.isCritical() && action == 0
|
||||
|| e.isCritical() && action == 1) {
|
||||
e = Extension.newExtension(
|
||||
|
@ -31,24 +31,6 @@
|
||||
#include "jlong.h"
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* WARNING:
|
||||
*
|
||||
* Do not replace instances of:
|
||||
*
|
||||
* if (length > MBYTE)
|
||||
* size = MBYTE;
|
||||
* else
|
||||
* size = length;
|
||||
*
|
||||
* with
|
||||
*
|
||||
* size = (length > MBYTE ? MBYTE : length);
|
||||
*
|
||||
* This expression causes a c compiler assertion failure when compiling on
|
||||
* 32-bit sparc.
|
||||
*/
|
||||
|
||||
#define MBYTE 1048576
|
||||
|
||||
#define GETCRITICAL_OR_RETURN(bytes, env, obj) { \
|
||||
@ -71,7 +53,7 @@
|
||||
((jlong)SWAPINT((jint)((x) >> 32)) & 0xffffffff)))
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_nio_Bits_copyFromShortArray(JNIEnv *env, jobject this, jobject src,
|
||||
Java_java_nio_Bits_copyFromShortArray(JNIEnv *env, jclass clazz, jobject src,
|
||||
jlong srcPos, jlong dstAddr, jlong length)
|
||||
{
|
||||
jbyte *bytes;
|
||||
@ -82,11 +64,7 @@ Java_java_nio_Bits_copyFromShortArray(JNIEnv *env, jobject this, jobject src,
|
||||
dstShort = (jshort *)jlong_to_ptr(dstAddr);
|
||||
|
||||
while (length > 0) {
|
||||
/* do not change this if-else statement, see WARNING above */
|
||||
if (length > MBYTE)
|
||||
size = MBYTE;
|
||||
else
|
||||
size = (size_t)length;
|
||||
size = (length < MBYTE) ? (size_t)length : (size_t)MBYTE;
|
||||
|
||||
GETCRITICAL_OR_RETURN(bytes, env, src);
|
||||
|
||||
@ -100,13 +78,12 @@ Java_java_nio_Bits_copyFromShortArray(JNIEnv *env, jobject this, jobject src,
|
||||
RELEASECRITICAL(bytes, env, src, JNI_ABORT);
|
||||
|
||||
length -= size;
|
||||
dstAddr += size;
|
||||
srcPos += size;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_nio_Bits_copyToShortArray(JNIEnv *env, jobject this, jlong srcAddr,
|
||||
Java_java_nio_Bits_copyToShortArray(JNIEnv *env, jclass clazz, jlong srcAddr,
|
||||
jobject dst, jlong dstPos, jlong length)
|
||||
{
|
||||
jbyte *bytes;
|
||||
@ -117,11 +94,7 @@ Java_java_nio_Bits_copyToShortArray(JNIEnv *env, jobject this, jlong srcAddr,
|
||||
srcShort = (jshort *)jlong_to_ptr(srcAddr);
|
||||
|
||||
while (length > 0) {
|
||||
/* do not change this if-else statement, see WARNING above */
|
||||
if (length > MBYTE)
|
||||
size = MBYTE;
|
||||
else
|
||||
size = (size_t)length;
|
||||
size = (length < MBYTE) ? (size_t)length : (size_t)MBYTE;
|
||||
|
||||
GETCRITICAL_OR_RETURN(bytes, env, dst);
|
||||
|
||||
@ -135,13 +108,12 @@ Java_java_nio_Bits_copyToShortArray(JNIEnv *env, jobject this, jlong srcAddr,
|
||||
RELEASECRITICAL(bytes, env, dst, 0);
|
||||
|
||||
length -= size;
|
||||
srcAddr += size;
|
||||
dstPos += size;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_nio_Bits_copyFromIntArray(JNIEnv *env, jobject this, jobject src,
|
||||
Java_java_nio_Bits_copyFromIntArray(JNIEnv *env, jclass clazz, jobject src,
|
||||
jlong srcPos, jlong dstAddr, jlong length)
|
||||
{
|
||||
jbyte *bytes;
|
||||
@ -152,11 +124,7 @@ Java_java_nio_Bits_copyFromIntArray(JNIEnv *env, jobject this, jobject src,
|
||||
dstInt = (jint *)jlong_to_ptr(dstAddr);
|
||||
|
||||
while (length > 0) {
|
||||
/* do not change this code, see WARNING above */
|
||||
if (length > MBYTE)
|
||||
size = MBYTE;
|
||||
else
|
||||
size = (size_t)length;
|
||||
size = (length < MBYTE) ? (size_t)length : (size_t)MBYTE;
|
||||
|
||||
GETCRITICAL_OR_RETURN(bytes, env, src);
|
||||
|
||||
@ -170,13 +138,12 @@ Java_java_nio_Bits_copyFromIntArray(JNIEnv *env, jobject this, jobject src,
|
||||
RELEASECRITICAL(bytes, env, src, JNI_ABORT);
|
||||
|
||||
length -= size;
|
||||
dstAddr += size;
|
||||
srcPos += size;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_nio_Bits_copyToIntArray(JNIEnv *env, jobject this, jlong srcAddr,
|
||||
Java_java_nio_Bits_copyToIntArray(JNIEnv *env, jclass clazz, jlong srcAddr,
|
||||
jobject dst, jlong dstPos, jlong length)
|
||||
{
|
||||
jbyte *bytes;
|
||||
@ -187,11 +154,7 @@ Java_java_nio_Bits_copyToIntArray(JNIEnv *env, jobject this, jlong srcAddr,
|
||||
srcInt = (jint *)jlong_to_ptr(srcAddr);
|
||||
|
||||
while (length > 0) {
|
||||
/* do not change this code, see WARNING above */
|
||||
if (length > MBYTE)
|
||||
size = MBYTE;
|
||||
else
|
||||
size = (size_t)length;
|
||||
size = (length < MBYTE) ? (size_t)length : (size_t)MBYTE;
|
||||
|
||||
GETCRITICAL_OR_RETURN(bytes, env, dst);
|
||||
|
||||
@ -205,13 +168,12 @@ Java_java_nio_Bits_copyToIntArray(JNIEnv *env, jobject this, jlong srcAddr,
|
||||
RELEASECRITICAL(bytes, env, dst, 0);
|
||||
|
||||
length -= size;
|
||||
srcAddr += size;
|
||||
dstPos += size;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_nio_Bits_copyFromLongArray(JNIEnv *env, jobject this, jobject src,
|
||||
Java_java_nio_Bits_copyFromLongArray(JNIEnv *env, jclass clazz, jobject src,
|
||||
jlong srcPos, jlong dstAddr, jlong length)
|
||||
{
|
||||
jbyte *bytes;
|
||||
@ -222,11 +184,7 @@ Java_java_nio_Bits_copyFromLongArray(JNIEnv *env, jobject this, jobject src,
|
||||
dstLong = (jlong *)jlong_to_ptr(dstAddr);
|
||||
|
||||
while (length > 0) {
|
||||
/* do not change this code, see WARNING above */
|
||||
if (length > MBYTE)
|
||||
size = MBYTE;
|
||||
else
|
||||
size = (size_t)length;
|
||||
size = (length < MBYTE) ? (size_t)length : (size_t)MBYTE;
|
||||
|
||||
GETCRITICAL_OR_RETURN(bytes, env, src);
|
||||
|
||||
@ -240,13 +198,12 @@ Java_java_nio_Bits_copyFromLongArray(JNIEnv *env, jobject this, jobject src,
|
||||
RELEASECRITICAL(bytes, env, src, JNI_ABORT);
|
||||
|
||||
length -= size;
|
||||
dstAddr += size;
|
||||
srcPos += size;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_nio_Bits_copyToLongArray(JNIEnv *env, jobject this, jlong srcAddr,
|
||||
Java_java_nio_Bits_copyToLongArray(JNIEnv *env, jclass clazz, jlong srcAddr,
|
||||
jobject dst, jlong dstPos, jlong length)
|
||||
{
|
||||
jbyte *bytes;
|
||||
@ -257,11 +214,7 @@ Java_java_nio_Bits_copyToLongArray(JNIEnv *env, jobject this, jlong srcAddr,
|
||||
srcLong = (jlong *)jlong_to_ptr(srcAddr);
|
||||
|
||||
while (length > 0) {
|
||||
/* do not change this code, see WARNING above */
|
||||
if (length > MBYTE)
|
||||
size = MBYTE;
|
||||
else
|
||||
size = (size_t)length;
|
||||
size = (length < MBYTE) ? (size_t)length : (size_t)MBYTE;
|
||||
|
||||
GETCRITICAL_OR_RETURN(bytes, env, dst);
|
||||
|
||||
@ -275,7 +228,6 @@ Java_java_nio_Bits_copyToLongArray(JNIEnv *env, jobject this, jlong srcAddr,
|
||||
RELEASECRITICAL(bytes, env, dst, 0);
|
||||
|
||||
length -= size;
|
||||
srcAddr += size;
|
||||
dstPos += size;
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,8 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "jni.h"
|
||||
#include "jni_util.h"
|
||||
#include "jlong.h"
|
||||
#include "jvm.h"
|
||||
#include "jdk_util.h"
|
||||
|
||||
@ -43,12 +40,8 @@ Java_sun_misc_VM_latestUserDefinedLoader(JNIEnv *env, jclass cls) {
|
||||
return JVM_LatestUserDefinedLoader(env);
|
||||
}
|
||||
|
||||
typedef void (JNICALL *GetJvmVersionInfo_fp)(JNIEnv*, jvm_version_info*, size_t);
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_misc_VM_initialize(JNIEnv *env, jclass cls) {
|
||||
GetJvmVersionInfo_fp func_p;
|
||||
|
||||
if (!JDK_InitJvmHandle()) {
|
||||
JNU_ThrowInternalError(env, "Handle for JVM not found for symbol lookup");
|
||||
return;
|
||||
@ -61,15 +54,4 @@ Java_sun_misc_VM_initialize(JNIEnv *env, jclass cls) {
|
||||
// introducing a Java_sun_misc_VM_getNanoTimeAdjustment wrapper
|
||||
(*env)->RegisterNatives(env, cls,
|
||||
methods, sizeof(methods)/sizeof(methods[0]));
|
||||
|
||||
func_p = (GetJvmVersionInfo_fp) JDK_FindJvmEntry("JVM_GetVersionInfo");
|
||||
if (func_p != NULL) {
|
||||
jvm_version_info info;
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
||||
/* obtain the JVM version info */
|
||||
(*func_p)(env, &info, sizeof(info));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 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
|
||||
@ -290,10 +290,10 @@ abstract class UnixFileSystem
|
||||
String input = syntaxAndInput.substring(pos+1);
|
||||
|
||||
String expr;
|
||||
if (syntax.equals(GLOB_SYNTAX)) {
|
||||
if (syntax.equalsIgnoreCase(GLOB_SYNTAX)) {
|
||||
expr = Globs.toUnixRegexPattern(input);
|
||||
} else {
|
||||
if (syntax.equals(REGEX_SYNTAX)) {
|
||||
if (syntax.equalsIgnoreCase(REGEX_SYNTAX)) {
|
||||
expr = input;
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Syntax '" + syntax +
|
||||
|
35
jdk/src/java.base/unix/conf/aarch64/jvm.cfg
Normal file
@ -0,0 +1,35 @@
|
||||
# Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
#
|
||||
# List of JVMs that can be used as an option to java, javac, etc.
|
||||
# Order is important -- first in this list is the default JVM.
|
||||
# NOTE that this both this file and its format are UNSUPPORTED and
|
||||
# WILL GO AWAY in a future release.
|
||||
#
|
||||
# You may also select a JVM in an arbitrary location with the
|
||||
# "-XXaltjvm=<jvm_dir>" option, but that too is unsupported
|
||||
# and may not be available in a future release.
|
||||
#
|
||||
-server KNOWN
|
||||
-client IGNORE
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 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
|
||||
@ -290,10 +290,10 @@ class WindowsFileSystem
|
||||
String input = syntaxAndInput.substring(pos+1);
|
||||
|
||||
String expr;
|
||||
if (syntax.equals(GLOB_SYNTAX)) {
|
||||
if (syntax.equalsIgnoreCase(GLOB_SYNTAX)) {
|
||||
expr = Globs.toWindowsRegexPattern(input);
|
||||
} else {
|
||||
if (syntax.equals(REGEX_SYNTAX)) {
|
||||
if (syntax.equalsIgnoreCase(REGEX_SYNTAX)) {
|
||||
expr = input;
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Syntax '" + syntax +
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2014, 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
|
||||
@ -195,7 +195,7 @@ static int getWinTimeZone(char *winZoneName, char *winMapID)
|
||||
* Vista uses the different key name.
|
||||
*/
|
||||
if (ret != ERROR_SUCCESS) {
|
||||
bufSize = sizeof(val);
|
||||
bufSize = sizeof(val);
|
||||
ret = RegQueryValueExA(hKey, "DynamicDaylightTimeDisabled",
|
||||
NULL, &valueType, (LPBYTE) &val, &bufSize);
|
||||
}
|
||||
@ -510,18 +510,49 @@ char *findJavaTZ_md(const char *java_home_dir)
|
||||
} else {
|
||||
std_timezone = matchJavaTZ(java_home_dir, result,
|
||||
winZoneName, winMapID);
|
||||
if (std_timezone == NULL) {
|
||||
std_timezone = getGMTOffsetID();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return std_timezone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a GMT-offset-based time zone ID. On Win32, it always return
|
||||
* NULL since the fall back is performed in getWinTimeZone().
|
||||
* Returns a GMT-offset-based time zone ID.
|
||||
*/
|
||||
char *
|
||||
getGMTOffsetID()
|
||||
{
|
||||
return NULL;
|
||||
LONG bias = 0;
|
||||
LONG ret;
|
||||
HANDLE hKey = NULL;
|
||||
char zonename[32];
|
||||
|
||||
// Obtain the current GMT offset value of ActiveTimeBias.
|
||||
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_CURRENT_TZ_KEY, 0,
|
||||
KEY_READ, (PHKEY)&hKey);
|
||||
if (ret == ERROR_SUCCESS) {
|
||||
DWORD val;
|
||||
DWORD bufSize = sizeof(val);
|
||||
ULONG valueType = 0;
|
||||
ret = RegQueryValueExA(hKey, "ActiveTimeBias",
|
||||
NULL, &valueType, (LPBYTE) &val, &bufSize);
|
||||
if (ret == ERROR_SUCCESS) {
|
||||
bias = (LONG) val;
|
||||
}
|
||||
(void) RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
// If we can't get the ActiveTimeBias value, use Bias of TimeZoneInformation.
|
||||
// Note: Bias doesn't reflect current daylight saving.
|
||||
if (ret != ERROR_SUCCESS) {
|
||||
TIME_ZONE_INFORMATION tzi;
|
||||
if (GetTimeZoneInformation(&tzi) != TIME_ZONE_ID_INVALID) {
|
||||
bias = tzi.Bias;
|
||||
}
|
||||
}
|
||||
|
||||
customZoneName(bias, zonename);
|
||||
return _strdup(zonename);
|
||||
}
|
||||
|
@ -325,17 +325,14 @@ Java_sun_nio_ch_FileDispatcherImpl_truncate0(JNIEnv *env, jobject this,
|
||||
{
|
||||
BOOL result = 0;
|
||||
HANDLE h = (HANDLE)(handleval(env, fdo));
|
||||
LARGE_INTEGER offset;
|
||||
FILE_END_OF_FILE_INFO eofInfo;
|
||||
|
||||
offset.QuadPart = size;
|
||||
result = SetFilePointerEx(h, offset, NULL, FILE_BEGIN);
|
||||
if (result == 0) {
|
||||
JNU_ThrowIOExceptionWithLastError(env, "Truncation failed");
|
||||
return IOS_THROWN;
|
||||
}
|
||||
|
||||
result = SetEndOfFile(h);
|
||||
if (result == 0) {
|
||||
eofInfo.EndOfFile.QuadPart = size;
|
||||
result = SetFileInformationByHandle(h,
|
||||
FileEndOfFileInfo,
|
||||
&eofInfo,
|
||||
sizeof(eofInfo));
|
||||
if (result == FALSE) {
|
||||
JNU_ThrowIOExceptionWithLastError(env, "Truncation failed");
|
||||
return IOS_THROWN;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class AquaIcon {
|
||||
AquaPainter.create(JRSUIState.getInstance());
|
||||
initIconPainter(painter);
|
||||
|
||||
g.setClip(new Rectangle(x, y, width, height));
|
||||
g.clipRect(x, y, width, height);
|
||||
painter.paint(g, c, x, y, width, height);
|
||||
g.dispose();
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ public final class CGraphicsDevice extends GraphicsDevice
|
||||
* therefore methods, which is using this id should be ready to it.
|
||||
*/
|
||||
private volatile int displayID;
|
||||
private volatile Insets screenInsets;
|
||||
private volatile double xResolution;
|
||||
private volatile double yResolution;
|
||||
private volatile int scale;
|
||||
@ -120,7 +119,13 @@ public final class CGraphicsDevice extends GraphicsDevice
|
||||
}
|
||||
|
||||
public Insets getScreenInsets() {
|
||||
return screenInsets;
|
||||
// the insets are queried synchronously and are not cached
|
||||
// since there are no Quartz or Cocoa means to receive notifications
|
||||
// on insets changes (e.g. when the Dock is resized):
|
||||
// the existing CGDisplayReconfigurationCallBack is not notified
|
||||
// as well as the NSApplicationDidChangeScreenParametersNotification
|
||||
// is fired on the Dock location changes only
|
||||
return nativeGetScreenInsets(displayID);
|
||||
}
|
||||
|
||||
public int getScaleFactor() {
|
||||
@ -135,7 +140,6 @@ public final class CGraphicsDevice extends GraphicsDevice
|
||||
public void displayChanged() {
|
||||
xResolution = nativeGetXResolution(displayID);
|
||||
yResolution = nativeGetYResolution(displayID);
|
||||
screenInsets = nativeGetScreenInsets(displayID);
|
||||
scale = (int) nativeGetScaleFactor(displayID);
|
||||
//TODO configs/fullscreenWindow/modes?
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,8 +28,6 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
#import <CoreServices/CoreServices.h>
|
||||
#import <AudioToolbox/AudioToolbox.h>
|
||||
|
||||
#define DEBUG 1
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,7 +28,6 @@
|
||||
//#define USE_VERBOSE_TRACE
|
||||
|
||||
#include <AudioUnit/AudioUnit.h>
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <AudioToolbox/AudioConverter.h>
|
||||
#include <pthread.h>
|
||||
#include <math.h>
|
||||
@ -617,7 +616,7 @@ struct OSX_DirectAudioDevice {
|
||||
|
||||
~OSX_DirectAudioDevice() {
|
||||
if (audioUnit) {
|
||||
CloseComponent(audioUnit);
|
||||
AudioComponentInstanceDispose(audioUnit);
|
||||
}
|
||||
if (resampler) {
|
||||
delete resampler;
|
||||
@ -629,17 +628,16 @@ static AudioUnit CreateOutputUnit(AudioDeviceID deviceID, int isSource)
|
||||
{
|
||||
OSStatus err;
|
||||
AudioUnit unit;
|
||||
UInt32 size;
|
||||
|
||||
ComponentDescription desc;
|
||||
AudioComponentDescription desc;
|
||||
desc.componentType = kAudioUnitType_Output;
|
||||
desc.componentSubType = (deviceID == 0 && isSource) ? kAudioUnitSubType_DefaultOutput : kAudioUnitSubType_HALOutput;
|
||||
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||
desc.componentFlags = 0;
|
||||
desc.componentFlagsMask = 0;
|
||||
|
||||
Component comp = FindNextComponent(NULL, &desc);
|
||||
err = OpenAComponent(comp, &unit);
|
||||
AudioComponent comp = AudioComponentFindNext(NULL, &desc);
|
||||
err = AudioComponentInstanceNew(comp, &unit);
|
||||
|
||||
if (err) {
|
||||
OS_ERROR0(err, "CreateOutputUnit:OpenAComponent");
|
||||
@ -664,7 +662,7 @@ static AudioUnit CreateOutputUnit(AudioDeviceID deviceID, int isSource)
|
||||
// get real AudioDeviceID for default input device (macosx current input device)
|
||||
deviceID = GetDefaultDevice(isSource);
|
||||
if (!deviceID) {
|
||||
CloseComponent(unit);
|
||||
AudioComponentInstanceDispose(unit);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -675,7 +673,7 @@ static AudioUnit CreateOutputUnit(AudioDeviceID deviceID, int isSource)
|
||||
0, &deviceID, sizeof(deviceID));
|
||||
if (err) {
|
||||
OS_ERROR0(err, "SetProperty (CurrentDevice)");
|
||||
CloseComponent(unit);
|
||||
AudioComponentInstanceDispose(unit);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2014, 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
|
||||
@ -64,13 +64,6 @@ final class Platform {
|
||||
// SYSTEM CHARACTERISTICS
|
||||
// vary according to hardware architecture
|
||||
|
||||
// signed8 (use signed 8-bit values) is true for everything we support except for
|
||||
// the solaris sbpro card.
|
||||
// we'll leave it here as a variable; in the future we may need this in java.
|
||||
// wait, is that true? i'm not sure. i think solaris takes unsigned data?
|
||||
// $$kk: 03.11.99: i think solaris takes unsigned 8-bit or signed 16-bit data....
|
||||
private static boolean signed8;
|
||||
|
||||
// intel is little-endian. sparc is big-endian.
|
||||
private static boolean bigEndian;
|
||||
|
||||
@ -110,14 +103,6 @@ final class Platform {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether the system takes signed 8-bit data.
|
||||
*/
|
||||
static boolean isSigned8() {
|
||||
|
||||
return signed8;
|
||||
}
|
||||
|
||||
// PRIVATE METHODS
|
||||
|
||||
/**
|
||||
@ -185,17 +170,14 @@ final class Platform {
|
||||
|
||||
// the following native methods are implemented in Platform.c
|
||||
private native static boolean nIsBigEndian();
|
||||
private native static boolean nIsSigned8();
|
||||
private native static String nGetExtraLibraries();
|
||||
private native static int nGetLibraryForFeature(int feature);
|
||||
|
||||
|
||||
/**
|
||||
* Read the required system properties.
|
||||
*/
|
||||
private static void readProperties() {
|
||||
// $$fb 2002-03-06: implement check for endianness in native. Facilitates porting !
|
||||
bigEndian = nIsBigEndian();
|
||||
signed8 = nIsSigned8(); // Solaris on Sparc: signed, all others unsigned
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2014, 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
|
||||
@ -24,18 +24,17 @@
|
||||
*/
|
||||
package java.awt;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import java.security.AccessController;
|
||||
|
||||
import sun.util.logging.PlatformLogger;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
/**
|
||||
* A class to encapsulate the bitmap representation of the mouse cursor.
|
||||
@ -160,28 +159,19 @@ public class Cursor implements java.io.Serializable {
|
||||
public static final int CUSTOM_CURSOR = -1;
|
||||
|
||||
/*
|
||||
* hashtable, filesystem dir prefix, filename, and properties for custom cursors support
|
||||
* hashtable, resource prefix, filename, and properties for custom cursors
|
||||
* support
|
||||
*/
|
||||
|
||||
private static final Hashtable<String,Cursor> systemCustomCursors = new Hashtable<>(1);
|
||||
private static final String systemCustomCursorDirPrefix = initCursorDir();
|
||||
|
||||
private static String initCursorDir() {
|
||||
String jhome = java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction("java.home"));
|
||||
return jhome +
|
||||
File.separator + "lib" + File.separator + "images" +
|
||||
File.separator + "cursors" + File.separator;
|
||||
}
|
||||
|
||||
private static final String systemCustomCursorPropertiesFile = systemCustomCursorDirPrefix + "cursors.properties";
|
||||
private static final String RESOURCE_PREFIX = "/sun/awt/resources/cursors/";
|
||||
private static final String PROPERTIES_FILE = RESOURCE_PREFIX + "cursors.properties";
|
||||
|
||||
private static Properties systemCustomCursorProperties = null;
|
||||
|
||||
private static final String CursorDotPrefix = "Cursor.";
|
||||
private static final String DotFileSuffix = ".File";
|
||||
private static final String DotHotspotSuffix = ".HotSpot";
|
||||
private static final String DotNameSuffix = ".Name";
|
||||
private static final String CURSOR_DOT_PREFIX = "Cursor.";
|
||||
private static final String DOT_FILE_SUFFIX = ".File";
|
||||
private static final String DOT_HOTSPOT_SUFFIX = ".HotSpot";
|
||||
private static final String DOT_NAME_SUFFIX = ".Name";
|
||||
|
||||
/*
|
||||
* JDK 1.1 serialVersionUID
|
||||
@ -307,8 +297,8 @@ public class Cursor implements java.io.Serializable {
|
||||
loadSystemCustomCursorProperties();
|
||||
}
|
||||
|
||||
String prefix = CursorDotPrefix + name;
|
||||
String key = prefix + DotFileSuffix;
|
||||
String prefix = CURSOR_DOT_PREFIX + name;
|
||||
String key = prefix + DOT_FILE_SUFFIX;
|
||||
|
||||
if (!systemCustomCursorProperties.containsKey(key)) {
|
||||
if (log.isLoggable(PlatformLogger.Level.FINER)) {
|
||||
@ -320,11 +310,10 @@ public class Cursor implements java.io.Serializable {
|
||||
final String fileName =
|
||||
systemCustomCursorProperties.getProperty(key);
|
||||
|
||||
String localized = systemCustomCursorProperties.getProperty(prefix + DotNameSuffix);
|
||||
final String localized = systemCustomCursorProperties.getProperty(
|
||||
prefix + DOT_NAME_SUFFIX, name);
|
||||
|
||||
if (localized == null) localized = name;
|
||||
|
||||
String hotspot = systemCustomCursorProperties.getProperty(prefix + DotHotspotSuffix);
|
||||
String hotspot = systemCustomCursorProperties.getProperty(prefix + DOT_HOTSPOT_SUFFIX);
|
||||
|
||||
if (hotspot == null)
|
||||
throw new AWTException("no hotspot property defined for cursor: " + name);
|
||||
@ -334,31 +323,25 @@ public class Cursor implements java.io.Serializable {
|
||||
if (st.countTokens() != 2)
|
||||
throw new AWTException("failed to parse hotspot property for cursor: " + name);
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
final Point hotPoint;
|
||||
try {
|
||||
x = Integer.parseInt(st.nextToken());
|
||||
y = Integer.parseInt(st.nextToken());
|
||||
hotPoint = new Point(Integer.parseInt(st.nextToken()),
|
||||
Integer.parseInt(st.nextToken()));
|
||||
} catch (NumberFormatException nfe) {
|
||||
throw new AWTException("failed to parse hotspot property for cursor: " + name);
|
||||
}
|
||||
|
||||
try {
|
||||
final int fx = x;
|
||||
final int fy = y;
|
||||
final String flocalized = localized;
|
||||
final Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
final String file = RESOURCE_PREFIX + fileName;
|
||||
|
||||
cursor = java.security.AccessController.<Cursor>doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<Cursor>() {
|
||||
public Cursor run() throws Exception {
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
Image image = toolkit.getImage(
|
||||
systemCustomCursorDirPrefix + fileName);
|
||||
return toolkit.createCustomCursor(
|
||||
image, new Point(fx,fy), flocalized);
|
||||
}
|
||||
});
|
||||
cursor = AccessController.doPrivileged(
|
||||
(PrivilegedExceptionAction<Cursor>) () -> {
|
||||
URL url = Cursor.class.getResource(file);
|
||||
Image image = toolkit.getImage(url);
|
||||
return toolkit.createCustomCursor(image, hotPoint,
|
||||
localized);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
throw new AWTException(
|
||||
"Exception: " + e.getClass() + " " + e.getMessage() +
|
||||
@ -452,26 +435,19 @@ public class Cursor implements java.io.Serializable {
|
||||
systemCustomCursorProperties = new Properties();
|
||||
|
||||
try {
|
||||
AccessController.<Object>doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<Object>() {
|
||||
public Object run() throws Exception {
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream(
|
||||
systemCustomCursorPropertiesFile);
|
||||
systemCustomCursorProperties.load(fis);
|
||||
} finally {
|
||||
if (fis != null)
|
||||
fis.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedExceptionAction<Object>) () -> {
|
||||
try (InputStream is = Cursor.class
|
||||
.getResourceAsStream(PROPERTIES_FILE)) {
|
||||
systemCustomCursorProperties.load(is);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
} catch (Exception e) {
|
||||
systemCustomCursorProperties = null;
|
||||
throw new AWTException("Exception: " + e.getClass() + " " +
|
||||
e.getMessage() + " occurred while loading: " +
|
||||
systemCustomCursorPropertiesFile);
|
||||
PROPERTIES_FILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ public class ICC_ColorSpace extends ColorSpace {
|
||||
public float getMinValue(int component) {
|
||||
if ((component < 0) || (component > this.getNumComponents() - 1)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Component index out of range: + component");
|
||||
"Component index out of range: " + component);
|
||||
}
|
||||
return minVal[component];
|
||||
}
|
||||
@ -571,7 +571,7 @@ public class ICC_ColorSpace extends ColorSpace {
|
||||
public float getMaxValue(int component) {
|
||||
if ((component < 0) || (component > this.getNumComponents() - 1)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Component index out of range: + component");
|
||||
"Component index out of range: " + component);
|
||||
}
|
||||
return maxVal[component];
|
||||
}
|
||||
|
@ -3763,12 +3763,6 @@ public abstract class JComponent extends Container implements Serializable,
|
||||
* @param listener the PropertyChangeListener to be added
|
||||
*/
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
if (accessibleContainerHandler == null) {
|
||||
accessibleContainerHandler = new AccessibleContainerHandler();
|
||||
}
|
||||
if (propertyListenersCount++ == 0) {
|
||||
JComponent.this.addContainerListener(accessibleContainerHandler);
|
||||
}
|
||||
super.addPropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
@ -3780,9 +3774,6 @@ public abstract class JComponent extends Container implements Serializable,
|
||||
* @param listener the PropertyChangeListener to be removed
|
||||
*/
|
||||
public void removePropertyChangeListener(PropertyChangeListener listener) {
|
||||
if (--propertyListenersCount == 0) {
|
||||
JComponent.this.removeContainerListener(accessibleContainerHandler);
|
||||
}
|
||||
super.removePropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
|
@ -476,7 +476,8 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
|
||||
}
|
||||
// Then the y:
|
||||
y = s.height + yOffset; // Prefer dropping down
|
||||
if (position.y + y + pmSize.height >= screenBounds.height &&
|
||||
if (position.y + y + pmSize.height >= screenBounds.height
|
||||
+ screenBounds.y &&
|
||||
// popup doesn't fit - place it wherever there's more room
|
||||
screenBounds.height - s.height < 2*(position.y
|
||||
- screenBounds.y)) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -872,11 +872,13 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
treeModelListener = createTreeModelListener();
|
||||
if(treeModelListener != null)
|
||||
treeModel.addTreeModelListener(treeModelListener);
|
||||
|
||||
// Mark the root as expanded, if it isn't a leaf.
|
||||
if(treeModel.getRoot() != null &&
|
||||
!treeModel.isLeaf(treeModel.getRoot())) {
|
||||
expandedState.put(new TreePath(treeModel.getRoot()),
|
||||
Boolean.TRUE);
|
||||
Object treeRoot = treeModel.getRoot();
|
||||
if(treeRoot != null &&
|
||||
!treeModel.isLeaf(treeRoot)) {
|
||||
expandedState.put(new TreePath(treeRoot),
|
||||
Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
firePropertyChange(TREE_MODEL_PROPERTY, oldModel, treeModel);
|
||||
@ -3000,8 +3002,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
* Expands the root path, assuming the current TreeModel has been set.
|
||||
*/
|
||||
private void expandRoot() {
|
||||
TreeModel model = getModel();
|
||||
|
||||
TreeModel model = getModel();
|
||||
if(model != null && model.getRoot() != null) {
|
||||
expandPath(new TreePath(model.getRoot()));
|
||||
}
|
||||
@ -3271,9 +3272,12 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
return null;
|
||||
|
||||
int count = indexs.length;
|
||||
Object parent = model.getRoot();
|
||||
TreePath parentPath = new TreePath(parent);
|
||||
|
||||
Object parent = model.getRoot();
|
||||
if (parent == null)
|
||||
return null;
|
||||
|
||||
TreePath parentPath = new TreePath(parent);
|
||||
for(int counter = 0; counter < count; counter++) {
|
||||
parent = model.getChild(parent, indexs[counter]);
|
||||
if(parent == null)
|
||||
@ -3860,8 +3864,11 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
if (parent.getPathCount() == 1) {
|
||||
// New root, remove everything!
|
||||
clearToggledPaths();
|
||||
if(treeModel.getRoot() != null &&
|
||||
!treeModel.isLeaf(treeModel.getRoot())) {
|
||||
|
||||
Object treeRoot = treeModel.getRoot();
|
||||
|
||||
if(treeRoot != null &&
|
||||
!treeModel.isLeaf(treeRoot)) {
|
||||
// Mark the root as expanded, if it isn't a leaf.
|
||||
expandedState.put(parent, Boolean.TRUE);
|
||||
}
|
||||
@ -4351,7 +4358,12 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
TreePath path = new TreePath(model.getRoot());
|
||||
|
||||
Object treeRoot = model.getRoot();
|
||||
if (treeRoot == null) {
|
||||
return null;
|
||||
}
|
||||
TreePath path = new TreePath(treeRoot);
|
||||
if (JTree.this.isVisible(path)) {
|
||||
TreeCellRenderer r = JTree.this.getCellRenderer();
|
||||
TreeUI ui = JTree.this.getUI();
|
||||
@ -4364,8 +4376,8 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
boolean expanded = JTree.this.isExpanded(path);
|
||||
|
||||
return r.getTreeCellRendererComponent(JTree.this,
|
||||
model.getRoot(), selected, expanded,
|
||||
model.isLeaf(model.getRoot()), row, hasFocus);
|
||||
treeRoot, selected, expanded,
|
||||
model.isLeaf(treeRoot), row, hasFocus);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -4418,8 +4430,12 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
return 1; // the root node
|
||||
}
|
||||
|
||||
Object treeRoot = model.getRoot();
|
||||
if (treeRoot == null)
|
||||
return 0;
|
||||
|
||||
// return the root's first set of children count
|
||||
return model.getChildCount(model.getRoot());
|
||||
return model.getChildCount(treeRoot);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4433,9 +4449,15 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Object treeRoot = model.getRoot();
|
||||
if (treeRoot == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isRootVisible()) {
|
||||
if (i == 0) { // return the root node Accessible
|
||||
Object[] objPath = { model.getRoot() };
|
||||
Object[] objPath = { treeRoot };
|
||||
TreePath path = new TreePath(objPath);
|
||||
return new AccessibleJTreeNode(JTree.this, path, JTree.this);
|
||||
} else {
|
||||
@ -4444,12 +4466,16 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
}
|
||||
|
||||
// return Accessible for one of root's child nodes
|
||||
int count = model.getChildCount(model.getRoot());
|
||||
int count = model.getChildCount(treeRoot);
|
||||
if (i < 0 || i >= count) {
|
||||
return null;
|
||||
}
|
||||
Object obj = model.getChild(model.getRoot(), i);
|
||||
Object[] objPath = { model.getRoot(), obj };
|
||||
Object obj = model.getChild(treeRoot, i);
|
||||
if (obj == null)
|
||||
return null;
|
||||
|
||||
Object[] objPath = {treeRoot, obj };
|
||||
|
||||
TreePath path = new TreePath(objPath);
|
||||
return new AccessibleJTreeNode(JTree.this, path, JTree.this);
|
||||
}
|
||||
@ -4488,6 +4514,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
public int getAccessibleSelectionCount() {
|
||||
Object[] rootPath = new Object[1];
|
||||
rootPath[0] = treeModel.getRoot();
|
||||
if (rootPath[0] == null)
|
||||
return 0;
|
||||
|
||||
TreePath childPath = new TreePath(rootPath);
|
||||
if (JTree.this.isPathSelected(childPath)) {
|
||||
return 1;
|
||||
@ -4510,6 +4539,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
if (i == 0) {
|
||||
Object[] rootPath = new Object[1];
|
||||
rootPath[0] = treeModel.getRoot();
|
||||
if (rootPath[0] == null)
|
||||
return null;
|
||||
|
||||
TreePath childPath = new TreePath(rootPath);
|
||||
if (JTree.this.isPathSelected(childPath)) {
|
||||
return new AccessibleJTreeNode(JTree.this, childPath, JTree.this);
|
||||
@ -4529,6 +4561,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
if (i == 0) {
|
||||
Object[] rootPath = new Object[1];
|
||||
rootPath[0] = treeModel.getRoot();
|
||||
if (rootPath[0] == null)
|
||||
return false;
|
||||
|
||||
TreePath childPath = new TreePath(rootPath);
|
||||
return JTree.this.isPathSelected(childPath);
|
||||
} else {
|
||||
@ -4549,7 +4584,10 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
TreeModel model = JTree.this.getModel();
|
||||
if (model != null) {
|
||||
if (i == 0) {
|
||||
Object[] objPath = {model.getRoot()};
|
||||
Object[] objPath = {model.getRoot()};
|
||||
if (objPath[0] == null)
|
||||
return;
|
||||
|
||||
TreePath path = new TreePath(objPath);
|
||||
JTree.this.addSelectionPath(path);
|
||||
}
|
||||
@ -4568,6 +4606,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
if (model != null) {
|
||||
if (i == 0) {
|
||||
Object[] objPath = {model.getRoot()};
|
||||
if (objPath[0] == null)
|
||||
return;
|
||||
|
||||
TreePath path = new TreePath(objPath);
|
||||
JTree.this.removeSelectionPath(path);
|
||||
}
|
||||
@ -4593,6 +4634,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
TreeModel model = JTree.this.getModel();
|
||||
if (model != null) {
|
||||
Object[] objPath = {model.getRoot()};
|
||||
if (objPath[0] == null)
|
||||
return;
|
||||
|
||||
TreePath path = new TreePath(objPath);
|
||||
JTree.this.addSelectionPath(path);
|
||||
}
|
||||
|
@ -377,15 +377,16 @@ public class BasicOptionPaneUI extends OptionPaneUI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the appropriate object to represent {@code msg} and
|
||||
* places it into {@code container}. If {@code msg} is an instance of
|
||||
* {@code Component}, it is added directly, if it is an {@code Icon},
|
||||
* a {@code JLabel} is created to represent it, otherwise a {@code JLabel} is
|
||||
* created for the string, if {@code d} is an Object[], this method
|
||||
* will be recursively invoked for the children. {@code internallyCreated} is
|
||||
* {@code true} if Objc is an instance of {@code Component} and was created
|
||||
* internally by this method (this is used to correctly set
|
||||
* {@code hasCustomComponents} only if {@code internallyCreated} is {@code false}).
|
||||
* Creates the appropriate object to represent {@code msg} and places it
|
||||
* into {@code container}. If {@code msg} is an instance of
|
||||
* {@code Component}, it is added directly; if it is an {@code Icon}, a
|
||||
* {@code JLabel} is created to represent it; otherwise, a {@code JLabel}
|
||||
* is created for the string. If {@code msg} is an Object[], this method
|
||||
* will be recursively invoked for the children. {@code internallyCreated}
|
||||
* is {@code true} if {@code msg} is an instance of {@code Component} and
|
||||
* was created internally by this method (this is used to correctly set
|
||||
* {@code hasCustomComponents} only if {@code internallyCreated} is
|
||||
* {@code false}).
|
||||
*
|
||||
* @param container a container
|
||||
* @param cons an instance of {@code GridBagConstraints}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2014, 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
|
||||
@ -686,7 +686,12 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
|
||||
|
||||
if (toFocus != null) {
|
||||
if (parent instanceof EmbeddedFrame) {
|
||||
((EmbeddedFrame)parent).synthesizeWindowActivation(true);
|
||||
// JDK-8056915: Try to request focus to the embedder first and
|
||||
// activate the embedded frame through it
|
||||
if (!((EmbeddedFrame) parent).requestFocusToEmbedder()) {
|
||||
// Otherwise activate the embedded frame directly
|
||||
((EmbeddedFrame) parent).synthesizeWindowActivation(true);
|
||||
}
|
||||
}
|
||||
// EmbeddedFrame might have focus before the applet was added.
|
||||
// Thus after its activation the most recent focus owner will be
|
||||
|
@ -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
|
||||
@ -360,6 +360,15 @@ public abstract class EmbeddedFrame extends Frame
|
||||
*/
|
||||
public void synthesizeWindowActivation(boolean doActivate) {}
|
||||
|
||||
/**
|
||||
* Requests the focus to the embedder.
|
||||
*
|
||||
* @return {@code true} if focus request was successful, and {@code false} otherwise.
|
||||
*/
|
||||
public boolean requestFocusToEmbedder() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves this embedded frame to a new location. The top-left corner of
|
||||
* the new location is specified by the <code>x</code> and <code>y</code>
|
||||
|
Before ![]() (image error) Size: 158 B After ![]() (image error) Size: 158 B ![]() ![]() |
Before ![]() (image error) Size: 162 B After ![]() (image error) Size: 162 B ![]() ![]() |
Before ![]() (image error) Size: 141 B After ![]() (image error) Size: 141 B ![]() ![]() |
@ -11,27 +11,27 @@
|
||||
# Cursor.<name>.<geom>.HotSpot=<x>,<y>
|
||||
# Cursor.<name>.<geom>.Name=<localized name>
|
||||
#
|
||||
Cursor.CopyDrop.32x32.File=motif_CopyDrop32x32.gif
|
||||
Cursor.CopyDrop.32x32.File=CopyDrop32x32.gif
|
||||
Cursor.CopyDrop.32x32.HotSpot=0,0
|
||||
Cursor.CopyDrop.32x32.Name=CopyDrop32x32
|
||||
#
|
||||
Cursor.MoveDrop.32x32.File=motif_MoveDrop32x32.gif
|
||||
Cursor.MoveDrop.32x32.File=MoveDrop32x32.gif
|
||||
Cursor.MoveDrop.32x32.HotSpot=0,0
|
||||
Cursor.MoveDrop.32x32.Name=MoveDrop32x32
|
||||
#
|
||||
Cursor.LinkDrop.32x32.File=motif_LinkDrop32x32.gif
|
||||
Cursor.LinkDrop.32x32.File=LinkDrop32x32.gif
|
||||
Cursor.LinkDrop.32x32.HotSpot=0,0
|
||||
Cursor.LinkDrop.32x32.Name=LinkDrop32x32
|
||||
#
|
||||
Cursor.CopyNoDrop.32x32.File=motif_CopyNoDrop32x32.gif
|
||||
Cursor.CopyNoDrop.32x32.File=invalid32x32.gif
|
||||
Cursor.CopyNoDrop.32x32.HotSpot=6,2
|
||||
Cursor.CopyNoDrop.32x32.Name=CopyNoDrop32x32
|
||||
#
|
||||
Cursor.MoveNoDrop.32x32.File=motif_MoveNoDrop32x32.gif
|
||||
Cursor.MoveNoDrop.32x32.File=invalid32x32.gif
|
||||
Cursor.MoveNoDrop.32x32.HotSpot=6,2
|
||||
Cursor.MoveNoDrop.32x32.Name=MoveNoDrop32x32
|
||||
#
|
||||
Cursor.LinkNoDrop.32x32.File=motif_LinkNoDrop32x32.gif
|
||||
Cursor.LinkNoDrop.32x32.File=invalid32x32.gif
|
||||
Cursor.LinkNoDrop.32x32.HotSpot=6,2
|
||||
Cursor.LinkNoDrop.32x32.Name=LinkNoDrop32x32
|
||||
#
|
Before ![]() (image error) Size: 153 B After ![]() (image error) Size: 153 B ![]() ![]() |
Before ![]() (image error) Size: 153 B |
Before ![]() (image error) Size: 153 B |
Before ![]() (image error) Size: 153 B |
Before ![]() (image error) Size: 153 B |
Before ![]() (image error) Size: 153 B |
Before ![]() (image error) Size: 153 B |
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 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
|
||||
@ -38,19 +38,6 @@ JNIEXPORT jboolean JNICALL Java_com_sun_media_sound_Platform_nIsBigEndian(JNIEnv
|
||||
return UTIL_IsBigEndianPlatform();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: com_sun_media_sound_Platform
|
||||
* Method: nIsSigned8
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_com_sun_media_sound_Platform_nIsSigned8(JNIEnv *env, jclass clss) {
|
||||
#if ((X_ARCH == X_SPARC) || (X_ARCH == X_SPARCV9))
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: com_sun_media_sound_Platform
|
||||
* Method: nGetExtraLibraries
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -34,32 +34,14 @@
|
||||
#define X_BSD 4
|
||||
#define X_MACOSX 5
|
||||
|
||||
// types for X_ARCH
|
||||
#define X_I586 1
|
||||
#define X_SPARC 2
|
||||
#define X_SPARCV9 3
|
||||
#define X_IA64 4
|
||||
#define X_AMD64 5
|
||||
#define X_ZERO 6
|
||||
#define X_ARM 7
|
||||
#define X_PPC 8
|
||||
|
||||
#define X_AARCH64 9
|
||||
// **********************************
|
||||
// Make sure you set X_PLATFORM and X_ARCH defines correctly.
|
||||
// Make sure you set X_PLATFORM defines correctly.
|
||||
// Everything depends upon this flag being setup correctly.
|
||||
// **********************************
|
||||
|
||||
#if (X_PLATFORM == X_MACOSX) && !defined(X_ARCH)
|
||||
#if __x86_64__
|
||||
#define X_ARCH X_AMD64
|
||||
#endif
|
||||
#if __i386__
|
||||
#define X_ARCH X_I586
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (!defined(X_PLATFORM) || !defined(X_ARCH))
|
||||
#error "You need to define X_PLATFORM and X_ARCH outside of the source. Use the types above."
|
||||
#if (!defined(X_PLATFORM))
|
||||
#error "You need to define X_PLATFORM outside of the source. Use the types above."
|
||||
#endif
|
||||
|
||||
|
||||
|
Before ![]() (image error) Size: 165 B After ![]() (image error) Size: 165 B ![]() ![]() |
Before ![]() (image error) Size: 168 B After ![]() (image error) Size: 168 B ![]() ![]() |
Before ![]() (image error) Size: 147 B After ![]() (image error) Size: 147 B ![]() ![]() |
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2014, 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
|
||||
@ -52,6 +52,11 @@ public class WEmbeddedFrame extends EmbeddedFrame {
|
||||
private static int pScale = 0;
|
||||
private static final int MAX_BAND_SIZE = (1024*30);
|
||||
|
||||
/**
|
||||
* This flag is set to {@code true} if this embedded frame is hosted by Internet Explorer.
|
||||
*/
|
||||
private boolean isEmbeddedInIE = false;
|
||||
|
||||
private static String printScale = AccessController.doPrivileged(
|
||||
new GetPropertyAction("sun.java2d.print.pluginscalefactor"));
|
||||
|
||||
@ -244,6 +249,14 @@ public class WEmbeddedFrame extends EmbeddedFrame {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean requestFocusToEmbedder() {
|
||||
if (isEmbeddedInIE) {
|
||||
return ((WEmbeddedFramePeer) getPeer()).requestFocusToEmbedder();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void registerAccelerator(AWTKeyStroke stroke) {}
|
||||
public void unregisterAccelerator(AWTKeyStroke stroke) {}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2014, 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
|
||||
@ -78,4 +78,11 @@ public class WEmbeddedFramePeer extends WFramePeer {
|
||||
// false on other systems.
|
||||
return !Win32GraphicsEnvironment.isDWMCompositionEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the focus to plugin control window, the parent of embedded frame.
|
||||
* Eventually, it will synthesizeWindowActivation to activate the embedded frame,
|
||||
* if plugin control window gets the focus.
|
||||
*/
|
||||
public native boolean requestFocusToEmbedder();
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
#
|
||||
#
|
||||
# Cursors Properties file
|
||||
#
|
||||
# Names GIF89 sources for Custom Cursors and their associated HotSpots
|
||||
#
|
||||
# Note: the syntax of the property name is significant and is parsed
|
||||
# by java.awt.Cursor
|
||||
#
|
||||
# The syntax is: Cursor.<name>.<geom>.File=win32_<filename>
|
||||
# Cursor.<name>.<geom>.HotSpot=<x>,<y>
|
||||
# Cursor.<name>.<geom>.Name=<localized name>
|
||||
#
|
||||
Cursor.CopyDrop.32x32.File=win32_CopyDrop32x32.gif
|
||||
Cursor.CopyDrop.32x32.HotSpot=0,0
|
||||
Cursor.CopyDrop.32x32.Name=CopyDrop32x32
|
||||
#
|
||||
Cursor.MoveDrop.32x32.File=win32_MoveDrop32x32.gif
|
||||
Cursor.MoveDrop.32x32.HotSpot=0,0
|
||||
Cursor.MoveDrop.32x32.Name=MoveDrop32x32
|
||||
#
|
||||
Cursor.LinkDrop.32x32.File=win32_LinkDrop32x32.gif
|
||||
Cursor.LinkDrop.32x32.HotSpot=0,0
|
||||
Cursor.LinkDrop.32x32.Name=LinkDrop32x32
|
||||
#
|
||||
Cursor.CopyNoDrop.32x32.File=win32_CopyNoDrop32x32.gif
|
||||
Cursor.CopyNoDrop.32x32.HotSpot=6,2
|
||||
Cursor.CopyNoDrop.32x32.Name=CopyNoDrop32x32
|
||||
#
|
||||
Cursor.MoveNoDrop.32x32.File=win32_MoveNoDrop32x32.gif
|
||||
Cursor.MoveNoDrop.32x32.HotSpot=6,2
|
||||
Cursor.MoveNoDrop.32x32.Name=MoveNoDrop32x32
|
||||
#
|
||||
Cursor.LinkNoDrop.32x32.File=win32_LinkNoDrop32x32.gif
|
||||
Cursor.LinkNoDrop.32x32.HotSpot=6,2
|
||||
Cursor.LinkNoDrop.32x32.Name=LinkNoDrop32x32
|
||||
#
|
||||
Cursor.Invalid.32x32.File=invalid32x32.gif
|
||||
Cursor.Invalid.32x32.HotSpot=6,2
|
||||
Cursor.Invalid.32x32.Name=Invalid32x32
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2014, 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
|
||||
@ -82,6 +82,15 @@ struct BlockedThreadStruct {
|
||||
HHOOK mouseHook;
|
||||
HHOOK modalHook;
|
||||
};
|
||||
|
||||
|
||||
// Communication with plugin control
|
||||
|
||||
// The value must be the same as in AxControl.h
|
||||
#define WM_AX_REQUEST_FOCUS_TO_EMBEDDER (WM_USER + 197)
|
||||
|
||||
static bool SetFocusToPluginControl(HWND hwndPlugin);
|
||||
|
||||
/************************************************************************
|
||||
* AwtFrame fields
|
||||
*/
|
||||
@ -93,6 +102,7 @@ jmethodID AwtFrame::getExtendedStateMID;
|
||||
jmethodID AwtFrame::setExtendedStateMID;
|
||||
|
||||
jmethodID AwtFrame::activateEmbeddingTopLevelMID;
|
||||
jfieldID AwtFrame::isEmbeddedInIEID;
|
||||
|
||||
Hashtable AwtFrame::sm_BlockedThreads("AWTBlockedThreads");
|
||||
|
||||
@ -104,6 +114,7 @@ AwtFrame::AwtFrame() {
|
||||
m_parentWnd = NULL;
|
||||
menuBar = NULL;
|
||||
m_isEmbedded = FALSE;
|
||||
m_isEmbeddedInIE = FALSE;
|
||||
m_isLightweight = FALSE;
|
||||
m_ignoreWmSize = FALSE;
|
||||
m_isMenuDropped = FALSE;
|
||||
@ -199,6 +210,13 @@ AwtFrame* AwtFrame::Create(jobject self, jobject parent)
|
||||
|
||||
if (isEmbedded) {
|
||||
hwndParent = (HWND)handle;
|
||||
|
||||
// JDK-8056915: Handle focus communication between plugin and frame
|
||||
frame->m_isEmbeddedInIE = IsEmbeddedInIE(hwndParent);
|
||||
if (frame->m_isEmbeddedInIE) {
|
||||
env->SetBooleanField(target, isEmbeddedInIEID, JNI_TRUE);
|
||||
}
|
||||
|
||||
RECT rect;
|
||||
::GetClientRect(hwndParent, &rect);
|
||||
//Fix for 6328675: SWT_AWT.new_Frame doesn't occupy client area under JDK6
|
||||
@ -338,6 +356,21 @@ done:
|
||||
return frame;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if the frame is embedded into Internet Explorer.
|
||||
* The function checks the class name of the parent window of the embedded frame.
|
||||
*/
|
||||
BOOL AwtFrame::IsEmbeddedInIE(HWND hwndParent)
|
||||
{
|
||||
const char *pluginClass = "Java Plug-in Control Window";
|
||||
#define PARENT_CLASS_BUFFER_SIZE 64
|
||||
char parentClass[PARENT_CLASS_BUFFER_SIZE];
|
||||
|
||||
return (::GetClassNameA(hwndParent, parentClass, PARENT_CLASS_BUFFER_SIZE) > 0)
|
||||
&& (strncmp(parentClass, pluginClass, PARENT_CLASS_BUFFER_SIZE) == 0);
|
||||
}
|
||||
|
||||
|
||||
LRESULT AwtFrame::ProxyWindowProc(UINT message, WPARAM wParam, LPARAM lParam, MsgRouting &mr)
|
||||
{
|
||||
LRESULT retValue = 0L;
|
||||
@ -1039,6 +1072,19 @@ BOOL AwtFrame::AwtSetActiveWindow(BOOL isMouseEventCause, UINT hittest)
|
||||
if (IsLightweightFrame()) {
|
||||
return TRUE;
|
||||
}
|
||||
if (isMouseEventCause && IsEmbeddedFrame() && m_isEmbeddedInIE) {
|
||||
HWND hwndProxy = GetProxyFocusOwner();
|
||||
// Do nothing if this frame is focused already
|
||||
if (::GetFocus() != hwndProxy) {
|
||||
// Fix for JDK-8056915:
|
||||
// If window activated with mouse, set focus to plugin control window
|
||||
// first to preserve focus owner inside browser window
|
||||
if (SetFocusToPluginControl(::GetParent(GetHWnd()))) {
|
||||
return TRUE;
|
||||
}
|
||||
// Plugin control window is already focused, so do normal processing
|
||||
}
|
||||
}
|
||||
return AwtWindow::AwtSetActiveWindow(isMouseEventCause);
|
||||
}
|
||||
|
||||
@ -1819,6 +1865,9 @@ Java_sun_awt_windows_WEmbeddedFrame_initIDs(JNIEnv *env, jclass cls)
|
||||
AwtFrame::activateEmbeddingTopLevelMID = env->GetMethodID(cls, "activateEmbeddingTopLevel", "()V");
|
||||
DASSERT(AwtFrame::activateEmbeddingTopLevelMID != NULL);
|
||||
|
||||
AwtFrame::isEmbeddedInIEID = env->GetFieldID(cls, "isEmbeddedInIE", "Z");
|
||||
DASSERT(AwtFrame::isEmbeddedInIEID != NULL);
|
||||
|
||||
CATCH_BAD_ALLOC;
|
||||
}
|
||||
|
||||
@ -1911,4 +1960,44 @@ Java_sun_awt_windows_WFramePeer_synthesizeWmActivate(JNIEnv *env, jobject self,
|
||||
CATCH_BAD_ALLOC;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_sun_awt_windows_WEmbeddedFramePeer_requestFocusToEmbedder(JNIEnv *env, jobject self)
|
||||
{
|
||||
jboolean result = JNI_FALSE;
|
||||
|
||||
TRY;
|
||||
|
||||
AwtFrame *frame = NULL;
|
||||
|
||||
PDATA pData;
|
||||
JNI_CHECK_PEER_GOTO(self, ret);
|
||||
frame = (AwtFrame *)pData;
|
||||
|
||||
// JDK-8056915: During initial applet activation, set focus to plugin control window
|
||||
HWND hwndParent = ::GetParent(frame->GetHWnd());
|
||||
|
||||
result = SetFocusToPluginControl(hwndParent);
|
||||
|
||||
CATCH_BAD_ALLOC_RET(JNI_FALSE);
|
||||
ret:
|
||||
return result;
|
||||
}
|
||||
|
||||
} /* extern "C" */
|
||||
|
||||
static bool SetFocusToPluginControl(HWND hwndPlugin)
|
||||
{
|
||||
HWND hwndFocus = ::GetFocus();
|
||||
|
||||
if (hwndFocus == hwndPlugin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
::SetFocus(hwndPlugin);
|
||||
DWORD dwError = ::GetLastError();
|
||||
if (dwError != ERROR_SUCCESS) {
|
||||
// If direct call failed, use a special message to set focus
|
||||
return (::SendMessage(hwndPlugin, WM_AX_REQUEST_FOCUS_TO_EMBEDDER, 0, 0) == 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -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
|
||||
@ -60,6 +60,9 @@ public:
|
||||
/* method id for WEmbeddedFrame.requestActivate() method */
|
||||
static jmethodID activateEmbeddingTopLevelMID;
|
||||
|
||||
/* field id for WEmbeddedFrame.isEmbeddedInIE */
|
||||
static jfieldID isEmbeddedInIEID;
|
||||
|
||||
AwtFrame();
|
||||
virtual ~AwtFrame();
|
||||
|
||||
@ -171,6 +174,13 @@ private:
|
||||
/* The frame is an EmbeddedFrame. */
|
||||
BOOL m_isEmbedded;
|
||||
|
||||
/* Fix for JDK-8056915:
|
||||
The embedded frame must gain focus by setting focus to its parent. */
|
||||
BOOL m_isEmbeddedInIE;
|
||||
|
||||
/* Checks whether the frame is embedded in IE */
|
||||
static BOOL IsEmbeddedInIE(HWND hwndParent);
|
||||
|
||||
/* The frame is a LightweightFrame */
|
||||
BOOL m_isLightweight;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 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
|
||||
@ -538,6 +538,13 @@ public abstract class ClientNotifForwarder {
|
||||
currentFetchThread = null;
|
||||
}
|
||||
|
||||
if (nr == null) {
|
||||
if (logger.traceOn()) {
|
||||
logger.trace("NotifFetcher-run",
|
||||
"Recieved null object as notifs, stops fetching because the "
|
||||
+ "notification server is terminated.");
|
||||
}
|
||||
}
|
||||
if (nr == null || shouldStop()) {
|
||||
// tell that the thread is REALLY stopped
|
||||
setState(STOPPED);
|
||||
@ -657,7 +664,7 @@ public abstract class ClientNotifForwarder {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (shouldStop())
|
||||
if (shouldStop() || nr == null)
|
||||
return null;
|
||||
|
||||
startSequenceNumber = nr.getNextSequenceNumber();
|
||||
|
@ -1254,10 +1254,11 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
|
||||
if (serverTerminated) {
|
||||
// we must not call fetchNotifs() if the server is
|
||||
// terminated (timeout elapsed).
|
||||
//
|
||||
return new NotificationResult(0L, 0L,
|
||||
new TargetedNotification[0]);
|
||||
|
||||
// returns null to force the client to stop fetching
|
||||
if (logger.debugOn()) logger.debug("fetchNotifications",
|
||||
"The notification server has been closed, "
|
||||
+ "returns null to force the client to stop fetching");
|
||||
return null;
|
||||
}
|
||||
final long csn = clientSequenceNumber;
|
||||
final int mn = maxNotifications;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 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
|
||||
@ -282,6 +282,7 @@ public class ObjectReferenceImpl extends ValueImpl
|
||||
* implemented interface
|
||||
*/
|
||||
ReferenceTypeImpl declType = (ReferenceTypeImpl)method.declaringType();
|
||||
|
||||
if (!declType.isAssignableFrom(this)) {
|
||||
throw new IllegalArgumentException("Invalid method");
|
||||
}
|
||||
@ -311,7 +312,7 @@ public class ObjectReferenceImpl extends ValueImpl
|
||||
/*
|
||||
* For nonvirtual invokes, method must have a body
|
||||
*/
|
||||
if ((options & INVOKE_NONVIRTUAL) != 0) {
|
||||
if (isNonVirtual(options)) {
|
||||
if (method.isAbstract()) {
|
||||
throw new IllegalArgumentException("Abstract method");
|
||||
}
|
||||
@ -323,7 +324,7 @@ public class ObjectReferenceImpl extends ValueImpl
|
||||
* method argument types.
|
||||
*/
|
||||
ClassTypeImpl invokedClass;
|
||||
if ((options & INVOKE_NONVIRTUAL) != 0) {
|
||||
if (isNonVirtual(options)) {
|
||||
// No overrides in non-virtual invokes
|
||||
invokedClass = clazz;
|
||||
} else {
|
||||
@ -348,7 +349,7 @@ public class ObjectReferenceImpl extends ValueImpl
|
||||
/*
|
||||
* Only default methods allowed for nonvirtual invokes
|
||||
*/
|
||||
if (!method.isDefault()) {
|
||||
if (isNonVirtual(options) && !method.isDefault()) {
|
||||
throw new IllegalArgumentException("Not a default method");
|
||||
}
|
||||
}
|
||||
@ -383,6 +384,7 @@ public class ObjectReferenceImpl extends ValueImpl
|
||||
IncompatibleThreadStateException,
|
||||
InvocationException,
|
||||
ClassNotLoadedException {
|
||||
|
||||
validateMirror(threadIntf);
|
||||
validateMirror(methodIntf);
|
||||
validateMirrorsOrNulls(origArguments);
|
||||
@ -624,4 +626,8 @@ public class ObjectReferenceImpl extends ValueImpl
|
||||
byte typeValueKey() {
|
||||
return JDWP.Tag.OBJECT;
|
||||
}
|
||||
|
||||
private static boolean isNonVirtual(int options) {
|
||||
return (options & INVOKE_NONVIRTUAL) != 0;
|
||||
}
|
||||
}
|
||||
|
@ -46,8 +46,10 @@ value(PacketInputStream *in, PacketOutputStream *out)
|
||||
char *utf;
|
||||
|
||||
utf = (char *)JNI_FUNC_PTR(env,GetStringUTFChars)(env, string, NULL);
|
||||
(void)outStream_writeString(out, utf);
|
||||
JNI_FUNC_PTR(env,ReleaseStringUTFChars)(env, string, utf);
|
||||
if (!(*env)->ExceptionCheck(env)) {
|
||||
(void)outStream_writeString(out, utf);
|
||||
JNI_FUNC_PTR(env,ReleaseStringUTFChars)(env, string, utf);
|
||||
}
|
||||
|
||||
} END_WITH_LOCAL_REFS(env);
|
||||
|
||||
|
@ -98,7 +98,9 @@ createNode(JNIEnv *env, jobject ref)
|
||||
|
||||
/* Create weak reference to make sure we have a reference */
|
||||
weakRef = JNI_FUNC_PTR(env,NewWeakGlobalRef)(env, ref);
|
||||
if (weakRef == NULL) {
|
||||
// NewWeakGlobalRef can throw OOM, clear exception here.
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
(*env)->ExceptionClear(env);
|
||||
jvmtiDeallocate(node);
|
||||
return NULL;
|
||||
}
|
||||
@ -154,6 +156,7 @@ strengthenNode(JNIEnv *env, RefNode *node)
|
||||
/*
|
||||
* NewGlobalRef on a weak ref will return NULL if the weak
|
||||
* reference has been collected or if out of memory.
|
||||
* It never throws OOM.
|
||||
* We need to distinguish those two occurrences.
|
||||
*/
|
||||
if ((strongRef == NULL) && !isSameObject(env, node->ref, NULL)) {
|
||||
@ -178,6 +181,11 @@ weakenNode(JNIEnv *env, RefNode *node)
|
||||
jweak weakRef;
|
||||
|
||||
weakRef = JNI_FUNC_PTR(env,NewWeakGlobalRef)(env, node->ref);
|
||||
// NewWeakGlobalRef can throw OOM, clear exception here.
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
(*env)->ExceptionClear(env);
|
||||
}
|
||||
|
||||
if (weakRef != NULL) {
|
||||
JNI_FUNC_PTR(env,DeleteGlobalRef)(env, node->ref);
|
||||
node->ref = weakRef;
|
||||
@ -452,6 +460,7 @@ commonRef_idToRef(JNIEnv *env, jlong id)
|
||||
jobject lref;
|
||||
|
||||
lref = JNI_FUNC_PTR(env,NewLocalRef)(env, node->ref);
|
||||
// NewLocalRef never throws OOM.
|
||||
if ( lref == NULL ) {
|
||||
/* Object was GC'd shortly after we found the node */
|
||||
deleteNodeByID(env, node->seqNum, ALL_REFS);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 201, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 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
|
||||
@ -237,10 +237,10 @@ class ZipFileSystem extends FileSystem {
|
||||
String syntax = syntaxAndInput.substring(0, pos);
|
||||
String input = syntaxAndInput.substring(pos + 1);
|
||||
String expr;
|
||||
if (syntax.equals(GLOB_SYNTAX)) {
|
||||
if (syntax.equalsIgnoreCase(GLOB_SYNTAX)) {
|
||||
expr = toRegexPattern(input);
|
||||
} else {
|
||||
if (syntax.equals(REGEX_SYNTAX)) {
|
||||
if (syntax.equalsIgnoreCase(REGEX_SYNTAX)) {
|
||||
expr = input;
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Syntax '" + syntax +
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 1995, 2014, 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
|
||||
@ -112,6 +112,19 @@ ifdef JPRT_PRODUCT_VM_ARGS
|
||||
JAVA_VM_ARGS = $(JPRT_PRODUCT_VM_ARGS)
|
||||
endif
|
||||
|
||||
# jtreg -nativepath <dir>
|
||||
#
|
||||
# Local make tests will be TEST_IMAGE_DIR and JPRT with jprt.use.reg.test.bundle=true
|
||||
# should be JPRT_TESTNATIVE_PATH
|
||||
ifdef TEST_IMAGE_DIR
|
||||
TESTNATIVE_DIR = $(TEST_IMAGE_DIR)
|
||||
else ifdef JPRT_TESTNATIVE_PATH
|
||||
TESTNATIVE_DIR = $(JPRT_TESTNATIVE_PATH)
|
||||
endif
|
||||
ifdef TESTNATIVE_DIR
|
||||
JTREG_NATIVE_PATH = -nativepath:$(shell $(GETMIXEDPATH) "$(TESTNATIVE_DIR)/jdk/jtreg/native")
|
||||
endif
|
||||
|
||||
# Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results)
|
||||
ifdef JPRT_ARCHIVE_BUNDLE
|
||||
ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE)
|
||||
@ -313,6 +326,7 @@ jtreg_tests: prep $(PRODUCT_HOME) $(JTREG)
|
||||
-r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport") \
|
||||
-w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork") \
|
||||
-jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \
|
||||
$(JTREG_NATIVE_PATH) \
|
||||
$(JTREG_EXCLUSIONS) \
|
||||
$(JTREG_TEST_OPTIONS) \
|
||||
$(TEST_SELECTION) \
|
||||
|
@ -168,6 +168,9 @@ jdk_jmx = \
|
||||
jdk_jdi = \
|
||||
com/sun/jdi
|
||||
|
||||
jdk_native_sanity = \
|
||||
native_sanity
|
||||
|
||||
# java launcher specific tests, Note: do not include this group into any groups
|
||||
# that potentially could be included into a jprt test rule, as the complementary
|
||||
# closed group includes awt SplashScreen and these tests may not run
|
||||
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.lang.String;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import static java.lang.System.out;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4686632 8048610
|
||||
* @summary To verify Cipher.init will throw InvalidKeyException with
|
||||
* Non-empty message when create SecretKeySpec with invalid DES key
|
||||
* @author Kevin Liu
|
||||
*/
|
||||
public class Empty {
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
byte master[] = {
|
||||
0, 1, 2, 3, 4
|
||||
};
|
||||
SecretKey key = new SecretKeySpec(master, "DES");
|
||||
Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
throw new RuntimeException("InvalidKeyException not thrown");
|
||||
} catch (java.security.InvalidKeyException ike) {
|
||||
ike.printStackTrace();
|
||||
if (ike.getMessage() != null) {
|
||||
out.println("Status -- Passed");
|
||||
} else {
|
||||
throw new RuntimeException("Error message is not expected when"
|
||||
+ " InvalidKeyException is thrown");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 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
|
||||
@ -24,6 +24,7 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 8031195
|
||||
* @bug 8071657
|
||||
* @summary JDI: Add support for static and default methods in interfaces
|
||||
*
|
||||
* @run build TestScaffold VMConnection TargetListener TargetAdapter
|
||||
@ -38,6 +39,7 @@ public class InterfaceMethodsTest extends TestScaffold {
|
||||
private static final int RESULT_A = 1;
|
||||
private static final int RESULT_B = 1;
|
||||
private static final int RESULT_TARGET = 1;
|
||||
|
||||
static interface InterfaceA {
|
||||
static int staticMethodA() {
|
||||
System.out.println("-InterfaceA: static interface method A-");
|
||||
@ -202,6 +204,9 @@ public class InterfaceMethodsTest extends TestScaffold {
|
||||
|
||||
// try to invoke static method B on the instance
|
||||
testInvokePos(ifaceClass, ref, "staticMethodB", "()I", vm().mirrorOf(RESULT_A));
|
||||
|
||||
// try to invoke a virtual method
|
||||
testInvokePos(ifaceClass, ref, "implementedMethod", "()I", vm().mirrorOf(RESULT_A), true);
|
||||
}
|
||||
|
||||
private void testInterfaceB(ObjectReference ref) {
|
||||
@ -302,9 +307,14 @@ public class InterfaceMethodsTest extends TestScaffold {
|
||||
|
||||
private void testInvokePos(ReferenceType targetClass, ObjectReference ref, String methodName,
|
||||
String methodSig, Value value) {
|
||||
testInvokePos(targetClass, ref, methodName, methodSig, value, false);
|
||||
}
|
||||
|
||||
private void testInvokePos(ReferenceType targetClass, ObjectReference ref, String methodName,
|
||||
String methodSig, Value value, boolean virtual) {
|
||||
logInvocation(ref, methodName, methodSig, targetClass);
|
||||
try {
|
||||
invoke(targetClass, ref, methodName, methodSig, value);
|
||||
invoke(targetClass, ref, methodName, methodSig, value, virtual);
|
||||
System.err.println("--- PASSED");
|
||||
} catch (Exception e) {
|
||||
System.err.println("--- FAILED");
|
||||
@ -314,9 +324,14 @@ public class InterfaceMethodsTest extends TestScaffold {
|
||||
|
||||
private void testInvokeNeg(ReferenceType targetClass, ObjectReference ref, String methodName,
|
||||
String methodSig, Value value, String msg) {
|
||||
testInvokeNeg(targetClass, ref, methodName, methodSig, value, msg, false);
|
||||
}
|
||||
|
||||
private void testInvokeNeg(ReferenceType targetClass, ObjectReference ref, String methodName,
|
||||
String methodSig, Value value, String msg, boolean virtual) {
|
||||
logInvocation(ref, methodName, methodSig, targetClass);
|
||||
try {
|
||||
invoke(targetClass, ref, methodName, methodSig, value);
|
||||
invoke(targetClass, ref, methodName, methodSig, value, virtual);
|
||||
System.err.println("--- FAILED");
|
||||
failure("FAILED: " + msg);
|
||||
} catch (Exception e) {
|
||||
@ -326,7 +341,7 @@ public class InterfaceMethodsTest extends TestScaffold {
|
||||
}
|
||||
|
||||
private void invoke(ReferenceType targetClass, ObjectReference ref, String methodName,
|
||||
String methodSig, Value value)
|
||||
String methodSig, Value value, boolean virtual)
|
||||
throws Exception {
|
||||
Method method = getMethod(targetClass, methodName, methodSig);
|
||||
if (method == null) {
|
||||
@ -334,10 +349,15 @@ public class InterfaceMethodsTest extends TestScaffold {
|
||||
}
|
||||
|
||||
println("Invoking " + (method.isAbstract() ? "abstract " : " ") + "method: " + method);
|
||||
println(method.declaringType().toString());
|
||||
|
||||
Value returnValue = null;
|
||||
if (ref != null) {
|
||||
returnValue = invokeInstance(ref, method);
|
||||
if (virtual) {
|
||||
returnValue = invokeVirtual(ref, method);
|
||||
} else {
|
||||
returnValue = invokeInstance(ref, method);
|
||||
}
|
||||
} else {
|
||||
returnValue = invokeStatic(targetClass, method);
|
||||
}
|
||||
@ -362,6 +382,10 @@ public class InterfaceMethodsTest extends TestScaffold {
|
||||
return ref.invokeMethod(mainThread, method, Collections.emptyList(), ObjectReference.INVOKE_NONVIRTUAL);
|
||||
}
|
||||
|
||||
private Value invokeVirtual(ObjectReference ref, Method method) throws Exception {
|
||||
return ref.invokeMethod(mainThread, method, Collections.emptyList(), 0);
|
||||
}
|
||||
|
||||
private Value invokeStatic(ReferenceType refType, Method method) throws Exception {
|
||||
if (refType instanceof ClassType) {
|
||||
return ((ClassType)refType).invokeMethod(mainThread, method, Collections.emptyList(), ObjectReference.INVOKE_NONVIRTUAL);
|
||||
|
61
jdk/test/java/awt/Color/GetMinMaxValue_ICC_ColorSpace.java
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.color.ICC_ColorSpace;
|
||||
import java.awt.color.ICC_Profile;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8072678
|
||||
* @author Prasanta Sadhukhan
|
||||
*/
|
||||
|
||||
public class GetMinMaxValue_ICC_ColorSpace {
|
||||
|
||||
public static void main(String[] a) throws Exception {
|
||||
ICC_Profile cmyk_profile = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
|
||||
ICC_ColorSpace colorSpace = new ICC_ColorSpace(cmyk_profile);
|
||||
String minstr = null;
|
||||
String maxstr = null;
|
||||
|
||||
colorSpace.fromRGB(new float[]{4.3f,3.1f,2.2f});
|
||||
try {
|
||||
System.out.println("minvalue " + colorSpace.getMinValue(3));
|
||||
} catch (IllegalArgumentException iae) {
|
||||
minstr = iae.toString();
|
||||
}
|
||||
try {
|
||||
System.out.println("maxvalue " + colorSpace.getMaxValue(3));
|
||||
} catch (IllegalArgumentException iae) {
|
||||
maxstr = iae.toString();
|
||||
}
|
||||
|
||||
if (minstr.endsWith("+ component") || maxstr.endsWith("+ component")) {
|
||||
System.out.println("Test failed");
|
||||
throw new RuntimeException("IllegalArgumentException contains incorrect text message");
|
||||
} else {
|
||||
System.out.println("Test passed");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Cursor;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8039269
|
||||
* @author Sergey Bylokhov
|
||||
*/
|
||||
public final class GetSystemCustomCursor {
|
||||
|
||||
public static void main(final String[] args) throws AWTException {
|
||||
// This list is copied from cursors.properties
|
||||
String[] names = {"CopyDrop.32x32", "MoveDrop.32x32", "LinkDrop.32x32",
|
||||
"CopyNoDrop.32x32", "MoveNoDrop.32x32",
|
||||
"LinkNoDrop.32x32", "Invalid.32x32"};
|
||||
for (final String name : names) {
|
||||
if (Cursor.getSystemCustomCursor(name) == null) {
|
||||
throw new RuntimeException("Cursor is null: " + name);
|
||||
}
|
||||
}
|
||||
System.out.println("Test passed");
|
||||
}
|
||||
}
|
@ -30,37 +30,48 @@
|
||||
import java.io.*;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ClearHandleTable {
|
||||
private static final int TIMES = 1000;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
final int nreps = 100;
|
||||
ObjectOutputStream oout =
|
||||
new ObjectOutputStream(new ByteArrayOutputStream());
|
||||
WeakReference[] refs = new WeakReference[nreps];
|
||||
List<WeakReference<?>> refs = new ArrayList<>(nreps);
|
||||
|
||||
for (int i = 0; i < nreps; i++) {
|
||||
String str = new String("blargh");
|
||||
oout.writeObject(str);
|
||||
refs[i] = new WeakReference(str);
|
||||
refs.add(new WeakReference<Object>(str));
|
||||
}
|
||||
|
||||
oout.reset();
|
||||
exhaustMemory();
|
||||
|
||||
for (int i = 0; i < nreps; i++) {
|
||||
if (refs[i].get() != null) {
|
||||
throw new Error("failed to garbage collect object " + i);
|
||||
int count = 0;
|
||||
for (int i=0; i<TIMES; i++) {
|
||||
// relying on, possibly multiple, System.gc calls to clear weak references
|
||||
System.gc();
|
||||
|
||||
Iterator<WeakReference<?>> itr = refs.iterator();
|
||||
while(itr.hasNext()) {
|
||||
WeakReference<?> ref = itr.next();
|
||||
if (ref.get() == null) {
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
if (refs.isEmpty())
|
||||
break;
|
||||
Thread.sleep(20);
|
||||
count++;
|
||||
if (count % 10 == 0)
|
||||
System.out.println("Looping " + count + " times");
|
||||
}
|
||||
}
|
||||
|
||||
static void exhaustMemory() {
|
||||
ArrayList blob = new ArrayList();
|
||||
try {
|
||||
for (;;) {
|
||||
blob.add(new int[0xFFFF]);
|
||||
}
|
||||
} catch (OutOfMemoryError e) {
|
||||
if (!refs.isEmpty()) {
|
||||
throw new Error("failed to garbage collect object");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
45
jdk/test/java/lang/invoke/CustomizedLambdaFormTest.java
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.lang.invoke;
|
||||
|
||||
/* @test
|
||||
* @summary Assertion in LambdaFormEditor.bindArgumentType is too strong
|
||||
*
|
||||
* @run main/bootclasspath -esa java.lang.invoke.CustomizedLambdaFormTest
|
||||
*/
|
||||
public class CustomizedLambdaFormTest {
|
||||
|
||||
static void testExtendCustomizedBMH() throws Exception {
|
||||
// Construct BMH
|
||||
MethodHandle mh = MethodHandles.Lookup.IMPL_LOOKUP.findVirtual(String.class, "concat",
|
||||
MethodType.methodType(String.class, String.class))
|
||||
.bindTo("a");
|
||||
mh.customize();
|
||||
mh.bindTo("b"); // Try to extend customized BMH
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
testExtendCustomizedBMH();
|
||||
}
|
||||
}
|