This commit is contained in:
Bob Vandette 2018-06-12 18:53:38 -04:00
commit deba30de16
2767 changed files with 221508 additions and 36593 deletions

View file

@ -609,12 +609,13 @@ public final class LauncherHelper {
}
// From src/share/bin/java.c:
// enum LaunchMode { LM_UNKNOWN = 0, LM_CLASS, LM_JAR, LM_MODULE }
// enum LaunchMode { LM_UNKNOWN = 0, LM_CLASS, LM_JAR, LM_MODULE, LM_SOURCE }
private static final int LM_UNKNOWN = 0;
private static final int LM_CLASS = 1;
private static final int LM_JAR = 2;
private static final int LM_MODULE = 3;
private static final int LM_SOURCE = 4;
static void abort(Throwable t, String msgKey, Object... args) {
if (msgKey != null) {
@ -645,13 +646,21 @@ public final class LauncherHelper {
*
* @return the application's main class
*/
@SuppressWarnings("fallthrough")
public static Class<?> checkAndLoadMain(boolean printToStderr,
int mode,
String what) {
initOutput(printToStderr);
Class<?> mainClass = (mode == LM_MODULE) ? loadModuleMainClass(what)
: loadMainClass(mode, what);
Class<?> mainClass = null;
switch (mode) {
case LM_MODULE: case LM_SOURCE:
mainClass = loadModuleMainClass(what);
break;
default:
mainClass = loadMainClass(mode, what);
break;
}
// record the real main class for UI purposes
// neither method above can return null, they will abort()

View file

@ -25,13 +25,17 @@
# Translators please note do not translate the options themselves
java.launcher.opt.header = Usage: {0} [options] <mainclass> [args...]\n\
\ (to execute a class)\n or {0} [options] -jar <jarfile> [args...]\n\
\ (to execute a class)\n\
\ or {0} [options] -jar <jarfile> [args...]\n\
\ (to execute a jar file)\n\
\ or {0} [options] -m <module>[/<mainclass>] [args...]\n\
\ {0} [options] --module <module>[/<mainclass>] [args...]\n\
\ (to execute the main class in a module)\n\n\
\ Arguments following the main class, -jar <jarfile>, -m or --module\n\
\ <module>/<mainclass> are passed as the arguments to main class.\n\n\
\ (to execute the main class in a module)\n\
\ or {0} [options] <sourcefile> [args]\n\
\ (to execute a single source-file program)\n\n\
\ Arguments following the main class, source file, -jar <jarfile>,\n\
\ -m or --module <module>/<mainclass> are passed as the arguments to\n\
\ main class.\n\n\
\ where options include:\n\n
java.launcher.opt.vmselect =\ {0}\t to select the "{1}" VM\n
@ -114,7 +118,7 @@ java.launcher.opt.footer = \
\ -disable-@files\n\
\ prevent further argument file expansion\n\
\ --enable-preview\n\
\ allow classes to depend on preview features of this release
\ allow classes to depend on preview features of this release\n\
\To specify an argument for a long option, you can use --<name>=<value> or\n\
\--<name> <value>.\n
@ -180,7 +184,9 @@ java.launcher.X.usage=\n\
\ --patch-module <module>=<file>({0}<file>)*\n\
\ override or augment a module with classes and resources\n\
\ in JAR files or directories.\n\
\ --disable-@files disable further argument file expansion\n\n\
\ --disable-@files disable further argument file expansion\n\
\ --source <version>\n\
\ set the version of the source in source-file mode.\n\n\
These extra options are subject to change without notice.\n
# Translators please note do not translate the options themselves

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -30,6 +30,7 @@ import java.net.SocketException;
import java.net.SocketOption;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Defines the infrastructure to support extended socket options, beyond those
@ -40,6 +41,9 @@ import java.util.Set;
*/
public abstract class ExtendedSocketOptions {
public static final short SOCK_STREAM = 1;
public static final short SOCK_DGRAM = 2;
private final Set<SocketOption<?>> options;
/** Tells whether or not the option is supported. */
@ -50,6 +54,30 @@ public abstract class ExtendedSocketOptions {
/** Return the, possibly empty, set of extended socket options available. */
public final Set<SocketOption<?>> options() { return options; }
public static final Set<SocketOption<?>> options(short type) {
return getInstance().options0(type);
}
private Set<SocketOption<?>> options0(short type) {
Set<SocketOption<?>> extOptions = null;
switch (type) {
case SOCK_DGRAM:
extOptions = options.stream()
.filter((option) -> !option.name().startsWith("TCP_"))
.collect(Collectors.toUnmodifiableSet());
break;
case SOCK_STREAM:
extOptions = options.stream()
.filter((option) -> !option.name().startsWith("UDP_"))
.collect(Collectors.toUnmodifiableSet());
break;
default:
//this will never happen
throw new IllegalArgumentException("Invalid socket option type");
}
return extOptions;
}
/** Sets the value of a socket option, for the given socket. */
public abstract void setOption(FileDescriptor fd, SocketOption<?> option, Object value)
throws SocketException;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2018, 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
@ -39,6 +39,8 @@ import java.util.concurrent.Future;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import sun.net.NetHooks;
import sun.net.ext.ExtendedSocketOptions;
import static sun.net.ext.ExtendedSocketOptions.SOCK_STREAM;
/**
* Base implementation of AsynchronousServerSocketChannel.
@ -234,6 +236,7 @@ abstract class AsynchronousServerSocketChannelImpl
if (Net.isReusePortAvailable()) {
set.add(StandardSocketOptions.SO_REUSEPORT);
}
set.addAll(ExtendedSocketOptions.options(SOCK_STREAM));
return Collections.unmodifiableSet(set);
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2018, 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
@ -40,6 +40,7 @@ import java.util.concurrent.*;
import java.util.concurrent.locks.*;
import sun.net.NetHooks;
import sun.net.ext.ExtendedSocketOptions;
import static sun.net.ext.ExtendedSocketOptions.SOCK_STREAM;
/**
* Base implementation of AsynchronousSocketChannel
@ -512,9 +513,7 @@ abstract class AsynchronousSocketChannelImpl
set.add(StandardSocketOptions.SO_REUSEPORT);
}
set.add(StandardSocketOptions.TCP_NODELAY);
ExtendedSocketOptions extendedOptions =
ExtendedSocketOptions.getInstance();
set.addAll(extendedOptions.options());
set.addAll(ExtendedSocketOptions.options(SOCK_STREAM));
return Collections.unmodifiableSet(set);
}
}

View file

@ -57,6 +57,7 @@ import java.util.concurrent.locks.ReentrantLock;
import sun.net.ResourceManager;
import sun.net.ext.ExtendedSocketOptions;
import static sun.net.ext.ExtendedSocketOptions.SOCK_DGRAM;
/**
* An implementation of DatagramChannels.
@ -334,7 +335,7 @@ class DatagramChannelImpl
set.add(StandardSocketOptions.IP_MULTICAST_IF);
set.add(StandardSocketOptions.IP_MULTICAST_TTL);
set.add(StandardSocketOptions.IP_MULTICAST_LOOP);
set.addAll(ExtendedSocketOptions.getInstance().options());
set.addAll(ExtendedSocketOptions.options(SOCK_DGRAM));
return Collections.unmodifiableSet(set);
}
}

View file

@ -25,6 +25,9 @@
package sun.nio.ch;
import java.lang.invoke.ConstantBootstraps;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
@ -39,6 +42,13 @@ import java.nio.channels.spi.AbstractSelectionKey;
public final class SelectionKeyImpl
extends AbstractSelectionKey
{
private static final VarHandle INTERESTOPS =
ConstantBootstraps.fieldVarHandle(
MethodHandles.lookup(),
"interestOps",
VarHandle.class,
SelectionKeyImpl.class, int.class);
private final SelChImpl channel;
private final SelectorImpl selector;
@ -84,7 +94,35 @@ public final class SelectionKeyImpl
@Override
public SelectionKey interestOps(int ops) {
ensureValid();
return nioInterestOps(ops);
if ((ops & ~channel().validOps()) != 0)
throw new IllegalArgumentException();
int oldOps = (int) INTERESTOPS.getAndSet(this, ops);
if (ops != oldOps) {
selector.setEventOps(this);
}
return this;
}
@Override
public int interestOpsOr(int ops) {
ensureValid();
if ((ops & ~channel().validOps()) != 0)
throw new IllegalArgumentException();
int oldVal = (int) INTERESTOPS.getAndBitwiseOr(this, ops);
if (oldVal != (oldVal | ops)) {
selector.setEventOps(this);
}
return oldVal;
}
@Override
public int interestOpsAnd(int ops) {
ensureValid();
int oldVal = (int) INTERESTOPS.getAndBitwiseAnd(this, ops);
if (oldVal != (oldVal & ops)) {
selector.setEventOps(this);
}
return oldVal;
}
@Override

View file

@ -49,6 +49,8 @@ import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import sun.net.NetHooks;
import sun.net.ext.ExtendedSocketOptions;
import static sun.net.ext.ExtendedSocketOptions.SOCK_STREAM;
/**
* An implementation of ServerSocketChannels
@ -199,6 +201,7 @@ class ServerSocketChannelImpl
set.add(StandardSocketOptions.SO_REUSEPORT);
}
set.add(StandardSocketOptions.IP_TOS);
set.addAll(ExtendedSocketOptions.options(SOCK_STREAM));
return Collections.unmodifiableSet(set);
}
}

View file

@ -54,6 +54,7 @@ import java.util.concurrent.locks.ReentrantLock;
import sun.net.NetHooks;
import sun.net.ext.ExtendedSocketOptions;
import static sun.net.ext.ExtendedSocketOptions.SOCK_STREAM;
/**
* An implementation of SocketChannels
@ -280,7 +281,7 @@ class SocketChannelImpl
// additional options required by socket adaptor
set.add(StandardSocketOptions.IP_TOS);
set.add(ExtendedSocketOption.SO_OOBINLINE);
set.addAll(ExtendedSocketOptions.getInstance().options());
set.addAll(ExtendedSocketOptions.options(SOCK_STREAM));
return Collections.unmodifiableSet(set);
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2018, 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
@ -106,6 +106,7 @@ public class FormatData extends ParallelListResourceBundle {
"T",
"S",
"H",
"N", // NewEra
};
// Japanese imperial calendar era strings
@ -115,6 +116,7 @@ public class FormatData extends ParallelListResourceBundle {
"Taisho",
"Showa",
"Heisei",
"NewEra", // NewEra
};
return new Object[][] {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2018, 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
@ -159,6 +159,7 @@ public class JavaTimeSupplementary extends OpenListResourceBundle {
"Taisho",
"Showa",
"Heisei",
"NewEra", // New Era
};
final String[] sharedShortEras = {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2018, 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
@ -48,6 +48,7 @@ import java.util.TimeZone;
* Taisho 1912-07-30T00:00:00 local time
* Showa 1926-12-25T00:00:00 local time
* Heisei 1989-01-08T00:00:00 local time
* NewEra 2019-05-01T00:00:00 local time
* -----------------------------------------------------------------------
* }</pre>
*

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,6 +27,8 @@ package sun.util.calendar;
import java.security.AccessController;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import sun.security.action.GetPropertyAction;
/**
@ -41,11 +43,12 @@ public class LocalGregorianCalendar extends BaseCalendar {
new Era("Taisho", "T", -1812153600000L, true),
new Era("Showa", "S", -1357603200000L, true),
new Era("Heisei", "H", 600220800000L, true),
new Era("NewEra", "N", 1556668800000L, true),
};
private static boolean isValidEra(Era newEra, Era[] eras) {
Era last = eras[eras.length - 1];
if (last.getSinceDate().getYear() >= newEra.getSinceDate().getYear()) {
if (last.getSince(null) >= newEra.getSince(null)) {
return false;
}
// The new era name should be unique. Its abbr may not.
@ -173,7 +176,7 @@ public class LocalGregorianCalendar extends BaseCalendar {
return null;
}
String key = keyvalue[0].trim();
String value = keyvalue[1].trim();
String value = convertUnicodeEscape(keyvalue[1].trim());
switch (key) {
case "name":
eraName = value;
@ -203,6 +206,17 @@ public class LocalGregorianCalendar extends BaseCalendar {
return new Era(eraName, abbr, since, localTime);
}
private static String convertUnicodeEscape(String src) {
Matcher m = Pattern.compile("\\\\u([0-9a-fA-F]{4})").matcher(src);
StringBuilder sb = new StringBuilder();
while (m.find()) {
m.appendReplacement(sb,
Character.toString((char)Integer.parseUnsignedInt(m.group(1), 16)));
}
m.appendTail(sb);
return sb.toString();
}
private LocalGregorianCalendar(String name, Era[] eras) {
this.name = name;
this.eras = eras;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, 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
@ -35,8 +35,8 @@ import sun.util.calendar.CalendarSystem;
import sun.util.calendar.Era;
/**
* Concrete implementation of the {@link java.util.spi.CalendarDataProvider
* CalendarDataProvider} class for the JRE LocaleProviderAdapter.
* Concrete implementation of the {@link java.util.spi.CalendarNameProvider
* CalendarNameProvider} class for the JRE LocaleProviderAdapter.
*
* @author Masayoshi Okutsu
* @author Naoto Sato
@ -77,28 +77,43 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av
if (field == DAY_OF_WEEK || field == YEAR) {
--value;
}
if (value < 0 || value > strings.length) {
if (value < 0) {
return null;
} else if (value == strings.length) {
} else if (value >= strings.length) {
if (field == ERA && "japanese".equals(calendarType)) {
// get the supplemental era, if any, specified through
// the property "jdk.calendar.japanese.supplemental.era"
// which is always the last element.
Era[] jeras = CalendarSystem.forName("japanese").getEras();
if (jeras.length == value) {
Era supEra = jeras[value - 1]; // 0-based index
if (javatime) {
return getBaseStyle(style) == NARROW_FORMAT ?
supEra.getAbbreviation() :
supEra.getName();
} else {
return (style & LONG) != 0 ?
supEra.getName() :
supEra.getAbbreviation();
if (value <= jeras.length) {
// Localized era name could not be retrieved from this provider.
// This can occur either for NewEra or SupEra.
//
// If it's CLDR provider, try COMPAT first, which is guaranteed to have
// the name for NewEra.
if (type == LocaleProviderAdapter.Type.CLDR) {
lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
key = getResourceKeyFor(LocaleProviderAdapter.Type.JRE,
calendarType, field, style, javatime);
strings =
javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key);
}
if (strings == null || value >= strings.length) {
// Get the default name for SupEra
Era supEra = jeras[value - 1]; // 0-based index
if (javatime) {
return getBaseStyle(style) == NARROW_FORMAT ?
supEra.getAbbreviation() :
supEra.getName();
} else {
return (style & LONG) != 0 ?
supEra.getName() :
supEra.getAbbreviation();
}
}
} else {
return null;
}
} else {
return null;
}
return null;
}
name = strings[value];
// If name is empty in standalone, try its `format' style.
@ -180,7 +195,7 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av
return map;
}
private int getBaseStyle(int style) {
private static int getBaseStyle(int style) {
return style & ~(SHORT_STANDALONE - SHORT_FORMAT);
}
@ -261,6 +276,11 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av
}
private String getResourceKey(String type, int field, int style, boolean javatime) {
return getResourceKeyFor(this.type, type, field, style, javatime);
}
private static String getResourceKeyFor(LocaleProviderAdapter.Type adapterType,
String type, int field, int style, boolean javatime) {
int baseStyle = getBaseStyle(style);
boolean isStandalone = (style != baseStyle);
@ -284,7 +304,7 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av
// JRE and CLDR use different resource key conventions
// due to historical reasons. (JRE DateFormatSymbols.getEras returns
// abbreviations while other getShort*() return abbreviations.)
if (this.type == LocaleProviderAdapter.Type.JRE) {
if (adapterType == LocaleProviderAdapter.Type.JRE) {
if (javatime) {
if (baseStyle == LONG) {
key.append("long.");
@ -336,7 +356,7 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av
return key.length() > 0 ? key.toString() : null;
}
private String toStyleName(int baseStyle) {
private static String toStyleName(int baseStyle) {
switch (baseStyle) {
case SHORT:
return "Abbreviations";

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2005, 2018, 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
@ -178,6 +178,7 @@ MMK=MMK
MNT=MNT
MOP=MOP
MRO=MRO
MRU=MRU
MTL=MTL
MUR=MUR
MVR=MVR
@ -399,6 +400,7 @@ mmk=Myanma Kyat
mnt=Mongolian Tugrik
mop=Macanese Pataca
mro=Mauritanian Ouguiya
mru=Mauritanian Ouguiya
mtl=Maltese Lira
mur=Mauritian Rupee
mvr=Maldivian Rufiyaa