--- a/jdk/make/Tools.gmk Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/make/Tools.gmk Tue Mar 25 14:51:01 2014 -0700
@@ -71,6 +71,7 @@
build.tools.generatecharacter.CharacterName
TOOL_DTDBUILDER = $(JAVA_SMALL) -Ddtd_home=$(JDK_TOPDIR)/make/data/dtdbuilder \
+ -Djava.awt.headless=true \
-cp $(JDK_OUTPUTDIR)/btclasses build.tools.dtdbuilder.DTDBuilder
TOOL_GENERATEBREAKITERATORDATA = $(JAVA_SMALL) \
--- a/jdk/make/lib/CoreLibraries.gmk Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/make/lib/CoreLibraries.gmk Tue Mar 25 14:51:01 2014 -0700
@@ -305,7 +305,7 @@
LDFLAGS_SUFFIX_linux := -ljvm -ljava, \
LDFLAGS_SUFFIX_solaris := -ljvm -ljava -lc, \
LDFLAGS_SUFFIX_aix := -ljvm -ljava, \
- LDFLAGS_SUFFIX_windows := advapi32.lib, \
+ LDFLAGS_SUFFIX_windows := advapi32.lib jvm.lib $(WIN_JAVA_LIB), \
LDFLAGS_SUFFIX_macosx := -ljvm -framework CoreFoundation, \
VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
RC_FLAGS := $(RC_FLAGS) \
--- a/jdk/make/lib/ServiceabilityLibraries.gmk Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/make/lib/ServiceabilityLibraries.gmk Tue Mar 25 14:51:01 2014 -0700
@@ -49,7 +49,7 @@
EXCLUDE_FILES := $(LIBATTACH_EXCLUDE_FILES), \
LANG := C, \
OPTIMIZATION := LOW, \
- CFLAGS := $(CFLAGS_JDKLIB), \
+ CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS), \
CFLAGS_windows := /Gy, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libattach/mapfile-$(OPENJDK_TARGET_OS), \
VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
@@ -79,7 +79,7 @@
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/socket, \
LANG := C, \
OPTIMIZATION := LOW, \
- CFLAGS := $(CFLAGS_JDKLIB) -DUSE_MMAP \
+ CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_CFLAGS_WARNINGS_ARE_ERRORS) -DUSE_MMAP \
-I$(INCLUDEDIR) -I$(JDK_OUTPUTDIR)/include/$(OPENJDK_TARGET_OS) \
-I$(JDK_TOPDIR)/src/share/transport/socket \
-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/socket \
@@ -115,7 +115,7 @@
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/shmem, \
LANG := C, \
OPTIMIZATION := LOW, \
- CFLAGS := $(CFLAGS_JDKLIB) -DUSE_MMAP \
+ CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) -DUSE_MMAP \
-I$(INCLUDEDIR) -I$(JDK_OUTPUTDIR)/include/$(OPENJDK_TARGET_OS) \
-I$(JDK_TOPDIR)/src/share/transport/shmem \
-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/shmem \
@@ -144,7 +144,7 @@
SRC := $(JDK_TOPDIR)/src/share/back $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/back, \
LANG := C, \
OPTIMIZATION := LOW, \
- CFLAGS := $(CFLAGS_JDKLIB) -DJDWP_LOGGING \
+ CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) -DJDWP_LOGGING \
-I$(JDK_TOPDIR)/src/share/transport/export \
-I$(JDK_TOPDIR)/src/share/back/export \
-I$(JDK_TOPDIR)/src/share/npt \
@@ -179,7 +179,7 @@
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/tracing/dtrace, \
LANG := C, \
OPTIMIZATION := LOW, \
- CFLAGS := $(CFLAGS_JDKLIB) \
+ CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \
-I$(JDK_TOPDIR)/src/share/native/sun/tracing/dtrace, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjsdt/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
@@ -248,7 +248,7 @@
INCLUDE_FILES := $(LIBINSTRUMENT_FILES), \
LANG := C, \
OPTIMIZATION := LOW, \
- CFLAGS := $(LIBINSTRUMENT_CFLAGS), \
+ CFLAGS := $(LIBINSTRUMENT_CFLAGS) $(CFLAGS_WARNINGS_ARE_ERRORS), \
CFLAGS_debug := -DJPLIS_LOGGING, \
CFLAGS_release := -DNO_JPLIS_LOGGING, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libinstrument/mapfile-vers, \
@@ -316,7 +316,7 @@
EXCLUDE_FILES := $(BUILD_LIBMANAGEMENT_EXCLUDES), \
LANG := C, \
OPTIMIZATION := $(LIBMANAGEMENT_OPTIMIZATION), \
- CFLAGS := $(CFLAGS_JDKLIB) $(BUILD_LIBMANAGEMENT_CFLAGS), \
+ CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) $(BUILD_LIBMANAGEMENT_CFLAGS), \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libmanagement/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
@@ -364,7 +364,7 @@
SRC := $(BUILD_LIBHPROF_SRC), \
LANG := C, \
OPTIMIZATION := $(LIBHPROF_OPTIMIZATION), \
- CFLAGS := $(CFLAGS_JDKLIB) \
+ CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \
$(BUILD_LIBHPROF_CFLAGS), \
CFLAGS_debug := -DHPROF_LOGGING, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libhprof/mapfile-vers, \
@@ -392,7 +392,7 @@
SRC := $(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo, \
LANG := C, \
OPTIMIZATION := LOW, \
- CFLAGS := $(CFLAGS_JDKLIB) \
+ CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \
-I$(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjava_crw_demo/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
@@ -419,7 +419,7 @@
SRC := $(JDK_TOPDIR)/src/closed/share/native/oracle/jfr, \
LANG := C, \
OPTIMIZATION := LOW, \
- CFLAGS := $(CFLAGS_JDKLIB) \
+ CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \
-I$(JDK_TOPDIR)/src/closed/share/javavm/export, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjfr/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
--- a/jdk/src/share/back/SDE.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/share/back/SDE.c Tue Mar 25 14:51:01 2014 -0700
@@ -48,8 +48,6 @@
#define BASE_STRATUM_NAME "Java"
#define null NULL
-#define true JNI_TRUE
-#define false JNI_FALSE
#define String char *
#define private static
@@ -147,7 +145,7 @@
defaultStratumId = null;
defaultStratumIndex = -1;
baseStratumIndex = -2; /* so as not to match -1 above */
- sourceMapIsValid = false;
+ sourceMapIsValid = JNI_FALSE;
if (getSourceDebugExtension(clazz, &sourceDebugExtension) ==
JVMTI_ERROR_NONE) {
@@ -667,7 +665,7 @@
jplsFilename = readLine();
defaultStratumId = readLine();
createJavaStratum();
- while (true) {
+ while (1) {
if (sdeRead() != '*') {
syntax("expected '*'");
}
@@ -684,7 +682,7 @@
case 'E':
/* set end points */
storeStratum("*terminator*");
- sourceMapIsValid = true;
+ sourceMapIsValid = JNI_TRUE;
return;
default:
ignoreSection();
--- a/jdk/src/share/back/eventFilter.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/share/back/eventFilter.c Tue Mar 25 14:51:01 2014 -0700
@@ -288,7 +288,7 @@
>> JVMTI_VERSION_SHIFT_MAJOR;
minor = (version & JVMTI_VERSION_MASK_MINOR)
>> JVMTI_VERSION_SHIFT_MINOR;
- return (major > 1 || major == 1 && minor >= 2);
+ return (major > 1 || (major == 1 && minor >= 2)) ? JNI_TRUE : JNI_FALSE;
} else {
return JNI_FALSE;
}
--- a/jdk/src/share/back/eventHandler.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/share/back/eventHandler.c Tue Mar 25 14:51:01 2014 -0700
@@ -1682,7 +1682,7 @@
eventHandler_createPermanentInternal(EventIndex ei, HandlerFunction func)
{
return createInternal(ei, func, NULL,
- NULL, NULL, (jlocation)NULL, JNI_TRUE);
+ NULL, NULL, 0, JNI_TRUE);
}
HandlerNode *
@@ -1691,7 +1691,7 @@
jthread thread)
{
return createInternal(ei, func, thread,
- NULL, NULL, (jlocation)NULL, JNI_FALSE);
+ NULL, NULL, 0, JNI_FALSE);
}
HandlerNode *
--- a/jdk/src/share/back/log_messages.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/share/back/log_messages.c Tue Mar 25 14:51:01 2014 -0700
@@ -56,17 +56,24 @@
static void
get_time_stamp(char *tbuf, size_t ltbuf)
{
- char format[MAXLEN_TIMESTAMP+1];
+ char timestamp_prefix[MAXLEN_TIMESTAMP+1];
+ char timestamp_postfix[MAXLEN_TIMESTAMP+1];
unsigned millisecs = 0;
time_t t = 0;
GETMILLSECS(millisecs);
- if ( time(&t) == (time_t)(-1) )
+ if ( time(&t) == (time_t)(-1) ) {
t = 0;
- (void)strftime(format, sizeof(format),
- /* Break this string up for SCCS's sake */
- "%" "d.%" "m.%" "Y %" "T.%%.3d %" "Z", localtime(&t));
- (void)snprintf(tbuf, ltbuf, format, (int)(millisecs));
+ }
+ /* Break this up so that the format strings are string literals
+ and we avoid a compiler warning. */
+ (void)strftime(timestamp_prefix, sizeof(timestamp_prefix),
+ "%d.%m.%Y %T", localtime(&t));
+ (void)strftime(timestamp_postfix, sizeof(timestamp_postfix),
+ "%Z", localtime(&t));
+ (void)snprintf(tbuf, ltbuf,
+ "%s.%.3d %s", timestamp_prefix,
+ (int)(millisecs), timestamp_postfix);
}
/* Get basename of filename */
@@ -175,7 +182,7 @@
"LOC=%s;PID=%d;THR=t@%d",
location_stamp,
(int)processPid,
- (int)tid);
+ (int)(intptr_t)tid);
/* Construct message string. */
va_start(ap, format);
--- a/jdk/src/share/classes/java/time/format/DateTimeFormatter.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/share/classes/java/time/format/DateTimeFormatter.java Tue Mar 25 14:51:01 2014 -0700
@@ -1932,8 +1932,8 @@
*/
private TemporalAccessor parseResolved0(final CharSequence text, final ParsePosition position) {
ParsePosition pos = (position != null ? position : new ParsePosition(0));
- Parsed unresolved = parseUnresolved0(text, pos);
- if (unresolved == null || pos.getErrorIndex() >= 0 || (position == null && pos.getIndex() < text.length())) {
+ DateTimeParseContext context = parseUnresolved0(text, pos);
+ if (context == null || pos.getErrorIndex() >= 0 || (position == null && pos.getIndex() < text.length())) {
String abbr;
if (text.length() > 64) {
abbr = text.subSequence(0, 64).toString() + "...";
@@ -1948,7 +1948,7 @@
pos.getIndex(), text, pos.getIndex());
}
}
- return unresolved.resolve(resolverStyle, resolverFields);
+ return context.toResolved(resolverStyle, resolverFields);
}
/**
@@ -1991,10 +1991,14 @@
* @throws IndexOutOfBoundsException if the position is invalid
*/
public TemporalAccessor parseUnresolved(CharSequence text, ParsePosition position) {
- return parseUnresolved0(text, position);
+ DateTimeParseContext context = parseUnresolved0(text, position);
+ if (context == null) {
+ return null;
+ }
+ return context.toUnresolved();
}
- private Parsed parseUnresolved0(CharSequence text, ParsePosition position) {
+ private DateTimeParseContext parseUnresolved0(CharSequence text, ParsePosition position) {
Objects.requireNonNull(text, "text");
Objects.requireNonNull(position, "position");
DateTimeParseContext context = new DateTimeParseContext(this);
@@ -2005,7 +2009,7 @@
return null;
}
position.setIndex(pos); // errorIndex not updated from input
- return context.toParsed();
+ return context;
}
//-----------------------------------------------------------------------
@@ -2126,23 +2130,23 @@
@Override
public Object parseObject(String text, ParsePosition pos) {
Objects.requireNonNull(text, "text");
- Parsed unresolved;
+ DateTimeParseContext context;
try {
- unresolved = formatter.parseUnresolved0(text, pos);
+ context = formatter.parseUnresolved0(text, pos);
} catch (IndexOutOfBoundsException ex) {
if (pos.getErrorIndex() < 0) {
pos.setErrorIndex(0);
}
return null;
}
- if (unresolved == null) {
+ if (context == null) {
if (pos.getErrorIndex() < 0) {
pos.setErrorIndex(0);
}
return null;
}
try {
- TemporalAccessor resolved = unresolved.resolve(formatter.resolverStyle, formatter.resolverFields);
+ TemporalAccessor resolved = context.toResolved(formatter.resolverStyle, formatter.resolverFields);
if (parseType == null) {
return resolved;
}
--- a/jdk/src/share/classes/java/time/format/DateTimeParseContext.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/share/classes/java/time/format/DateTimeParseContext.java Tue Mar 25 14:51:01 2014 -0700
@@ -64,10 +64,12 @@
import java.time.ZoneId;
import java.time.chrono.Chronology;
import java.time.chrono.IsoChronology;
+import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalField;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Objects;
+import java.util.Set;
import java.util.function.Consumer;
/**
@@ -77,8 +79,8 @@
* It has the ability to store and retrieve the parsed values and manage optional segments.
* It also provides key information to the parsing methods.
* <p>
- * Once parsing is complete, the {@link #toParsed()} is used to obtain the data.
- * It contains a method to resolve the separate parsed fields into meaningful values.
+ * Once parsing is complete, the {@link #toUnresolved()} is used to obtain the unresolved
+ * result data. The {@link #toResolved()} is used to obtain the resolved result.
*
* @implSpec
* This class is a mutable context intended for use from a single thread.
@@ -309,16 +311,27 @@
}
/**
- * Gets the result of the parse.
+ * Gets the unresolved result of the parse.
*
* @return the result of the parse, not null
*/
- Parsed toParsed() {
+ Parsed toUnresolved() {
+ return currentParsed();
+ }
+
+ /**
+ * Gets the resolved result of the parse.
+ *
+ * @return the result of the parse, not null
+ */
+ TemporalAccessor toResolved(ResolverStyle resolverStyle, Set<TemporalField> resolverFields) {
Parsed parsed = currentParsed();
- parsed.effectiveChrono = getEffectiveChronology();
- return parsed;
+ parsed.chrono = getEffectiveChronology();
+ parsed.zone = (parsed.zone != null ? parsed.zone : formatter.getZone());
+ return parsed.resolve(resolverStyle, resolverFields);
}
+
//-----------------------------------------------------------------------
/**
* Gets the first value that was parsed for the specified field.
--- a/jdk/src/share/classes/java/time/format/Parsed.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/share/classes/java/time/format/Parsed.java Tue Mar 25 14:51:01 2014 -0700
@@ -136,10 +136,6 @@
*/
boolean leapSecond;
/**
- * The effective chronology.
- */
- Chronology effectiveChrono;
- /**
* The resolver style to use.
*/
private ResolverStyle resolverStyle;
@@ -241,7 +237,6 @@
fieldValues.keySet().retainAll(resolverFields);
}
this.resolverStyle = resolverStyle;
- chrono = effectiveChrono;
resolveFields();
resolveTimeLenient();
crossCheck();
@@ -266,14 +261,16 @@
TemporalAccessor resolvedObject = targetField.resolve(fieldValues, this, resolverStyle);
if (resolvedObject != null) {
if (resolvedObject instanceof ChronoZonedDateTime) {
- ChronoZonedDateTime<?> czdt = (ChronoZonedDateTime) resolvedObject;
- if (zone.equals(czdt.getZone()) == false) {
+ ChronoZonedDateTime<?> czdt = (ChronoZonedDateTime<?>) resolvedObject;
+ if (zone == null) {
+ zone = czdt.getZone();
+ } else if (zone.equals(czdt.getZone()) == false) {
throw new DateTimeException("ChronoZonedDateTime must use the effective parsed zone: " + zone);
}
resolvedObject = czdt.toLocalDateTime();
}
if (resolvedObject instanceof ChronoLocalDateTime) {
- ChronoLocalDateTime<?> cldt = (ChronoLocalDateTime) resolvedObject;
+ ChronoLocalDateTime<?> cldt = (ChronoLocalDateTime<?>) resolvedObject;
updateCheckConflict(cldt.toLocalTime(), Period.ZERO);
updateCheckConflict(cldt.toLocalDate());
changedCount++;
--- a/jdk/src/share/classes/java/util/Spliterators.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/share/classes/java/util/Spliterators.java Tue Mar 25 14:51:01 2014 -0700
@@ -384,7 +384,7 @@
*/
private static void checkFromToBounds(int arrayLength, int origin, int fence) {
if (origin > fence) {
- throw new IllegalArgumentException(
+ throw new ArrayIndexOutOfBoundsException(
"origin(" + origin + ") > fence(" + fence + ")");
}
if (origin < 0) {
--- a/jdk/src/share/classes/javax/sql/rowset/package.html Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/share/classes/javax/sql/rowset/package.html Tue Mar 25 14:51:01 2014 -0700
@@ -295,14 +295,13 @@
<h3><a name="relspec">4.0 Related Specifications</a></h3>
<ul>
-<li><a href="http://java.sun.com/products/jdbc">JDBC 3.0 Specification</a>
+<li><a href="https://jcp.org/en/jsr/detail?id=221">JDBC 4.2 Specification</a>
<li><a href="http://www.w3.org/XML/Schema">XML Schema</a>
-<li><a href="http://www.syncml.org">SyncML</a>
</ul>
<h3><a name="reldocs">5.0 Related Documentation</a></h3>
<ul>
-<li><a href="http://java.sun.com/developer/Books/JDBCTutorial/chapter5.html">
+<li><a href="http://docs.oracle.com/javase/tutorial/jdbc/basics/rowset.html">
JDBC RowSet Tutorial</a>
</ul>
</body>
--- a/jdk/src/share/classes/sun/security/pkcs11/SessionManager.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/share/classes/sun/security/pkcs11/SessionManager.java Tue Mar 25 14:51:01 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -34,6 +34,9 @@
import sun.security.pkcs11.wrapper.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
+import java.util.concurrent.ConcurrentLinkedDeque;
+import java.util.concurrent.atomic.AtomicInteger;
+
/**
* Session manager. There is one session manager object per PKCS#11
* provider. It allows code to checkout a session, release it
@@ -77,7 +80,7 @@
private final int maxSessions;
// total number of active sessions
- private int activeSessions;
+ private AtomicInteger activeSessions = new AtomicInteger();
// pool of available object sessions
private final Pool objSessions;
@@ -118,7 +121,7 @@
return (maxSessions <= DEFAULT_MAX_SESSIONS);
}
- synchronized Session getObjSession() throws PKCS11Exception {
+ Session getObjSession() throws PKCS11Exception {
Session session = objSessions.poll();
if (session != null) {
return ensureValid(session);
@@ -131,7 +134,7 @@
return ensureValid(session);
}
- synchronized Session getOpSession() throws PKCS11Exception {
+ Session getOpSession() throws PKCS11Exception {
Session session = opSessions.poll();
if (session != null) {
return ensureValid(session);
@@ -139,7 +142,7 @@
// create a new session rather than re-using an obj session
// that avoids potential expensive cancels() for Signatures & RSACipher
if (maxSessions == Integer.MAX_VALUE ||
- activeSessions < maxSessions) {
+ activeSessions.get() < maxSessions) {
session = openSession();
return ensureValid(session);
}
@@ -155,20 +158,20 @@
return session;
}
- synchronized Session killSession(Session session) {
+ Session killSession(Session session) {
if ((session == null) || (token.isValid() == false)) {
return null;
}
if (debug != null) {
String location = new Exception().getStackTrace()[2].toString();
System.out.println("Killing session (" + location + ") active: "
- + activeSessions);
+ + activeSessions.get());
}
closeSession(session);
return null;
}
- synchronized Session releaseSession(Session session) {
+ Session releaseSession(Session session) {
if ((session == null) || (token.isValid() == false)) {
return null;
}
@@ -181,13 +184,13 @@
return null;
}
- synchronized void demoteObjSession(Session session) {
+ void demoteObjSession(Session session) {
if (token.isValid() == false) {
return;
}
if (debug != null) {
System.out.println("Demoting session, active: " +
- activeSessions);
+ activeSessions.get());
}
boolean present = objSessions.remove(session);
if (present == false) {
@@ -200,18 +203,21 @@
private Session openSession() throws PKCS11Exception {
if ((maxSessions != Integer.MAX_VALUE) &&
- (activeSessions >= maxSessions)) {
+ (activeSessions.get() >= maxSessions)) {
throw new ProviderException("No more sessions available");
}
+
long id = token.p11.C_OpenSession
(token.provider.slotID, openSessionFlags, null, null);
Session session = new Session(token, id);
- activeSessions++;
+ activeSessions.incrementAndGet();
if (debug != null) {
- if (activeSessions > maxActiveSessions) {
- maxActiveSessions = activeSessions;
- if (maxActiveSessions % 10 == 0) {
- System.out.println("Open sessions: " + maxActiveSessions);
+ synchronized(this) {
+ if (activeSessions.get() > maxActiveSessions) {
+ maxActiveSessions = activeSessions.get();
+ if (maxActiveSessions % 10 == 0) {
+ System.out.println("Open sessions: " + maxActiveSessions);
+ }
}
}
}
@@ -220,18 +226,18 @@
private void closeSession(Session session) {
session.close();
- activeSessions--;
+ activeSessions.decrementAndGet();
}
- private static final class Pool {
+ public static final class Pool {
private final SessionManager mgr;
- private final List<Session> pool;
+ private final ConcurrentLinkedDeque<Session> pool;
Pool(SessionManager mgr) {
- this.mgr = mgr;
- pool = new ArrayList<Session>();
+ this.mgr = mgr;
+ pool = new ConcurrentLinkedDeque<Session>();
}
boolean remove(Session session) {
@@ -239,45 +245,40 @@
}
Session poll() {
- int n = pool.size();
- if (n == 0) {
- return null;
- }
- Session session = pool.remove(n - 1);
- return session;
+ return pool.pollLast();
}
void release(Session session) {
- pool.add(session);
- // if there are idle sessions, close them
+ pool.offer(session);
if (session.hasObjects()) {
return;
}
+
int n = pool.size();
if (n < 5) {
return;
}
- Session oldestSession = pool.get(0);
+
+ Session oldestSession;
long time = System.currentTimeMillis();
- if (session.isLive(time) && oldestSession.isLive(time)) {
- return;
- }
- Collections.sort(pool);
int i = 0;
- while (i < n - 1) { // always keep at least 1 session open
- oldestSession = pool.get(i);
- if (oldestSession.isLive(time)) {
+ // Check if the session head is too old and continue through queue
+ // until only one is left.
+ do {
+ oldestSession = pool.peek();
+ if (oldestSession == null || oldestSession.isLive(time) ||
+ !pool.remove(oldestSession)) {
break;
}
+
i++;
mgr.closeSession(oldestSession);
- }
+ } while ((n - i) > 1);
+
if (debug != null) {
System.out.println("Closing " + i + " idle sessions, active: "
+ mgr.activeSessions);
}
- List<Session> subList = pool.subList(0, i);
- subList.clear();
}
}
--- a/jdk/src/share/classes/sun/tools/jinfo/JInfo.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/share/classes/sun/tools/jinfo/JInfo.java Tue Mar 25 14:51:01 2014 -0700
@@ -78,8 +78,16 @@
}
if (useSA) {
+ // SA only supports -flags or -sysprops
+ if (args[0].startsWith("-")) {
+ if (!(args[0].equals("-flags") || args[0].equals("-sysprops"))) {
+ usage(1);
+ }
+ }
+
// invoke SA which does it's own argument parsing
runTool(args);
+
} else {
// Now we can parse arguments for the non-SA case
String pid = null;
--- a/jdk/src/share/instrument/InvocationAdapter.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/share/instrument/InvocationAdapter.c Tue Mar 25 14:51:01 2014 -0700
@@ -359,7 +359,7 @@
* class name. The manifest is in UTF8 so need to convert to
* modified UTF8 (see JNI spec).
*/
- oldLen = strlen(agentClass);
+ oldLen = (int)strlen(agentClass);
newLen = modifiedUtf8LengthOfUtf8(agentClass, oldLen);
if (newLen == oldLen) {
agentClass = strdup(agentClass);
--- a/jdk/src/share/instrument/PathCharsValidator.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/share/instrument/PathCharsValidator.c Tue Mar 25 14:51:01 2014 -0700
@@ -46,9 +46,9 @@
/* Compute the low-order mask for the characters in the given string */
static jlong lowMask(char* s) {
- int n = strlen(s);
+ size_t n = strlen(s);
jlong m = 0;
- int i;
+ size_t i;
for (i = 0; i < n; i++) {
int c = (int)s[i];
if (c < 64)
@@ -59,9 +59,9 @@
/* Compute the high-order mask for the characters in the given string */
static jlong highMask(char* s) {
- int n = strlen(s);
+ size_t n = strlen(s);
jlong m = 0;
- int i;
+ size_t i;
for (i = 0; i < n; i++) {
int c = (int)s[i];
if ((c >= 64) && (c < 128))
@@ -168,7 +168,7 @@
* illegal characters. Returns 0 if only validate characters are present.
*/
int validatePathChars(const char* path) {
- int i, n;
+ size_t i, n;
/* initialize on first usage */
if (L_HEX == 0) {
--- a/jdk/src/solaris/back/util_md.h Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/solaris/back/util_md.h Tue Mar 25 14:51:01 2014 -0700
@@ -62,13 +62,13 @@
(((UNSIGNED_JINT)(x & 0xff000000)) >> 24))
#define HOST_TO_JAVA_LONG(x) \
((x << 56) | \
- ((x & 0x000000000000ff00) << 40) | \
- ((x & 0x0000000000ff0000) << 24) | \
- ((x & 0x00000000ff000000) << 8) | \
- ((x & 0x000000ff00000000) >> 8) | \
- ((x & 0x0000ff0000000000) >> 24) | \
- ((x & 0x00ff000000000000) >> 40) | \
- (((UNSIGNED_JLONG)(x & 0xff00000000000000)) >> 56))
+ ((x & 0x000000000000ff00LL) << 40) | \
+ ((x & 0x0000000000ff0000LL) << 24) | \
+ ((x & 0x00000000ff000000LL) << 8) | \
+ ((x & 0x000000ff00000000LL) >> 8) | \
+ ((x & 0x0000ff0000000000LL) >> 24) | \
+ ((x & 0x00ff000000000000LL) >> 40) | \
+ (((UNSIGNED_JLONG)(x & 0xff00000000000000ULL)) >> 56))
#define HOST_TO_JAVA_FLOAT(x) stream_encodeFloat(x)
#define HOST_TO_JAVA_DOUBLE(x) stream_encodeDouble(x)
--- a/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java Tue Mar 25 14:51:01 2014 -0700
@@ -482,7 +482,7 @@
@Override
public Path normalize() {
final int count = getNameCount();
- if (count == 0)
+ if (count == 0 || isEmpty())
return this;
boolean[] ignore = new boolean[count]; // true => ignore name
--- a/jdk/src/solaris/native/java/net/NetworkInterface.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/solaris/native/java/net/NetworkInterface.c Tue Mar 25 14:51:01 2014 -0700
@@ -231,7 +231,11 @@
}
name_utf = (*env)->GetStringUTFChars(env, name, &isCopy);
-
+ if (name_utf == NULL) {
+ if (!(*env)->ExceptionCheck(env))
+ JNU_ThrowOutOfMemoryError(env, NULL);
+ return NULL;
+ }
/*
* Search the list of interface based on name
*/
@@ -499,7 +503,11 @@
const char* name_utf;
name_utf = (*env)->GetStringUTFChars(env, name, &isCopy);
-
+ if (name_utf == NULL) {
+ if (!(*env)->ExceptionCheck(env))
+ JNU_ThrowOutOfMemoryError(env, NULL);
+ return NULL;
+ }
if ((sock =openSocketWithFallback(env, name_utf)) < 0) {
(*env)->ReleaseStringUTFChars(env, name, name_utf);
return JNI_FALSE;
@@ -546,6 +554,11 @@
const char* name_utf;
name_utf = (*env)->GetStringUTFChars(env, name, &isCopy);
+ if (name_utf == NULL) {
+ if (!(*env)->ExceptionCheck(env))
+ JNU_ThrowOutOfMemoryError(env, NULL);
+ return ret;
+ }
if ((sock =openSocketWithFallback(env, name_utf)) < 0) {
(*env)->ReleaseStringUTFChars(env, name, name_utf);
@@ -569,7 +582,11 @@
int flags = 0;
name_utf = (*env)->GetStringUTFChars(env, name, &isCopy);
-
+ if (name_utf == NULL) {
+ if (!(*env)->ExceptionCheck(env))
+ JNU_ThrowOutOfMemoryError(env, NULL);
+ return -1;
+ }
if ((sock = openSocketWithFallback(env, name_utf)) < 0) {
(*env)->ReleaseStringUTFChars(env, name, name_utf);
return -1;
@@ -613,10 +630,9 @@
* Create a NetworkInterface object and populate it
*/
netifObj = (*env)->NewObject(env, ni_class, ni_ctrID);
+ CHECK_NULL_RETURN(netifObj, NULL);
name = (*env)->NewStringUTF(env, ifs->name);
- if (netifObj == NULL || name == NULL) {
- return NULL;
- }
+ CHECK_NULL_RETURN(name, NULL);
(*env)->SetObjectField(env, netifObj, ni_nameID, name);
(*env)->SetObjectField(env, netifObj, ni_descID, name);
(*env)->SetIntField(env, netifObj, ni_indexID, ifs->index);
@@ -655,6 +671,8 @@
iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
if (iaObj) {
setInetAddress_addr(env, iaObj, htonl(((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr));
+ } else {
+ return NULL;
}
ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
if (ibObj) {
@@ -665,10 +683,14 @@
if (ia2Obj) {
setInetAddress_addr(env, ia2Obj, htonl(((struct sockaddr_in*)addrP->brdcast)->sin_addr.s_addr));
(*env)->SetObjectField(env, ibObj, ni_ib4broadcastID, ia2Obj);
+ } else {
+ return NULL;
}
}
(*env)->SetShortField(env, ibObj, ni_ib4maskID, addrP->mask);
(*env)->SetObjectArrayElement(env, bindArr, bind_index++, ibObj);
+ } else {
+ return NULL;
}
}
@@ -688,20 +710,20 @@
setInet6Address_scopeid(env, iaObj, scope);
setInet6Address_scopeifname(env, iaObj, netifObj);
}
+ } else {
+ return NULL;
}
ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
if (ibObj) {
(*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj);
(*env)->SetShortField(env, ibObj, ni_ib4maskID, addrP->mask);
(*env)->SetObjectArrayElement(env, bindArr, bind_index++, ibObj);
+ } else {
+ return NULL;
}
}
#endif
- if (iaObj == NULL) {
- return NULL;
- }
-
(*env)->SetObjectArrayElement(env, addrArr, addr_index++, iaObj);
addrP = addrP->next;
}
@@ -893,9 +915,14 @@
// Deal with broadcast addr & subnet mask
struct sockaddr * brdcast_to = (struct sockaddr *) ((char *) addrP + sizeof(netaddr) + addr_size);
addrP->brdcast = getBroadcast(env, sock, name, brdcast_to );
-
- if ((mask = getSubnet(env, sock, name)) != -1)
+ if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
+ return ifs;
+ }
+ if ((mask = getSubnet(env, sock, name)) != -1) {
addrP->mask = mask;
+ } else if((*env)->ExceptionCheck(env)) {
+ return ifs;
+ }
}
/**
@@ -1377,6 +1404,7 @@
nddp = (struct kinfo_ndd *)malloc(size);
if (!nddp) {
+ JNU_ThrowOutOfMemoryError(env, "Network interface getMacAddress native buffer allocation failed");
return -1;
}
--- a/jdk/src/solaris/native/sun/management/MacosxOperatingSystem.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/solaris/native/sun/management/MacosxOperatingSystem.c Tue Mar 25 14:51:01 2014 -0700
@@ -29,6 +29,7 @@
#include <mach/mach.h>
#include <mach/task_info.h>
+#include "jvm.h"
JNIEXPORT jdouble JNICALL
Java_sun_management_OperatingSystemImpl_getSystemCpuLoad0
--- a/jdk/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c Tue Mar 25 14:51:01 2014 -0700
@@ -38,8 +38,7 @@
#include "sun_nio_ch_sctp_ResultContainer.h"
#include "sun_nio_ch_sctp_PeerAddrChange.h"
-/* sizeof(union sctp_notification */
-#define NOTIFICATION_BUFFER_SIZE 280
+static int SCTP_NOTIFICATION_SIZE = sizeof(union sctp_notification);
#define MESSAGE_IMPL_CLASS "sun/nio/ch/sctp/MessageInfoImpl"
#define RESULT_CONTAINER_CLASS "sun/nio/ch/sctp/ResultContainer"
@@ -463,20 +462,47 @@
if (msg->msg_flags & MSG_NOTIFICATION) {
char *bufp = (char*)addr;
union sctp_notification *snp;
+ jboolean allocated = JNI_FALSE;
- if (!(msg->msg_flags & MSG_EOR) && length < NOTIFICATION_BUFFER_SIZE) {
- char buf[NOTIFICATION_BUFFER_SIZE];
+ if (rv > SCTP_NOTIFICATION_SIZE) {
+ JNU_ThrowInternalError(env, "should not reach here");
+ return -1;
+ }
+
+ if (!(msg->msg_flags & MSG_EOR) && length < SCTP_NOTIFICATION_SIZE) {
+ char* newBuf;
int rvSAVE = rv;
- memcpy(buf, addr, rv);
- iov->iov_base = buf + rv;
- iov->iov_len = NOTIFICATION_BUFFER_SIZE - rv;
+
+ if ((newBuf = malloc(SCTP_NOTIFICATION_SIZE)) == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "Out of native heap space.");
+ return -1;
+ }
+ allocated = JNI_TRUE;
+
+ memcpy(newBuf, addr, rv);
+ iov->iov_base = newBuf + rv;
+ iov->iov_len = SCTP_NOTIFICATION_SIZE - rv;
if ((rv = recvmsg(fd, msg, flags)) < 0) {
handleSocketError(env, errno);
return 0;
}
- bufp = buf;
+ bufp = newBuf;
rv += rvSAVE;
}
+#ifdef __sparc
+ else if ((intptr_t)addr & 0x3) {
+ /* the given buffer is not 4 byte aligned */
+ char* newBuf;
+ if ((newBuf = malloc(SCTP_NOTIFICATION_SIZE)) == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "Out of native heap space.");
+ return -1;
+ }
+ allocated = JNI_TRUE;
+
+ memcpy(newBuf, addr, rv);
+ bufp = newBuf;
+ }
+#endif
snp = (union sctp_notification *) bufp;
if (handleNotification(env, fd, resultContainerObj, snp, rv,
(msg->msg_flags & MSG_EOR),
@@ -484,9 +510,16 @@
/* We have received a notification that is of interest to
to the Java API. The appropriate notification will be
set in the result container. */
+ if (allocated == JNI_TRUE) {
+ free(bufp);
+ }
return 0;
}
+ if (allocated == JNI_TRUE) {
+ free(bufp);
+ }
+
// set iov back to addr, and reset msg_controllen
iov->iov_base = addr;
iov->iov_len = length;
--- a/jdk/src/windows/back/linker_md.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/windows/back/linker_md.c Tue Mar 25 14:51:01 2014 -0700
@@ -33,6 +33,7 @@
#include <string.h>
#include <errno.h>
#include <io.h>
+#include <stdlib.h>
#include "sys.h"
--- a/jdk/src/windows/back/proc_md.h Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/windows/back/proc_md.h Tue Mar 25 14:51:01 2014 -0700
@@ -27,6 +27,7 @@
#include <process.h>
#include <time.h>
+#include <Windows.h>
#define MUTEX_T int
#define MUTEX_INIT 0
@@ -40,4 +41,4 @@
#define popen _popen
#define pclose _pclose
-#define sleep _sleep
+#define sleep(s) Sleep((s)*1000)
--- a/jdk/src/windows/native/java/io/WinNTFileSystem_md.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/windows/native/java/io/WinNTFileSystem_md.c Tue Mar 25 14:51:01 2014 -0700
@@ -85,7 +85,7 @@
* Retrieves the fully resolved (final) path for the given path or NULL
* if the function fails.
*/
-static WCHAR* getFinalPath(const WCHAR *path)
+static WCHAR* getFinalPath(JNIEnv *env, const WCHAR *path)
{
HANDLE h;
WCHAR *result;
@@ -121,6 +121,7 @@
len = (*GetFinalPathNameByHandle_func)(h, result, len, 0);
} else {
len = 0;
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
}
}
@@ -141,6 +142,7 @@
/* copy result without prefix into new buffer */
WCHAR *tmp = (WCHAR*)malloc(resultLen * sizeof(WCHAR));
if (tmp == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
len = 0;
} else {
WCHAR *p = result;
@@ -164,6 +166,8 @@
free(result);
result = NULL;
}
+ } else {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
}
error = GetLastError();
@@ -257,6 +261,8 @@
rv = (*env)->NewString(env, cp, (jsize)wcslen(cp));
}
free(cp);
+ } else {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
}
} else if (wcanonicalize(path, canonicalPath, MAX_PATH_LENGTH) >= 0) {
rv = (*env)->NewString(env, canonicalPath, (jsize)wcslen(canonicalPath));
@@ -288,6 +294,8 @@
rv = (*env)->NewString(env, cp, (jsize)wcslen(cp));
}
free(cp);
+ } else {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
}
} else if (wcanonicalizeWithPrefix(canonicalPrefix,
pathWithCanonicalPrefix,
@@ -433,7 +441,7 @@
if ((a != INVALID_FILE_ATTRIBUTES) &&
((a & FILE_ATTRIBUTE_REPARSE_POINT) != 0))
{
- WCHAR *fp = getFinalPath(pathbuf);
+ WCHAR *fp = getFinalPath(env, pathbuf);
if (fp == NULL) {
a = INVALID_FILE_ATTRIBUTES;
} else {
@@ -628,6 +636,7 @@
if (search_path == 0) {
free (pathbuf);
errno = ENOMEM;
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation faiuled");
return NULL;
}
wcscpy(search_path, pathbuf);
@@ -803,7 +812,7 @@
if ((a != INVALID_FILE_ATTRIBUTES) &&
((a & FILE_ATTRIBUTE_REPARSE_POINT) != 0))
{
- WCHAR *fp = getFinalPath(pathbuf);
+ WCHAR *fp = getFinalPath(env, pathbuf);
if (fp == NULL) {
a = INVALID_FILE_ATTRIBUTES;
} else {
--- a/jdk/src/windows/native/java/io/io_util_md.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/windows/native/java/io/io_util_md.c Tue Mar 25 14:51:01 2014 -0700
@@ -165,6 +165,9 @@
pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR));
if (pathbuf != 0) {
wcscpy(pathbuf, ps);
+ } else {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+ return NULL;
}
}
} else {
@@ -188,6 +191,9 @@
pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR));
if (pathbuf != 0) {
wcscpy(pathbuf, ps);
+ } else {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+ return NULL;
}
}
}
@@ -196,11 +202,18 @@
if (pathlen == 0) {
if (throwFNFE == JNI_TRUE) {
- throwFileNotFoundException(env, path);
+ if (!(*env)->ExceptionCheck(env)) {
+ throwFileNotFoundException(env, path);
+ }
return NULL;
} else {
pathbuf = (WCHAR*)malloc(sizeof(WCHAR));
- pathbuf[0] = L'\0';
+ if (pathbuf != NULL) {
+ pathbuf[0] = L'\0';
+ } else {
+ JNU_ThrowOutOfMemoryError(env, 0);
+ return NULL;
+ }
}
}
if (pathbuf == 0) {
--- a/jdk/src/windows/native/java/lang/ProcessEnvironment_md.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/windows/native/java/lang/ProcessEnvironment_md.c Tue Mar 25 14:51:01 2014 -0700
@@ -35,9 +35,13 @@
jmethodID String_init_ID;
jbyteArray bytes;
jbyte *blockA;
+ jclass string_class;
+
+ string_class = JNU_ClassString(env);
+ CHECK_NULL_RETURN(string_class, NULL);
String_init_ID =
- (*env)->GetMethodID(env, JNU_ClassString(env), "<init>", "([B)V");
+ (*env)->GetMethodID(env, string_class, "<init>", "([B)V");
CHECK_NULL_RETURN(String_init_ID, NULL);
blockA = (jbyte *) GetEnvironmentStringsA();
@@ -54,10 +58,13 @@
while (blockA[i++])
;
- if ((bytes = (*env)->NewByteArray(env, i)) == NULL) return NULL;
+ if ((bytes = (*env)->NewByteArray(env, i)) == NULL) {
+ FreeEnvironmentStringsA(blockA);
+ return NULL;
+ }
(*env)->SetByteArrayRegion(env, bytes, 0, i, blockA);
FreeEnvironmentStringsA(blockA);
- return (*env)->NewObject(env, JNU_ClassString(env),
+ return (*env)->NewObject(env, string_class,
String_init_ID, bytes);
}
--- a/jdk/src/windows/native/java/lang/ProcessImpl_md.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/windows/native/java/lang/ProcessImpl_md.c Tue Mar 25 14:51:01 2014 -0700
@@ -359,24 +359,28 @@
const jchar *penvBlock = (envBlock != NULL)
? (*env)->GetStringChars(env, envBlock, NULL)
: NULL;
- const jchar *pdir = (dir != NULL)
- ? (*env)->GetStringChars(env, dir, NULL)
- : NULL;
- jlong *handles = (*env)->GetLongArrayElements(env, stdHandles, NULL);
- if (handles != NULL) {
- ret = processCreate(
- env,
- pcmd,
- penvBlock,
- pdir,
- handles,
- redirectErrorStream);
- (*env)->ReleaseLongArrayElements(env, stdHandles, handles, 0);
+ if (!(*env)->ExceptionCheck(env)) {
+ const jchar *pdir = (dir != NULL)
+ ? (*env)->GetStringChars(env, dir, NULL)
+ : NULL;
+ if (!(*env)->ExceptionCheck(env)) {
+ jlong *handles = (*env)->GetLongArrayElements(env, stdHandles, NULL);
+ if (handles != NULL) {
+ ret = processCreate(
+ env,
+ pcmd,
+ penvBlock,
+ pdir,
+ handles,
+ redirectErrorStream);
+ (*env)->ReleaseLongArrayElements(env, stdHandles, handles, 0);
+ }
+ if (pdir != NULL)
+ (*env)->ReleaseStringChars(env, dir, pdir);
+ }
+ if (penvBlock != NULL)
+ (*env)->ReleaseStringChars(env, envBlock, penvBlock);
}
- if (pdir != NULL)
- (*env)->ReleaseStringChars(env, dir, pdir);
- if (penvBlock != NULL)
- (*env)->ReleaseStringChars(env, envBlock, penvBlock);
(*env)->ReleaseStringChars(env, cmd, pcmd);
}
}
@@ -448,7 +452,7 @@
JNIEXPORT jboolean JNICALL
Java_java_lang_ProcessImpl_closeHandle(JNIEnv *env, jclass ignored, jlong handle)
{
- return CloseHandle((HANDLE) handle);
+ return (jboolean) CloseHandle((HANDLE) handle);
}
/**
--- a/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c Tue Mar 25 14:51:01 2014 -0700
@@ -384,15 +384,19 @@
if (packetAddress == NULL) {
packetAddress = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa,
&port);
- /* stuff the new Inetaddress into the packet */
- (*env)->SetObjectField(env, dpObj, dp_addressID, packetAddress);
+ if (packetAddress != NULL) {
+ /* stuff the new Inetaddress into the packet */
+ (*env)->SetObjectField(env, dpObj, dp_addressID, packetAddress);
+ }
}
- /* populate the packet */
- (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, rv,
+ if (!(*env)->ExceptionCheck(env)) {
+ /* populate the packet */
+ (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, rv,
(jbyte *)fullPacket);
- (*env)->SetIntField(env, dpObj, dp_portID, port);
- (*env)->SetIntField(env, dpObj, dp_lengthID, rv);
+ (*env)->SetIntField(env, dpObj, dp_portID, port);
+ (*env)->SetIntField(env, dpObj, dp_lengthID, rv);
+ }
}
if (packetBufferLen > MAX_BUFFER_LEN) {
--- a/jdk/src/windows/native/java/net/NetworkInterface.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/windows/native/java/net/NetworkInterface.c Tue Mar 25 14:51:01 2014 -0700
@@ -543,16 +543,16 @@
* Create a NetworkInterface object and populate it
*/
netifObj = (*env)->NewObject(env, ni_class, ni_ctor);
+ CHECK_NULL_RETURN(netifObj, NULL);
name = (*env)->NewStringUTF(env, ifs->name);
+ CHECK_NULL_RETURN(name, NULL);
if (ifs->dNameIsUnicode) {
displayName = (*env)->NewString(env, (PWCHAR)ifs->displayName,
(jsize)wcslen ((PWCHAR)ifs->displayName));
} else {
displayName = (*env)->NewStringUTF(env, ifs->displayName);
}
- if (netifObj == NULL || name == NULL || displayName == NULL) {
- return NULL;
- }
+ CHECK_NULL_RETURN(displayName, NULL);
(*env)->SetObjectField(env, netifObj, ni_nameID, name);
(*env)->SetObjectField(env, netifObj, ni_displayNameID, displayName);
(*env)->SetIntField(env, netifObj, ni_indexID, ifs->index);
@@ -682,24 +682,29 @@
/* get the name as a C string */
name_utf = (*env)->GetStringUTFChars(env, name, &isCopy);
+ if (name_utf != NULL) {
- /* Search by name */
- curr = ifList;
- while (curr != NULL) {
- if (strcmp(name_utf, curr->name) == 0) {
- break;
+ /* Search by name */
+ curr = ifList;
+ while (curr != NULL) {
+ if (strcmp(name_utf, curr->name) == 0) {
+ break;
+ }
+ curr = curr->next;
}
- curr = curr->next;
+
+ /* if found create a NetworkInterface */
+ if (curr != NULL) {;
+ netifObj = createNetworkInterface(env, curr, -1, NULL);
+ }
+
+ /* release the UTF string */
+ (*env)->ReleaseStringUTFChars(env, name, name_utf);
+ } else {
+ if (!(*env)->ExceptionCheck(env))
+ JNU_ThrowOutOfMemoryError(env, NULL);
}
- /* if found create a NetworkInterface */
- if (curr != NULL) {;
- netifObj = createNetworkInterface(env, curr, -1, NULL);
- }
-
- /* release the UTF string */
- (*env)->ReleaseStringUTFChars(env, name, name_utf);
-
/* release the interface list */
free_netif(ifList);
--- a/jdk/src/windows/native/java/util/prefs/WindowsPreferences.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/windows/native/java/util/prefs/WindowsPreferences.c Tue Mar 25 14:51:01 2014 -0700
@@ -24,8 +24,10 @@
*/
#include <stdlib.h>
-#include <jni.h>
#include <windows.h>
+#include "jni.h"
+#include "jni_util.h"
+#include "jvm.h"
#ifdef __cplusplus
extern "C" {
#endif
@@ -37,12 +39,15 @@
int errorCode=-1;
jintArray result;
str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
+ CHECK_NULL_RETURN(str, NULL);
errorCode = RegOpenKeyEx((HKEY)hKey, str, 0, securityMask, &handle);
(*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
tmp[0]= (int) handle;
tmp[1]= errorCode;
result = (*env)->NewIntArray(env,2);
- (*env)->SetIntArrayRegion(env, result, 0, 2, tmp);
+ if (result != NULL) {
+ (*env)->SetIntArrayRegion(env, result, 0, 2, tmp);
+ }
return result;
}
@@ -58,8 +63,9 @@
int tmp[3];
DWORD lpdwDisposition;
int errorCode;
- jintArray result;
+ jintArray result = NULL;
str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
+ CHECK_NULL_RETURN(str, NULL);
errorCode = RegCreateKeyEx((HKEY)hKey, str, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_READ,
NULL, &handle, &lpdwDisposition);
@@ -68,7 +74,9 @@
tmp[1]= errorCode;
tmp[2]= lpdwDisposition;
result = (*env)->NewIntArray(env,3);
- (*env)->SetIntArrayRegion(env, result, 0, 3, tmp);
+ if (result != NULL) {
+ (*env)->SetIntArrayRegion(env, result, 0, 3, tmp);
+ }
return result;
}
@@ -77,6 +85,7 @@
char* str;
int result;
str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
+ CHECK_NULL_RETURN(str, -1);
result = RegDeleteKey((HKEY)hKey, str);
(*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
return result;
@@ -96,6 +105,7 @@
DWORD valueType;
DWORD valueSize;
valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
+ CHECK_NULL_RETURN(valueNameStr, NULL);
if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, NULL,
&valueSize) != ERROR_SUCCESS) {
(*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
@@ -103,19 +113,26 @@
}
buffer = (char*)malloc(valueSize);
-
- if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, buffer,
- &valueSize) != ERROR_SUCCESS) {
- free(buffer);
+ if (buffer != NULL) {
+ if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, buffer,
+ &valueSize) != ERROR_SUCCESS) {
+ free(buffer);
+ (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
+ return NULL;
+ }
+ } else {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
(*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
- return NULL;
+ return NULL;
}
if (valueType == REG_SZ) {
- result = (*env)->NewByteArray(env, valueSize);
- (*env)->SetByteArrayRegion(env, result, 0, valueSize, buffer);
+ result = (*env)->NewByteArray(env, valueSize);
+ if (result != NULL) {
+ (*env)->SetByteArrayRegion(env, result, 0, valueSize, buffer);
+ }
} else {
- result = NULL;
+ result = NULL;
}
free(buffer);
(*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
@@ -135,11 +152,14 @@
if ((valueName == NULL)||(data == NULL)) {return -1;}
size = (*env)->GetArrayLength(env, data);
dataStr = (*env)->GetByteArrayElements(env, data, NULL);
+ CHECK_NULL_RETURN(dataStr, -1);
valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
- error_code = RegSetValueEx((HKEY)hKey, valueNameStr, 0,
+ if (valueNameStr != NULL) {
+ error_code = RegSetValueEx((HKEY)hKey, valueNameStr, 0,
REG_SZ, dataStr, size);
+ (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
+ }
(*env)->ReleaseByteArrayElements(env, data, dataStr, 0);
- (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
return error_code;
}
@@ -149,6 +169,7 @@
int error_code = -1;
if (valueName == NULL) {return -1;}
valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
+ CHECK_NULL_RETURN(valueNameStr, -1);
error_code = RegDeleteValue((HKEY)hKey, valueNameStr);
(*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
return error_code;
@@ -156,7 +177,7 @@
JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryInfoKey
(JNIEnv* env, jclass this_class, jint hKey) {
- jintArray result;
+ jintArray result = NULL;
int tmp[5];
int valuesNumber = -1;
int maxValueNameLength = -1;
@@ -173,7 +194,9 @@
tmp[3]= maxSubKeyLength;
tmp[4]= maxValueNameLength;
result = (*env)->NewIntArray(env,5);
- (*env)->SetIntArrayRegion(env, result, 0, 5, tmp);
+ if (result != NULL) {
+ (*env)->SetIntArrayRegion(env, result, 0, 5, tmp);
+ }
return result;
}
@@ -183,13 +206,19 @@
jbyteArray result;
char* buffer = NULL;
buffer = (char*)malloc(maxKeyLength);
+ if (buffer == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+ return NULL;
+ }
if (RegEnumKeyEx((HKEY) hKey, subKeyIndex, buffer, &size, NULL, NULL,
NULL, NULL) != ERROR_SUCCESS){
free(buffer);
return NULL;
}
result = (*env)->NewByteArray(env, size + 1);
- (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
+ if (result != NULL) {
+ (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
+ }
free(buffer);
return result;
}
@@ -201,6 +230,10 @@
char* buffer = NULL;
int error_code;
buffer = (char*)malloc(maxValueNameLength);
+ if (buffer == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+ return NULL;
+ }
error_code = RegEnumValue((HKEY) hKey, valueIndex, buffer,
&size, NULL, NULL, NULL, NULL);
if (error_code!= ERROR_SUCCESS){
@@ -208,7 +241,9 @@
return NULL;
}
result = (*env)->NewByteArray(env, size + 1);
- (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
+ if (result != NULL) {
+ (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
+ }
free(buffer);
return result;
}
--- a/jdk/src/windows/native/sun/net/dns/ResolverConfigurationImpl.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/windows/native/sun/net/dns/ResolverConfigurationImpl.c Tue Mar 25 14:51:01 2014 -0700
@@ -39,6 +39,7 @@
#define STS_NO_CONFIG 0x0 /* no configuration found */
#define STS_SL_FOUND 0x1 /* search list found */
#define STS_NS_FOUND 0x2 /* name servers found */
+#define STS_ERROR -1 /* error return lodConfig failed memory allccation failure*/
#define IS_SL_FOUND(sts) (sts & STS_SL_FOUND)
#define IS_NS_FOUND(sts) (sts & STS_NS_FOUND)
@@ -123,14 +124,14 @@
size = sizeof(IP_ADAPTER_INFO);
adapterP = (IP_ADAPTER_INFO *)malloc(size);
if (adapterP == NULL) {
- return -1;
+ return STS_ERROR;
}
ret = GetAdaptersInfo(adapterP, &size);
if (ret == ERROR_BUFFER_OVERFLOW) {
IP_ADAPTER_INFO *newAdapterP = (IP_ADAPTER_INFO *)realloc(adapterP, size);
if (newAdapterP == NULL) {
free(adapterP);
- return -1;
+ return STS_ERROR;
}
adapterP = newAdapterP;
@@ -239,6 +240,7 @@
{
searchlistID = (*env)->GetStaticFieldID(env, cls, "os_searchlist",
"Ljava/lang/String;");
+ CHECK_NULL(searchlistID);
nameserversID = (*env)->GetStaticFieldID(env, cls, "os_nameservers",
"Ljava/lang/String;");
}
@@ -258,16 +260,21 @@
searchlist[0] = '\0';
nameservers[0] = '\0';
- loadConfig(searchlist, nameservers);
+ if (loadConfig(searchlist, nameservers) != STS_ERROR) {
- /*
- * Populate static fields in sun.net.DefaultResolverConfiguration
- */
- obj = (*env)->NewStringUTF(env, searchlist);
- (*env)->SetStaticObjectField(env, cls, searchlistID, obj);
+ /*
+ * Populate static fields in sun.net.DefaultResolverConfiguration
+ */
+ obj = (*env)->NewStringUTF(env, searchlist);
+ CHECK_NULL(obj);
+ (*env)->SetStaticObjectField(env, cls, searchlistID, obj);
- obj = (*env)->NewStringUTF(env, nameservers);
- (*env)->SetStaticObjectField(env, cls, nameserversID, obj);
+ obj = (*env)->NewStringUTF(env, nameservers);
+ CHECK_NULL(obj);
+ (*env)->SetStaticObjectField(env, cls, nameserversID, obj);
+ } else {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+ }
}
--- a/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c Tue Mar 25 14:51:01 2014 -0700
@@ -53,7 +53,9 @@
(JNIEnv *env, jclass authseq_clazz, jclass status_clazz)
{
ntlm_ctxHandleID = (*env)->GetFieldID(env, authseq_clazz, "ctxHandle", "J");
+ CHECK_NULL(ntlm_ctxHandleID);
ntlm_crdHandleID = (*env)->GetFieldID(env, authseq_clazz, "crdHandle", "J");
+ CHECK_NULL(ntlm_crdHandleID);
status_seqCompleteID = (*env)->GetFieldID(env, status_clazz, "sequenceComplete", "Z");
}
@@ -100,6 +102,16 @@
}
}
pCred = (CredHandle *)malloc(sizeof (CredHandle));
+ if (pCred == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+ if (pUser != NULL)
+ JNU_ReleaseStringPlatformChars(env, user, pUser);
+ if (pPassword != NULL)
+ JNU_ReleaseStringPlatformChars(env, password, pPassword);
+ if (pDomain != NULL)
+ JNU_ReleaseStringPlatformChars(env, domain, pDomain);
+ return NULL;
+ }
if ( ((pUser != NULL) || (pPassword != NULL)) || (pDomain != NULL)) {
pAuthId = &AuthId;
@@ -177,7 +189,12 @@
pCtx = (CtxtHandle *) (*env)->GetLongField (env, this, ntlm_ctxHandleID);
if (pCtx == 0) { /* first call */
newContext = (CtxtHandle *)malloc(sizeof(CtxtHandle));
- (*env)->SetLongField (env, this, ntlm_ctxHandleID, (jlong)newContext);
+ if (newContext != NULL) {
+ (*env)->SetLongField (env, this, ntlm_ctxHandleID, (jlong)newContext);
+ } else {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+ return NULL;
+ }
} else {
newContext = pCtx;
}
@@ -198,6 +215,7 @@
if (lastToken != 0)
{
pInput = (VOID *)(*env)->GetByteArrayElements(env, lastToken, &isCopy);
+ CHECK_NULL_RETURN(pInput, NULL);
inputLen = (*env)->GetArrayLength(env, lastToken);
InBuffDesc.ulVersion = 0;
@@ -240,8 +258,10 @@
if ( OutSecBuff.cbBuffer > 0 ) {
jbyteArray ret = (*env)->NewByteArray(env, OutSecBuff.cbBuffer);
- (*env)->SetByteArrayRegion(env, ret, 0, OutSecBuff.cbBuffer,
- OutSecBuff.pvBuffer);
+ if (ret != NULL) {
+ (*env)->SetByteArrayRegion(env, ret, 0, OutSecBuff.cbBuffer,
+ OutSecBuff.pvBuffer);
+ }
if (lastToken != 0) // 2nd stage
endSequence (pCred, pCtx, env, status);
result = ret;
--- a/jdk/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c Tue Mar 25 14:51:01 2014 -0700
@@ -1123,11 +1123,13 @@
JNU_ThrowInternalError(env, "GetFullPathNameW failed");
}
free(lpBuf);
+ } else {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failure");
}
}
+ } else {
+ throwWindowsException(env, GetLastError());
}
- if (len == 0)
- throwWindowsException(env, GetLastError());
return rv;
}
@@ -1162,13 +1164,13 @@
JNU_ThrowInternalError(env, "GetFinalPathNameByHandleW failed");
}
free(lpBuf);
+ } else {
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failure");
}
}
+ } else {
+ throwWindowsException(env, GetLastError());
}
-
- if (len == 0)
- throwWindowsException(env, GetLastError());
-
return rv;
}
--- a/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c Tue Mar 25 14:51:01 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -273,7 +273,9 @@
NULL); // default security attribute
if (hPipe == INVALID_HANDLE_VALUE) {
- JNU_ThrowIOExceptionWithLastError(env, "CreateNamedPipe failed");
+ char msg[256];
+ _snprintf(msg, sizeof(msg), "CreateNamedPipe failed: %d", GetLastError());
+ JNU_ThrowIOExceptionWithLastError(env, msg);
}
return (jlong)hPipe;
}
--- a/jdk/test/ProblemList.txt Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/ProblemList.txt Tue Mar 25 14:51:01 2014 -0700
@@ -261,6 +261,13 @@
############################################################################
+# jdk_instrument
+
+# 8037082
+java/lang/instrument/NativeMethodPrefixAgent.java generic-all
+
+############################################################################
+
# svc_tools
# 8031482
--- a/jdk/test/com/sun/corba/cachedSocket/7056731.sh Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/com/sun/corba/cachedSocket/7056731.sh Tue Mar 25 14:51:01 2014 -0700
@@ -102,7 +102,7 @@
sleep 5 # give time for Client to throw exception
# JVM_PROC should have exited but just in case, include it.
-kill -9 $ORB_PROC $JVM_PROC
+kill -9 $ORB_PROC $JVM_PROC $SERVER_PROC
grep "ORBUtilSystemException.writeErrorSend" client.$$
result=$?
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java Tue Mar 25 14:51:01 2014 -0700
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8034181
+ * @summary SIGBUS at Java_sun_nio_ch_SctpChannelImpl_receive0
+ * @author chegar
+ */
+
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import com.sun.nio.sctp.AbstractNotificationHandler;
+import com.sun.nio.sctp.AssociationChangeNotification;
+import com.sun.nio.sctp.AssociationChangeNotification.AssocChangeEvent;
+import com.sun.nio.sctp.HandlerResult;
+import com.sun.nio.sctp.MessageInfo;
+import com.sun.nio.sctp.Notification;
+import com.sun.nio.sctp.PeerAddressChangeNotification;
+import com.sun.nio.sctp.SctpChannel;
+import com.sun.nio.sctp.SctpServerChannel;
+import com.sun.nio.sctp.ShutdownNotification;
+import static java.lang.System.out;
+import static java.lang.System.err;
+import static java.nio.charset.StandardCharsets.US_ASCII;
+
+public class ReceiveIntoDirect {
+ /* suitably small message to NOT overrun small buffers */
+ final byte[] msgBytes = "Hello".getBytes(US_ASCII);
+
+ void test(String[] args) throws IOException {
+ SocketAddress address = null;
+ Server server;
+
+ if (!Util.isSCTPSupported()) {
+ out.println("SCTP protocol is not supported");
+ out.println("Test cannot be run");
+ return;
+ }
+
+ if (args.length == 2) {
+ /* requested to connecct to a specific address */
+ try {
+ int port = Integer.valueOf(args[1]);
+ address = new InetSocketAddress(args[0], port);
+ } catch (NumberFormatException nfe) {
+ err.println(nfe);
+ }
+ } else {
+ /* start server on local machine, default */
+ server = new Server();
+ server.start();
+ address = server.address();
+ debug("Server started and listening on " + address);
+ }
+
+ /* many combinations with varing buffer sizes, and offsets */
+ runWithManyOffsets(address, 20);
+ runWithManyOffsets(address, 49);
+ runWithManyOffsets(address, 50);
+ runWithManyOffsets(address, 51);
+ runWithManyOffsets(address, 1024);
+ }
+
+ void runWithManyOffsets(SocketAddress addr, int bufferSize)
+ throws IOException
+ {
+ doTest(addr, bufferSize, 1);
+ doTest(addr, bufferSize, 2);
+ doTest(addr, bufferSize, 3);
+ doTest(addr, bufferSize, 4);
+ doTest(addr, bufferSize, 5);
+ doTest(addr, bufferSize, 6);
+ doTest(addr, bufferSize, 7);
+ doTest(addr, bufferSize, 8);
+ doTest(addr, bufferSize, 9);
+ doTest(addr, bufferSize, 10);
+ doTest(addr, bufferSize, 11);
+ doTest(addr, bufferSize, 12);
+ doTest(addr, bufferSize, 13);
+ doTest(addr, bufferSize, 14);
+ doTest(addr, bufferSize, 15);
+ }
+
+ void doTest(SocketAddress peerAddress, int bufferSize, int bufferOffset)
+ throws IOException
+ {
+ debug("\n\nTesting with bufferSize " + bufferSize + " and offset " + bufferOffset);
+ assert bufferOffset + msgBytes.length <= bufferSize :
+ "buffer offset + message length greater than buffer size ";
+
+ ByteBuffer buffer = ByteBuffer.allocateDirect(bufferSize);
+ MessageInfo info;
+
+ try (SctpChannel channel = SctpChannel.open()) {
+ channel.connect(peerAddress);
+
+ ReceiveNotificationHandler handler =
+ new ReceiveNotificationHandler();
+
+ /* TEST 1: Assoc/peer change notif into direct buffer with offest */
+ do {
+ debug("Test 1: Assoc/peer change with offset " + bufferOffset);
+ buffer.position(bufferOffset);
+ info = channel.receive(buffer, null, handler);
+ if (info == null) {
+ fail("unexpected null from receive");
+ return;
+ }
+ } while (!info.isComplete());
+
+ buffer.flip().position(bufferOffset);
+ check(handler.receivedCommUp(), "SCTP_COMM_UP not received");
+ check(info != null, "info is null");
+ check(info.address() != null, "address is null");
+ check(info.association() != null, "association is null");
+ check(info.isComplete(), "message is not complete");
+ check(info.isUnordered() != true,
+ "message should not be unordered");
+ check(info.streamNumber() >= 0, "invalid stream number");
+ check(info.bytes() == msgBytes.length,
+ "bytes received not equal to message length");
+ check(info.bytes() == buffer.remaining(), "bytes != remaining");
+ check(Util.compare(buffer, msgBytes),
+ "received message not the same as sent message");
+
+ /* TEST 2: shutdown notification with offset */
+ debug("Test 2: shutdown notif with offset " + bufferOffset);
+ buffer.clear().position(bufferOffset);
+ while ((info = channel.receive(buffer, null, handler )) != null &&
+ info.bytes() != -1 );
+ }
+ }
+
+ class Server implements Runnable
+ {
+ private final InetSocketAddress serverAddr;
+ private final SctpServerChannel ssc;
+
+ public Server() throws IOException {
+ ssc = SctpServerChannel.open().bind(null);
+ java.util.Set<SocketAddress> addrs = ssc.getAllLocalAddresses();
+ if (addrs.isEmpty())
+ debug("addrs should not be empty");
+
+ serverAddr = (InetSocketAddress) addrs.iterator().next();
+ }
+
+ public void start() {
+ (new Thread(this, "Server-" + serverAddr.getPort())).start();
+ }
+
+ public InetSocketAddress address() {
+ return serverAddr;
+ }
+
+ @Override
+ public void run() {
+ try {
+ for (int i=0; i<75; i++) { // there are 75 client combinations
+ SctpChannel sc = ssc.accept();
+
+ /* send a small message */
+ MessageInfo info = MessageInfo.createOutgoing(null, 0);
+ ByteBuffer buf = ByteBuffer.allocateDirect(Util.SMALL_BUFFER);
+ buf.put(msgBytes);
+ buf.flip();
+
+ debug("sending small message: " + buf);
+ sc.send(buf, info);
+
+ sc.shutdown();
+ sc.close();
+ }
+ } catch (IOException x) {
+ unexpected(x);
+ } finally {
+ try { ssc.close(); }
+ catch (IOException x) { unexpected(x); }
+ }
+ }
+ }
+
+ class ReceiveNotificationHandler extends AbstractNotificationHandler<Object>
+ {
+ boolean receivedCommUp; // false
+
+ public ReceiveNotificationHandler() { }
+
+ public boolean receivedCommUp() {
+ return receivedCommUp;
+ }
+
+ @Override
+ public HandlerResult handleNotification(
+ Notification notification, Object attachment) {
+ fail("Unknown notification type");
+ return HandlerResult.CONTINUE;
+ }
+
+ @Override
+ public HandlerResult handleNotification(
+ AssociationChangeNotification notification, Object attachment) {
+ AssocChangeEvent event = notification.event();
+ debug("AssociationChangeNotification");
+ debug(" Association: " + notification.association());
+ debug(" Event: " + event);
+
+ if (event.equals(AssocChangeEvent.COMM_UP))
+ receivedCommUp = true;
+
+ return HandlerResult.CONTINUE;
+ }
+
+ @Override
+ public HandlerResult handleNotification(
+ PeerAddressChangeNotification pacn, Object unused)
+ {
+ debug("PeerAddressChangeNotification: " + pacn);
+ return HandlerResult.CONTINUE;
+ }
+
+ @Override
+ public HandlerResult handleNotification(
+ ShutdownNotification notification, Object attachment) {
+ debug("ShutdownNotification");
+ debug(" Association: " + notification.association());
+ return HandlerResult.CONTINUE;
+ }
+ }
+ //--------------------- Infrastructure ---------------------------
+ boolean debug = true;
+ volatile int passed = 0, failed = 0;
+ void pass() {passed++;}
+ void fail() {failed++; Thread.dumpStack();}
+ void fail(String msg) {System.err.println(msg); fail();}
+ void unexpected(Throwable t) {failed++; t.printStackTrace();}
+ void check(boolean cond) {if (cond) pass(); else fail();}
+ void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);}
+ void debug(String message) {if(debug) {
+ System.out.println(Thread.currentThread() + " " + message); } }
+ public static void main(String[] args) throws Throwable {
+ Class<?> k = new Object(){}.getClass().getEnclosingClass();
+ try {k.getMethod("instanceMain",String[].class)
+ .invoke( k.newInstance(), (Object) args);}
+ catch (Throwable e) {throw e.getCause();}}
+ public void instanceMain(String[] args) throws Throwable {
+ try {test(args);} catch (Throwable t) {unexpected(t);}
+ System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+ if (failed > 0) throw new AssertionError("Some tests failed");}
+
+}
--- a/jdk/test/java/lang/Runtime/exec/ConcurrentRead.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/java/lang/Runtime/exec/ConcurrentRead.java Tue Mar 25 14:51:01 2014 -0700
@@ -30,21 +30,19 @@
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.File;
-import java.io.IOException;
public class ConcurrentRead {
static volatile Exception savedException;
- static final String TEE = "/usr/bin/tee";
public static void main(String[] args) throws Exception {
+ if (! UnixCommands.isUnix) {
+ System.out.println("For UNIX only");
+ return;
+ }
+ UnixCommands.ensureCommandsAvailable("tee");
- if (File.separatorChar == '\\' || // Windows
- !new File(TEE).exists()) // no tee
- return;
-
- Process p = Runtime.getRuntime().exec(TEE);
+ Process p = Runtime.getRuntime().exec(UnixCommands.tee());
OutputStream out = p.getOutputStream();
InputStream in = p.getInputStream();
Thread t1 = new WriterThread(out, in);
--- a/jdk/test/java/lang/Runtime/exec/ExecWithDir.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/java/lang/Runtime/exec/ExecWithDir.java Tue Mar 25 14:51:01 2014 -0700
@@ -28,21 +28,25 @@
* directory is specified
*/
-import java.io.*;
+import java.io.File;
public class ExecWithDir {
- private static final String CMD = "/bin/true";
private static final int N = 500;
public static void main(String args[]) throws Exception {
- if (! new File(CMD).canExecute())
+ if (! UnixCommands.isUnix) {
+ System.out.println("For UNIX only");
return;
+ }
+ UnixCommands.ensureCommandsAvailable("true");
+
+ final String trueCmd = UnixCommands.findCommand("true");
File dir = new File(".");
for (int i = 1; i <= N; i++) {
System.out.print(i);
System.out.print(" e");
- Process p = Runtime.getRuntime().exec(CMD, null, dir);
+ Process p = Runtime.getRuntime().exec(trueCmd, null, dir);
System.out.print('w');
int s = p.waitFor();
System.out.println("x " + s);
--- a/jdk/test/java/lang/Runtime/exec/ExecWithInput.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/java/lang/Runtime/exec/ExecWithInput.java Tue Mar 25 14:51:01 2014 -0700
@@ -39,7 +39,6 @@
public class ExecWithInput {
- private static final String CAT = "/bin/cat";
private static final int N = 200;
static int go(int i) throws Exception {
@@ -50,8 +49,7 @@
* program exits. Under 1.4.1, cat sometimes gets stuck on a pipe
* read and never terminates.
*/
- //Process p = Runtime.getRuntime().exec(new String[] { CAT } );
- Process p = Runtime.getRuntime().exec(CAT);
+ Process p = Runtime.getRuntime().exec(UnixCommands.cat());
String input = i + ": line 1\n" + i + ": line 2\n";
StringBufferInputStream in = new StringBufferInputStream(input);
@@ -65,12 +63,12 @@
}
public static void main(String[] args) throws Exception {
- if (!System.getProperty("os.name").equals("Linux"))
- return;
- if (File.separatorChar == '\\') {
- // no /bin/cat on windows
+ if (! UnixCommands.isLinux) {
+ System.out.println("For Linux only");
return;
}
+ UnixCommands.ensureCommandsAvailable("cat");
+
for (int i = 0; i < N; i++)
go(i);
}
@@ -93,7 +91,6 @@
public void run() {
try {
- int c;
byte[] buf = new byte[8192];
int n;
while ((n = in.read(buf)) != -1) {
--- a/jdk/test/java/lang/Runtime/exec/ExitValue.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/java/lang/Runtime/exec/ExitValue.java Tue Mar 25 14:51:01 2014 -0700
@@ -68,13 +68,18 @@
int expectedExitValue)
throws Exception
{
- checkExitValue(new String[] { "/bin/sh", "-c", posixShellProgram },
+ checkExitValue(new String[] { UnixCommands.sh(), "-c", posixShellProgram },
expectedExitValue);
}
final static int EXIT_CODE = 5;
public static void main(String[] args) throws Exception {
+ if (! UnixCommands.isUnix) {
+ System.out.println("For UNIX only");
+ return;
+ }
+ UnixCommands.ensureCommandsAvailable("sh", "true", "kill");
String java = join(File.separator, new String []
{ System.getProperty("java.home"), "bin", "java" });
@@ -85,17 +90,14 @@
"ExitValue$Run", String.valueOf(EXIT_CODE)
}, EXIT_CODE);
- checkExitValue(new String[] { "/bin/true" }, 0);
+ checkExitValue(new String[] { UnixCommands.findCommand("true") }, 0);
checkPosixShellExitValue("exit", 0);
checkPosixShellExitValue("exit 7", 7);
- if (new File("/bin/kill").exists()) {
- int sigoffset =
- System.getProperty("os.name").equals("SunOS") ? 0 : 128;
- checkPosixShellExitValue("/bin/kill -9 $$", sigoffset+9);
- }
+ int sigoffset = UnixCommands.isSunOS ? 0 : 128;
+ checkPosixShellExitValue(UnixCommands.kill() + " -9 $$", sigoffset+9);
}
public static class Run {
--- a/jdk/test/java/lang/Runtime/exec/LotsOfDestroys.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/java/lang/Runtime/exec/LotsOfDestroys.java Tue Mar 25 14:51:01 2014 -0700
@@ -28,19 +28,19 @@
* @author kladko
*/
-import java.io.File;
-
public class LotsOfDestroys {
static final int RUNS = 400;
- static final String ECHO = "/usr/bin/echo";
public static void main(String[] args) throws Exception {
- if (File.separatorChar == '\\' || // Windows
- !new File(ECHO).exists()) // no echo
+ if (! UnixCommands.isUnix) {
+ System.out.println("For UNIX only");
return;
+ }
+ UnixCommands.ensureCommandsAvailable("echo");
- for (int i = 0; i<= RUNS; i++) {
- Process process = Runtime.getRuntime().exec(ECHO + " x");
+ for (int i = 0; i <= RUNS; i++) {
+ Process process = Runtime.getRuntime().exec(
+ UnixCommands.echo() + " x");
process.destroy();
}
}
--- a/jdk/test/java/lang/Runtime/exec/LotsOfOutput.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/java/lang/Runtime/exec/LotsOfOutput.java Tue Mar 25 14:51:01 2014 -0700
@@ -28,16 +28,16 @@
* @author kladko
*/
-import java.io.File;
-
public class LotsOfOutput {
- static final String CAT = "/usr/bin/cat";
- public static void main(String[] args) throws Exception{
- if (File.separatorChar == '\\' || // Windows
- !new File(CAT).exists()) // no cat
+ public static void main(String[] args) throws Exception {
+ if (! UnixCommands.isUnix) {
+ System.out.println("For UNIX only");
return;
- Process p = Runtime.getRuntime().exec(CAT + " /dev/zero");
+ }
+ UnixCommands.ensureCommandsAvailable("cat");
+
+ Process p = Runtime.getRuntime().exec(UnixCommands.cat() + " /dev/zero");
long initMemory = Runtime.getRuntime().totalMemory();
for (int i=1; i< 10; i++) {
Thread.sleep(100);
--- a/jdk/test/java/lang/Runtime/exec/SleepyCat.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/java/lang/Runtime/exec/SleepyCat.java Tue Mar 25 14:51:01 2014 -0700
@@ -73,8 +73,8 @@
// slower, making the child more likely to win the race!
int iterations = 20;
int timeout = 30;
- String[] catArgs = new String[] {"/bin/cat"};
- String[] sleepArgs = new String[] {"/bin/sleep",
+ String[] catArgs = new String[] {UnixCommands.cat()};
+ String[] sleepArgs = new String[] {UnixCommands.sleep(),
String.valueOf(timeout+1)};
Process[] cats = new Process[iterations];
Process[] sleeps = new Process[iterations];
@@ -126,8 +126,9 @@
timer.schedule(sleeperExecutioner, timeout * 1000);
byte[] buffer = new byte[10];
String[] args =
- new String[] {"/bin/sh", "-c",
- "exec sleep " + (timeout+1) + " >/dev/null"};
+ new String[] {UnixCommands.sh(), "-c",
+ "exec " + UnixCommands.sleep() + " "
+ + (timeout+1) + " >/dev/null"};
for (int i = 0;
i < backgroundSleepers.length && !sleeperExecutioner.timedOut();
@@ -153,12 +154,13 @@
}
public static void main (String[] args) throws Exception {
- try {
- if (hang1() | hang2())
- throw new Exception("Read from closed pipe hangs");
- } catch (IOException e) {
- // We will get here on non-Posix systems,
- // which don't have cat and sleep and sh.
+ if (! UnixCommands.isUnix) {
+ System.out.println("For UNIX only");
+ return;
}
+ UnixCommands.ensureCommandsAvailable("sh", "cat", "sleep");
+
+ if (hang1() | hang2())
+ throw new Exception("Read from closed pipe hangs");
}
}
--- a/jdk/test/java/lang/Runtime/exec/Status.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/java/lang/Runtime/exec/Status.java Tue Mar 25 14:51:01 2014 -0700
@@ -35,10 +35,15 @@
public static void main(String args[])
throws Exception
{
- if (!System.getProperty("os.name").equals("Linux"))
+ if (!System.getProperty("os.name").equals("Linux")) {
+ System.out.println("Only for Linux");
return;
+ }
+ UnixCommands.ensureCommandsAvailable("false");
+
+ final String falseCmd = UnixCommands.findCommand("false");
for (int i = 0; i < N; i++) {
- Process p = Runtime.getRuntime().exec("false");
+ Process p = Runtime.getRuntime().exec(falseCmd);
int s = p.waitFor();
System.out.print(s);
System.out.print(' ');
--- a/jdk/test/java/lang/Runtime/exec/StreamsSurviveDestroy.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/java/lang/Runtime/exec/StreamsSurviveDestroy.java Tue Mar 25 14:51:01 2014 -0700
@@ -102,7 +102,7 @@
CountDownLatch latch = new CountDownLatch(2);
System.err.println("test");
- Process p = Runtime.getRuntime().exec("/bin/cat");
+ Process p = Runtime.getRuntime().exec(UnixCommands.cat());
Copier cp1 = new Copier("out", p.getInputStream(), System.err,
false, false, latch);
Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
@@ -122,7 +122,7 @@
CountDownLatch latch = new CountDownLatch(2);
System.err.println("testCloseBeforeDestroy");
- Process p = Runtime.getRuntime().exec("/bin/cat");
+ Process p = Runtime.getRuntime().exec(UnixCommands.cat());
Copier cp1 = new Copier("out", p.getInputStream(), System.err,
true, false, latch);
Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
@@ -143,7 +143,7 @@
static void testCloseAfterDestroy() throws Exception {
CountDownLatch latch = new CountDownLatch(2);
System.err.println("testCloseAfterDestroy");
- Process p = Runtime.getRuntime().exec("/bin/cat");
+ Process p = Runtime.getRuntime().exec(UnixCommands.cat());
Copier cp1 = new Copier("out", p.getInputStream(), System.err,
true, false,latch);
Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
@@ -165,7 +165,7 @@
static void testInterrupt() throws Exception {
CountDownLatch latch = new CountDownLatch(2);
System.err.println("testInterrupt");
- Process p = Runtime.getRuntime().exec("/bin/cat");
+ Process p = Runtime.getRuntime().exec(UnixCommands.cat());
Copier cp1 = new Copier("out", p.getInputStream(), System.err,
false, true, latch);
Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
@@ -186,10 +186,13 @@
public static void main(String[] args) throws Exception {
- // Applies only to Solaris; Linux and Windows
- // behave a little differently
- if (!System.getProperty("os.name").equals("SunOS"))
+ // Applies only to Solaris;
+ // Linux and Windows behave a little differently
+ if (! UnixCommands.isSunOS) {
+ System.out.println("For SunOS only");
return;
+ }
+ UnixCommands.ensureCommandsAvailable("cat");
test();
testCloseBeforeDestroy();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/Runtime/exec/UnixCommands.java Tue Mar 25 14:51:01 2014 -0700
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Utility class for finding the command on the current system
+ */
+public class UnixCommands {
+
+ public static final boolean isUnix = ! System.getProperty("os.name").startsWith("Windows");
+ public static final boolean isLinux = System.getProperty("os.name").startsWith("Linux");
+ public static final boolean isSunOS = System.getProperty("os.name").equals("SunOS");
+
+ private static final String[] paths = {"/bin", "/usr/bin"};
+
+ private static Map<String,String> nameToCommand = new HashMap<>(16);
+
+ /**
+ * Throws Error unless every listed command is available on the system
+ */
+ public static void ensureCommandsAvailable(String... commands) {
+ for (String command : commands) {
+ if (findCommand(command) == null) {
+ throw new Error("Command '" + command + "' not found; bailing out");
+ }
+ }
+ }
+
+ /**
+ * If the path to the command could be found, returns the command with the full path.
+ * Otherwise, returns null.
+ */
+ public static String cat() { return findCommand("cat"); }
+ public static String sh() { return findCommand("sh"); }
+ public static String kill() { return findCommand("kill"); }
+ public static String sleep() { return findCommand("sleep"); }
+ public static String tee() { return findCommand("tee"); }
+ public static String echo() { return findCommand("echo"); }
+
+ public static String findCommand(String name) {
+ if (nameToCommand.containsKey(name)) {
+ return nameToCommand.get(name);
+ }
+ String command = findCommand0(name);
+ nameToCommand.put(name, command);
+ return command;
+ }
+
+ private static String findCommand0(String name) {
+ for (String path : paths) {
+ File file = new File(path, name);
+ if (file.canExecute()) {
+ return file.getPath();
+ }
+ }
+ return null;
+ }
+}
--- a/jdk/test/java/nio/channels/Selector/ChangingInterests.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/java/nio/channels/Selector/ChangingInterests.java Tue Mar 25 14:51:01 2014 -0700
@@ -138,8 +138,10 @@
ServerSocketChannel.open().bind(new InetSocketAddress(0));
final SocketChannel sc = SocketChannel.open();
+ sc.setOption(StandardSocketOptions.TCP_NODELAY, true);
sc.connect(new InetSocketAddress(lh, ssc.socket().getLocalPort()));
SocketChannel peer = ssc.accept();
+ peer.setOption(StandardSocketOptions.TCP_NODELAY, true);
sc.configureBlocking(false);
--- a/jdk/test/java/nio/file/Path/PathOps.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/java/nio/file/Path/PathOps.java Tue Mar 25 14:51:01 2014 -0700
@@ -22,7 +22,7 @@
*/
/* @test
- * @bug 4313887 6838333 6925932 7006126
+ * @bug 4313887 6838333 6925932 7006126 8037945
* @summary Unit test for java.nio.file.Path path operations
*/
@@ -899,6 +899,8 @@
.normalize("foo");
test("/foo")
.normalize("/foo");
+ test("")
+ .normalize("");
test(".")
.normalize("");
test("..")
--- a/jdk/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java Tue Mar 25 14:51:01 2014 -0700
@@ -90,9 +90,6 @@
import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
import static java.time.temporal.ChronoField.YEAR;
import static java.time.temporal.ChronoField.YEAR_OF_ERA;
-import static java.time.temporal.ChronoUnit.DAYS;
-import static java.time.temporal.ChronoUnit.FOREVER;
-import static java.time.temporal.ChronoUnit.NANOS;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
@@ -102,13 +99,17 @@
import java.time.Period;
import java.time.ZoneId;
import java.time.ZonedDateTime;
-import java.time.chrono.Chronology;
+import java.time.chrono.ChronoLocalDate;
+import java.time.chrono.ChronoLocalDateTime;
+import java.time.chrono.ChronoZonedDateTime;
+import java.time.chrono.IsoChronology;
+import java.time.chrono.MinguoChronology;
+import java.time.chrono.MinguoDate;
import java.time.chrono.ThaiBuddhistChronology;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.DateTimeParseException;
import java.time.format.ResolverStyle;
-import java.time.temporal.ChronoUnit;
import java.time.temporal.IsoFields;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalAccessor;
@@ -129,6 +130,9 @@
// TODO: tests with weird TenporalField implementations
// TODO: tests with non-ISO chronologies
+ private static final ZoneId EUROPE_ATHENS = ZoneId.of("Europe/Athens");
+ private static final ZoneId EUROPE_PARIS = ZoneId.of("Europe/Paris");
+
//-----------------------------------------------------------------------
@DataProvider(name="resolveOneNoChange")
Object[][] data_resolveOneNoChange() {
@@ -886,205 +890,273 @@
}
//-----------------------------------------------------------------------
+ // SPEC: DateTimeFormatter.withChronology()
@Test
- public void test_fieldResolvesToLocalTime() {
- TemporalField field = new TemporalField() {
- @Override
- public TemporalUnit getBaseUnit() {
- throw new UnsupportedOperationException();
- }
- @Override
- public TemporalUnit getRangeUnit() {
- throw new UnsupportedOperationException();
- }
- @Override
- public ValueRange range() {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean isDateBased() {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean isTimeBased() {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean isSupportedBy(TemporalAccessor temporal) {
- throw new UnsupportedOperationException();
- }
- @Override
- public ValueRange rangeRefinedBy(TemporalAccessor temporal) {
- throw new UnsupportedOperationException();
- }
- @Override
- public long getFrom(TemporalAccessor temporal) {
- throw new UnsupportedOperationException();
- }
- @Override
- public <R extends Temporal> R adjustInto(R temporal, long newValue) {
- throw new UnsupportedOperationException();
- }
- @Override
- public TemporalAccessor resolve(
- Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
- return LocalTime.MIDNIGHT.plusNanos(fieldValues.remove(this));
- }
- };
- DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field).toFormatter();
- TemporalAccessor accessor = f.parse("1234567890");
- assertEquals(accessor.query(TemporalQueries.localDate()), null);
- assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.of(0, 0, 1, 234_567_890));
+ public void test_withChronology_noOverride() {
+ DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).toFormatter();
+ TemporalAccessor accessor = f.parse("");
+ assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+ assertEquals(accessor.query(TemporalQueries.localTime()), null);
+ assertEquals(accessor.query(TemporalQueries.chronology()), IsoChronology.INSTANCE);
+ }
+
+ @Test
+ public void test_withChronology_override() {
+ DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).toFormatter();
+ f = f.withChronology(MinguoChronology.INSTANCE);
+ TemporalAccessor accessor = f.parse("");
+ assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+ assertEquals(accessor.query(TemporalQueries.localTime()), null);
+ assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
+ }
+
+ @Test
+ public void test_withChronology_parsedChronology_noOverride() {
+ DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).appendChronologyId().toFormatter();
+ TemporalAccessor accessor = f.parse("ThaiBuddhist");
+ assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+ assertEquals(accessor.query(TemporalQueries.localTime()), null);
+ assertEquals(accessor.query(TemporalQueries.chronology()), ThaiBuddhistChronology.INSTANCE);
+ }
+
+ @Test
+ public void test_withChronology_parsedChronology_override() {
+ DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).appendChronologyId().toFormatter();
+ f = f.withChronology(MinguoChronology.INSTANCE);
+ TemporalAccessor accessor = f.parse("ThaiBuddhist");
+ assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+ assertEquals(accessor.query(TemporalQueries.localTime()), null);
+ assertEquals(accessor.query(TemporalQueries.chronology()), ThaiBuddhistChronology.INSTANCE);
+ }
+
+ //-----------------------------------------------------------------------
+ // SPEC: DateTimeFormatter.withZone()
+ @Test
+ public void test_withZone_noOverride() {
+ DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).toFormatter();
+ TemporalAccessor accessor = f.parse("");
+ assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+ assertEquals(accessor.query(TemporalQueries.localTime()), null);
+ assertEquals(accessor.query(TemporalQueries.zoneId()), null);
}
@Test
- public void test_fieldResolvesToChronoLocalDateTime() {
- TemporalField field = new TemporalField() {
- @Override
- public TemporalUnit getBaseUnit() {
- throw new UnsupportedOperationException();
- }
- @Override
- public TemporalUnit getRangeUnit() {
- throw new UnsupportedOperationException();
- }
- @Override
- public ValueRange range() {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean isDateBased() {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean isTimeBased() {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean isSupportedBy(TemporalAccessor temporal) {
- throw new UnsupportedOperationException();
- }
- @Override
- public ValueRange rangeRefinedBy(TemporalAccessor temporal) {
- throw new UnsupportedOperationException();
- }
- @Override
- public long getFrom(TemporalAccessor temporal) {
- throw new UnsupportedOperationException();
- }
- @Override
- public <R extends Temporal> R adjustInto(R temporal, long newValue) {
- throw new UnsupportedOperationException();
- }
- @Override
- public TemporalAccessor resolve(
- Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
- fieldValues.remove(this);
- return LocalDateTime.of(2010, 6, 30, 12, 30);
- }
- };
- DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field).toFormatter();
+ public void test_withZone_override() {
+ DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).toFormatter();
+ f = f.withZone(EUROPE_ATHENS);
+ TemporalAccessor accessor = f.parse("");
+ assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+ assertEquals(accessor.query(TemporalQueries.localTime()), null);
+ assertEquals(accessor.query(TemporalQueries.zoneId()), EUROPE_ATHENS);
+ }
+
+ @Test
+ public void test_withZone_parsedZone_noOverride() {
+ DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).appendZoneId().toFormatter();
+ TemporalAccessor accessor = f.parse("Europe/Paris");
+ assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+ assertEquals(accessor.query(TemporalQueries.localTime()), null);
+ assertEquals(accessor.query(TemporalQueries.zoneId()), EUROPE_PARIS);
+ }
+
+ @Test
+ public void test_withZone_parsedZone_override() {
+ DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(EPOCH_DAY, 2).appendZoneId().toFormatter();
+ f = f.withZone(EUROPE_ATHENS);
+ TemporalAccessor accessor = f.parse("Europe/Paris");
+ assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(1970, 1, 3));
+ assertEquals(accessor.query(TemporalQueries.localTime()), null);
+ assertEquals(accessor.query(TemporalQueries.zoneId()), EUROPE_PARIS);
+ }
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_fieldResolvesToLocalTime() {
+ LocalTime lt = LocalTime.of(12, 30, 40);
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(lt)).toFormatter();
+ TemporalAccessor accessor = f.parse("1234567890");
+ assertEquals(accessor.query(TemporalQueries.localDate()), null);
+ assertEquals(accessor.query(TemporalQueries.localTime()), lt);
+ }
+
+ //-------------------------------------------------------------------------
+ @Test
+ public void test_fieldResolvesToChronoLocalDate_noOverrideChrono_matches() {
+ LocalDate ldt = LocalDate.of(2010, 6, 30);
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(ldt)).toFormatter();
TemporalAccessor accessor = f.parse("1234567890");
assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(2010, 6, 30));
- assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.of(12, 30));
+ assertEquals(accessor.query(TemporalQueries.localTime()), null);
+ assertEquals(accessor.query(TemporalQueries.chronology()), IsoChronology.INSTANCE);
+ }
+
+ @Test
+ public void test_fieldResolvesToChronoLocalDate_overrideChrono_matches() {
+ MinguoDate mdt = MinguoDate.of(100, 6, 30);
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(mdt)).toFormatter();
+ f = f.withChronology(MinguoChronology.INSTANCE);
+ TemporalAccessor accessor = f.parse("1234567890");
+ assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.from(mdt));
+ assertEquals(accessor.query(TemporalQueries.localTime()), null);
+ assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
}
@Test(expectedExceptions = DateTimeParseException.class)
- public void test_fieldResolvesWrongChrono() {
- TemporalField field = new TemporalField() {
- @Override
- public TemporalUnit getBaseUnit() {
- throw new UnsupportedOperationException();
- }
- @Override
- public TemporalUnit getRangeUnit() {
- throw new UnsupportedOperationException();
- }
- @Override
- public ValueRange range() {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean isDateBased() {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean isTimeBased() {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean isSupportedBy(TemporalAccessor temporal) {
- throw new UnsupportedOperationException();
- }
- @Override
- public ValueRange rangeRefinedBy(TemporalAccessor temporal) {
- throw new UnsupportedOperationException();
- }
- @Override
- public long getFrom(TemporalAccessor temporal) {
- throw new UnsupportedOperationException();
- }
- @Override
- public <R extends Temporal> R adjustInto(R temporal, long newValue) {
- throw new UnsupportedOperationException();
- }
- @Override
- public TemporalAccessor resolve(
- Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
- return ThaiBuddhistChronology.INSTANCE.dateNow();
- }
- };
- DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field).toFormatter();
+ public void test_fieldResolvesToChronoLocalDate_noOverrideChrono_wrongChrono() {
+ ChronoLocalDate cld = ThaiBuddhistChronology.INSTANCE.dateNow();
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cld)).toFormatter();
f.parse("1234567890");
}
@Test(expectedExceptions = DateTimeParseException.class)
- public void test_fieldResolvesWrongZone() {
- TemporalField field = new TemporalField() {
- @Override
- public TemporalUnit getBaseUnit() {
- throw new UnsupportedOperationException();
- }
- @Override
- public TemporalUnit getRangeUnit() {
- throw new UnsupportedOperationException();
- }
- @Override
- public ValueRange range() {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean isDateBased() {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean isTimeBased() {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean isSupportedBy(TemporalAccessor temporal) {
- throw new UnsupportedOperationException();
- }
- @Override
- public ValueRange rangeRefinedBy(TemporalAccessor temporal) {
- throw new UnsupportedOperationException();
- }
- @Override
- public long getFrom(TemporalAccessor temporal) {
- throw new UnsupportedOperationException();
- }
- @Override
- public <R extends Temporal> R adjustInto(R temporal, long newValue) {
- throw new UnsupportedOperationException();
- }
- @Override
- public TemporalAccessor resolve(
- Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
- return ZonedDateTime.of(2010, 6, 30, 12, 30, 0, 0, ZoneId.of("Europe/Paris"));
- }
- };
- DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field).toFormatter().withZone(ZoneId.of("Europe/London"));
+ public void test_fieldResolvesToChronoLocalDate_overrideChrono_wrongChrono() {
+ ChronoLocalDate cld = ThaiBuddhistChronology.INSTANCE.dateNow();
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cld)).toFormatter();
+ f = f.withChronology(MinguoChronology.INSTANCE);
+ f.parse("1234567890");
+ }
+
+ //-------------------------------------------------------------------------
+ @Test
+ public void test_fieldResolvesToChronoLocalDateTime_noOverrideChrono_matches() {
+ LocalDateTime ldt = LocalDateTime.of(2010, 6, 30, 12, 30);
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(ldt)).toFormatter();
+ TemporalAccessor accessor = f.parse("1234567890");
+ assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(2010, 6, 30));
+ assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.of(12, 30));
+ assertEquals(accessor.query(TemporalQueries.chronology()), IsoChronology.INSTANCE);
+ }
+
+ @Test
+ public void test_fieldResolvesToChronoLocalDateTime_overrideChrono_matches() {
+ MinguoDate mdt = MinguoDate.of(100, 6, 30);
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(mdt.atTime(LocalTime.NOON))).toFormatter();
+ f = f.withChronology(MinguoChronology.INSTANCE);
+ TemporalAccessor accessor = f.parse("1234567890");
+ assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.from(mdt));
+ assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.NOON);
+ assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
+ }
+
+ @Test(expectedExceptions = DateTimeParseException.class)
+ public void test_fieldResolvesToChronoLocalDateTime_noOverrideChrono_wrongChrono() {
+ ChronoLocalDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON);
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
+ f.parse("1234567890");
+ }
+
+ @Test(expectedExceptions = DateTimeParseException.class)
+ public void test_fieldResolvesToChronoLocalDateTime_overrideChrono_wrongChrono() {
+ ChronoLocalDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON);
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
+ f = f.withChronology(MinguoChronology.INSTANCE);
+ f.parse("1234567890");
+ }
+
+ //-------------------------------------------------------------------------
+ @Test
+ public void test_fieldResolvesToChronoZonedDateTime_noOverrideChrono_matches() {
+ ZonedDateTime zdt = ZonedDateTime.of(2010, 6, 30, 12, 30, 0, 0, EUROPE_PARIS);
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(zdt)).toFormatter();
+ TemporalAccessor accessor = f.parse("1234567890");
+ assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(2010, 6, 30));
+ assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.of(12, 30));
+ assertEquals(accessor.query(TemporalQueries.chronology()), IsoChronology.INSTANCE);
+ assertEquals(accessor.query(TemporalQueries.zoneId()), EUROPE_PARIS);
+ }
+
+ @Test
+ public void test_fieldResolvesToChronoZonedDateTime_overrideChrono_matches() {
+ MinguoDate mdt = MinguoDate.of(100, 6, 30);
+ ChronoZonedDateTime<MinguoDate> mzdt = mdt.atTime(LocalTime.NOON).atZone(EUROPE_PARIS);
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(mzdt)).toFormatter();
+ f = f.withChronology(MinguoChronology.INSTANCE);
+ TemporalAccessor accessor = f.parse("1234567890");
+ assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.from(mdt));
+ assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.NOON);
+ assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
+ assertEquals(accessor.query(TemporalQueries.zoneId()), EUROPE_PARIS);
+ }
+
+ @Test(expectedExceptions = DateTimeParseException.class)
+ public void test_fieldResolvesToChronoZonedDateTime_noOverrideChrono_wrongChrono() {
+ ChronoZonedDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON).atZone(EUROPE_PARIS);
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
f.parse("1234567890");
}
+ @Test(expectedExceptions = DateTimeParseException.class)
+ public void test_fieldResolvesToChronoZonedDateTime_overrideChrono_wrongChrono() {
+ ChronoZonedDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON).atZone(EUROPE_PARIS);
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
+ f = f.withChronology(MinguoChronology.INSTANCE);
+ f.parse("1234567890");
+ }
+
+ @Test
+ public void test_fieldResolvesToChronoZonedDateTime_overrideZone_matches() {
+ ZonedDateTime zdt = ZonedDateTime.of(2010, 6, 30, 12, 30, 0, 0, EUROPE_PARIS);
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(zdt)).toFormatter();
+ f = f.withZone(EUROPE_PARIS);
+ assertEquals(f.parse("1234567890", ZonedDateTime::from), zdt);
+ }
+
+ @Test(expectedExceptions = DateTimeParseException.class)
+ public void test_fieldResolvesToChronoZonedDateTime_overrideZone_wrongZone() {
+ ZonedDateTime zdt = ZonedDateTime.of(2010, 6, 30, 12, 30, 0, 0, EUROPE_PARIS);
+ DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(zdt)).toFormatter();
+ f = f.withZone(ZoneId.of("Europe/London"));
+ f.parse("1234567890");
+ }
+
+ //-------------------------------------------------------------------------
+ private static class ResolvingField implements TemporalField {
+ private final TemporalAccessor resolvedValue;
+ ResolvingField(TemporalAccessor resolvedValue) {
+ this.resolvedValue = resolvedValue;
+ }
+ @Override
+ public TemporalUnit getBaseUnit() {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public TemporalUnit getRangeUnit() {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public ValueRange range() {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public boolean isDateBased() {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public boolean isTimeBased() {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public boolean isSupportedBy(TemporalAccessor temporal) {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public ValueRange rangeRefinedBy(TemporalAccessor temporal) {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public long getFrom(TemporalAccessor temporal) {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public <R extends Temporal> R adjustInto(R temporal, long newValue) {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public TemporalAccessor resolve(
+ Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
+ fieldValues.remove(this);
+ return resolvedValue;
+ }
+ };
+
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Arrays/StreamAndSpliterator.java Tue Mar 25 14:51:01 2014 -0700
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test 8037857
+ * @summary tests for stream and spliterator factory methods
+ * @run testng StreamAndSpliterator
+ */
+
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.Spliterators;
+
+import static org.testng.Assert.assertNotNull;
+
+public class StreamAndSpliterator {
+ @Test
+ public void testStreamNPEs() {
+ assertThrowsNPE(() -> Arrays.stream((int[]) null, 0, 0));
+ assertThrowsNPE(() -> Arrays.stream((long[]) null, 0, 0));
+ assertThrowsNPE(() -> Arrays.stream((double[]) null, 0, 0));
+ assertThrowsNPE(() -> Arrays.stream((String[]) null, 0, 0));
+ }
+
+ @Test
+ public void testStreamAIOBEs() {
+ // origin > fence
+ assertThrowsAIOOB(() -> Arrays.stream(new int[]{}, 1, 0));
+ assertThrowsAIOOB(() -> Arrays.stream(new long[]{}, 1, 0));
+ assertThrowsAIOOB(() -> Arrays.stream(new double[]{}, 1, 0));
+ assertThrowsAIOOB(() -> Arrays.stream(new String[]{}, 1, 0));
+
+ // bad origin
+ assertThrowsAIOOB(() -> Arrays.stream(new int[]{}, -1, 0));
+ assertThrowsAIOOB(() -> Arrays.stream(new long[]{}, -1, 0));
+ assertThrowsAIOOB(() -> Arrays.stream(new double[]{}, -1, 0));
+ assertThrowsAIOOB(() -> Arrays.stream(new String[]{}, -1, 0));
+
+ // bad fence
+ assertThrowsAIOOB(() -> Arrays.stream(new int[]{}, 0, 1));
+ assertThrowsAIOOB(() -> Arrays.stream(new long[]{}, 0, 1));
+ assertThrowsAIOOB(() -> Arrays.stream(new double[]{}, 0, 1));
+ assertThrowsAIOOB(() -> Arrays.stream(new String[]{}, 0, 1));
+ }
+
+
+ @Test
+ public void testSpliteratorNPEs() {
+ assertThrowsNPE(() -> Arrays.spliterator((int[]) null, 0, 0));
+ assertThrowsNPE(() -> Arrays.spliterator((long[]) null, 0, 0));
+ assertThrowsNPE(() -> Arrays.spliterator((double[]) null, 0, 0));
+ assertThrowsNPE(() -> Arrays.spliterator((String[]) null, 0, 0));
+ }
+
+ @Test
+ public void testSpliteratorAIOBEs() {
+ // origin > fence
+ assertThrowsAIOOB(() -> Arrays.spliterator(new int[]{}, 1, 0));
+ assertThrowsAIOOB(() -> Arrays.spliterator(new long[]{}, 1, 0));
+ assertThrowsAIOOB(() -> Arrays.spliterator(new double[]{}, 1, 0));
+ assertThrowsAIOOB(() -> Arrays.spliterator(new String[]{}, 1, 0));
+
+ // bad origin
+ assertThrowsAIOOB(() -> Arrays.spliterator(new int[]{}, -1, 0));
+ assertThrowsAIOOB(() -> Arrays.spliterator(new long[]{}, -1, 0));
+ assertThrowsAIOOB(() -> Arrays.spliterator(new double[]{}, -1, 0));
+ assertThrowsAIOOB(() -> Arrays.spliterator(new String[]{}, -1, 0));
+
+ // bad fence
+ assertThrowsAIOOB(() -> Arrays.spliterator(new int[]{}, 0, 1));
+ assertThrowsAIOOB(() -> Arrays.spliterator(new long[]{}, 0, 1));
+ assertThrowsAIOOB(() -> Arrays.spliterator(new double[]{}, 0, 1));
+ assertThrowsAIOOB(() -> Arrays.spliterator(new String[]{}, 0, 1));
+ }
+
+
+ @Test
+ public void testSpliteratorNPEsFromSpliterators() {
+ assertThrowsNPE(() -> Spliterators.spliterator((int[]) null, 0, 0, 0));
+ assertThrowsNPE(() -> Spliterators.spliterator((long[]) null, 0, 0, 0));
+ assertThrowsNPE(() -> Spliterators.spliterator((double[]) null, 0, 0, 0));
+ assertThrowsNPE(() -> Spliterators.spliterator((String[]) null, 0, 0, 0));
+ }
+
+ @Test
+ public void testSpliteratorAIOBEsFromSpliterators() {
+ // origin > fence
+ assertThrowsAIOOB(() -> Spliterators.spliterator(new int[]{}, 1, 0, 0));
+ assertThrowsAIOOB(() -> Spliterators.spliterator(new long[]{}, 1, 0, 0));
+ assertThrowsAIOOB(() -> Spliterators.spliterator(new double[]{}, 1, 0, 0));
+ assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, 1, 0, 0));
+
+ // bad origin
+ assertThrowsAIOOB(() -> Spliterators.spliterator(new int[]{}, -1, 0, 0));
+ assertThrowsAIOOB(() -> Spliterators.spliterator(new long[]{}, -1, 0, 0));
+ assertThrowsAIOOB(() -> Spliterators.spliterator(new double[]{}, -1, 0, 0));
+ assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, -1, 0, 0));
+
+ // bad fence
+ assertThrowsAIOOB(() -> Spliterators.spliterator(new int[]{}, 0, 1, 0));
+ assertThrowsAIOOB(() -> Spliterators.spliterator(new long[]{}, 0, 1, 0));
+ assertThrowsAIOOB(() -> Spliterators.spliterator(new double[]{}, 0, 1, 0));
+ assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, 0, 1, 0));
+ }
+
+ void assertThrowsNPE(Runnable r) {
+ NullPointerException caught = null;
+ try {
+ r.run();
+ }
+ catch (NullPointerException e) {
+ caught = e;
+ }
+ assertNotNull(caught, "NullPointerException not thrown");
+ }
+
+ void assertThrowsAIOOB(Runnable r) {
+ ArrayIndexOutOfBoundsException caught = null;
+ try {
+ r.run();
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ caught = e;
+ }
+ assertNotNull(caught, "ArrayIndexOutOfBoundsException not thrown");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/xml/jaxp/XPath/8035577/Regex.java Tue Mar 25 14:51:01 2014 -0700
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8035577
+ * @summary Tests for xpath regular expression methods.
+ * @run main Regex
+ * @author david.x.li@oracle.com
+ */
+
+import com.sun.org.apache.xerces.internal.impl.xpath.regex.RegularExpression;
+import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException;
+
+public class Regex {
+
+ public static void main(String[] args) {
+ testIntersect();
+ }
+
+ static void testIntersect() {
+ // The use of intersection operator & is not allowed in
+ // XML schema. Consequently, the intersection operator
+ // can never be called except for internal API usage.
+ // Following test illustrates this.
+ try{
+ new RegularExpression("(?[b-d]&[a-r])", "X");
+ throw new RuntimeException ("Xerces XPath Regex: " +
+ "intersection not allowed in XML schema mode, " +
+ "exception expected above.");
+ }
+ catch (ParseException e) {
+ // Empty, expecting an exception
+ }
+
+ // Bug 8035577: verifying a typo fix in RangeToken.intersectRanges.
+ // Note: Each test case has a diagram showing the ranges being tested.
+ // Following test case will trigger the typo.
+ // o-----o
+ // o-----o
+ RegularExpression ce = new RegularExpression("(?[a-e]&[c-r])");
+ if (!(ce.matches("c") && ce.matches("d") && ce.matches("e"))) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[c-e] expected to match c,d,e.");
+ }
+
+ if (ce.matches("b") || ce.matches("f")) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[c-e] not expected to match b or f.");
+ }
+
+ // Test the expected behavior after fixing the typo.
+ // o------o
+ // o-------------o
+ RegularExpression bd = new RegularExpression("(?[b-d]&[a-r])");
+ if (!(bd.matches("b") && bd.matches("c") && bd.matches("d"))) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[b-d] expected to match b,c,d.");
+ }
+
+ if (bd.matches("e") || bd.matches("a")) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[b-d] not expected to match a or e.");
+ }
+
+ // Bug fix for first range ends later than second range.
+ // o--------o
+ // o--o
+ RegularExpression bd2 = new RegularExpression("(?[a-r]&[b-d])");
+ if (!(bd.matches("b") && bd.matches("c") && bd.matches("d"))) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[b-d] expected to match b,c,d, test 2.");
+ }
+
+ if (bd2.matches("e") || bd2.matches("a")) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[b-d] not expected to match a or e, test 2.");
+ }
+
+ // o-----o
+ // o----o
+ RegularExpression dh = new RegularExpression("(?[d-z]&[a-h])");
+ if (!(dh.matches("d") && dh.matches("e") && dh.matches("h"))) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[d-h] expected to match d,e,h.");
+ }
+
+ if (dh.matches("c") || bd2.matches("i")) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[d-h] not expected to match c or i.");
+ }
+
+ // Test code improvement, addition of src2+=2 to one of the
+ // conditions. In this case, src1 leftover from matching
+ // first portion of src2 is re-used to match against the next
+ // portion of src2.
+ // o--------------o
+ // o--o o--o
+ RegularExpression dfhk = new RegularExpression("(?[b-r]&[d-fh-k])");
+ if (!(dfhk.matches("d") && dfhk.matches("f") && dfhk.matches("h") && dfhk.matches("k"))) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[d-fh-k] expected to match d,f,h,k.");
+ }
+
+ if (dfhk.matches("c") || dfhk.matches("g") || dfhk.matches("l")) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[d-fh-k] not expected to match c,g,l.");
+ }
+
+ // random tests
+ // o------------o
+ // o-----o o--o
+ RegularExpression cfhk = new RegularExpression("(?[c-r]&[b-fh-k])");
+ if (!(cfhk.matches("c") && cfhk.matches("f") && cfhk.matches("h") && cfhk.matches("k"))) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[c-fh-k] expected to match c,f,h,k.");
+ }
+
+ if (cfhk.matches("b") || cfhk.matches("g") || cfhk.matches("l")) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[c-fh-k] not expected to match b,g,l.");
+ }
+
+ // o----------o
+ // o-----------o
+ // o----o o---o
+ RegularExpression ekor = new RegularExpression("(?[a-r]&[e-z]&[c-ko-s])");
+ if (!(ekor.matches("e") && ekor.matches("k") && ekor.matches("o") && ekor.matches("r"))) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[e-ko-r] expected to match e,k,o,r.");
+ }
+
+ if (ekor.matches("d") || ekor.matches("l") || ekor.matches("s")) {
+ throw new RuntimeException("Xerces XPath Regex Error: " +
+ "[e-ko-r] not expected to match d,l,s.");
+ }
+
+ }
+
+}
--- a/jdk/test/sun/tools/jinfo/Basic.sh Wed Jul 05 19:34:04 2017 +0200
+++ b/jdk/test/sun/tools/jinfo/Basic.sh Tue Mar 25 14:51:01 2014 -0700
@@ -40,6 +40,7 @@
# all return statuses are checked in this test
set +e
+set -x
failed=0
@@ -71,16 +72,6 @@
# no option
${JINFO} -J-XX:+UsePerfData -F $appJavaPid
if [ $? != 0 ]; then failed=1; fi
-
- # -flag option
- ${JINFO} -J-XX:+UsePerfData -F -flag +PrintGC $appJavaPid
- if [ $? != 0 ]; then failed=1; fi
-
- ${JINFO} -J-XX:+UsePerfData -F -flag -PrintGC $appJavaPid
- if [ $? != 0 ]; then failed=1; fi
-
- ${JINFO} -J-XX:+UsePerfData -F -flag PrintGC $appJavaPid
- if [ $? != 0 ]; then failed=1; fi
fi
# -sysprops option